Skip to content

Commit

Permalink
[Fleet] fix create package policy test (#199477)
Browse files Browse the repository at this point in the history
## Summary

Enabling flaky create package policy test, fixing failures

Closes #196463
Closes #196464
Closes #196465
Closes #196466
Closes #196467
Closes #196468
Closes #196469
  • Loading branch information
juliaElastic authored Nov 8, 2024
1 parent d677153 commit 3dfe062
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 3dfe062

Please sign in to comment.