Skip to content

Commit

Permalink
fix create package policy test
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaElastic committed Nov 8, 2024
1 parent 0e736e3 commit b8c926b
Showing 1 changed file with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jest.mock('../../../../hooks', () => {
sendGetStatus: jest
.fn()
.mockResolvedValue({ data: { isReady: true, missing_requirements: [] } }),
sendGetAgentStatus: jest.fn().mockResolvedValue({ data: { results: { total: 0 } } }),
sendGetAgentStatus: jest.fn().mockResolvedValue({ data: { results: { active: 0 } } }),
useGetAgentPolicies: jest.fn().mockReturnValue({
data: {
items: [
Expand Down Expand Up @@ -154,14 +154,7 @@ afterAll(() => {
consoleDebugMock.mockRestore();
});

// FLAKY: https://github.com/elastic/kibana/issues/196463
// FLAKY: https://github.com/elastic/kibana/issues/196464
// FLAKY: https://github.com/elastic/kibana/issues/196465
// FLAKY: https://github.com/elastic/kibana/issues/196466
// FLAKY: https://github.com/elastic/kibana/issues/196467
// FLAKY: https://github.com/elastic/kibana/issues/196468
// FLAKY: https://github.com/elastic/kibana/issues/196469
describe.skip('When on the package policy create page', () => {
describe('When on the package policy create page', () => {
afterEach(() => {
jest.clearAllMocks();
});
Expand Down Expand Up @@ -534,7 +527,7 @@ describe.skip('When on the package policy create page', () => {
(sendCreateAgentPolicy as jest.MockedFunction<any>).mockClear();
(sendCreatePackagePolicy as jest.MockedFunction<any>).mockClear();
(sendGetAgentStatus as jest.MockedFunction<any>).mockResolvedValue({
data: { results: { total: 0 } },
data: { results: { active: 0 } },
});
});

Expand Down Expand Up @@ -584,7 +577,7 @@ describe.skip('When on the package policy create page', () => {

test('should show modal if agent policy has agents', async () => {
(sendGetAgentStatus as jest.MockedFunction<any>).mockResolvedValue({
data: { results: { total: 1 } },
data: { results: { active: 1 } },
});

await act(async () => {
Expand Down Expand Up @@ -787,7 +780,7 @@ describe.skip('When on the package policy create page', () => {

test('should not show confirmation modal', async () => {
(sendGetAgentStatus as jest.MockedFunction<any>).mockResolvedValueOnce({
data: { results: { total: 1 } },
data: { results: { active: 1 } },
});

await act(async () => {
Expand Down Expand Up @@ -854,8 +847,8 @@ describe.skip('When on the package policy create page', () => {
expect(sendGetOneAgentPolicy).not.toHaveBeenCalled();
expect(sendCreateAgentPolicy).toHaveBeenCalledWith(
expect.objectContaining({
monitoring_enabled: ['logs', 'metrics', 'traces'],
name: 'Agent policy 1',
monitoring_enabled: ['logs', 'metrics'],
name: 'Agentless policy for nginx-1',
}),
{ withSysMonitoring: true }
);
Expand All @@ -868,7 +861,7 @@ describe.skip('When on the package policy create page', () => {

test('should create agentless agent policy and package policy when in cloud and agentless API url is set', async () => {
fireEvent.click(renderResult.getByTestId(SETUP_TECHNOLOGY_SELECTOR_TEST_SUBJ));
fireEvent.click(renderResult.getByText('Agentless'));
fireEvent.click(renderResult.getAllByText('Agentless')[0]);
await act(async () => {
fireEvent.click(renderResult.getByText(/Save and continue/).closest('button')!);
});
Expand All @@ -879,7 +872,7 @@ describe.skip('When on the package policy create page', () => {
name: 'Agentless policy for nginx-1',
supports_agentless: true,
}),
{ withSysMonitoring: false }
{ withSysMonitoring: true }
);
expect(sendCreatePackagePolicy).toHaveBeenCalled();

Expand All @@ -894,7 +887,7 @@ describe.skip('When on the package policy create page', () => {
const mockApiCalls = (http: MockedFleetStartServices['http']) => {
http.get.mockImplementation(async (path: any) => {
if (path === '/api/fleet/agents/setup') {
return Promise.resolve({ data: { results: { total: 0 } } });
return Promise.resolve({ data: { results: { active: 0 } } });
}
if (path === '/api/fleet/package_policies') {
return Promise.resolve({ data: { items: [] } });
Expand Down

0 comments on commit b8c926b

Please sign in to comment.