Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fleet] fix create package policy test #199477

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading