Skip to content

Commit

Permalink
[Security Solution][Endpoint] Move artifact list page and host isolat…
Browse files Browse the repository at this point in the history
…ion exception skipped tests to jest integration (elastic#142275)

* Moved ArtifactListPage failing tests to integration_tests

* Fix failing test in artifact list page

* un-skip tests

* move host isolation exceptions list test to jest integration tests

* Un-skip tests from host isolation exceptions form test

* move tests from host isolation exceptions form to integration_tests
  • Loading branch information
paul-tavares authored and WafaaNasr committed Oct 11, 2022
1 parent df69f21 commit 1ab287c
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
* 2.0.
*/

import type { AppContextTestRender } from '../../../../common/mock/endpoint';
import type { trustedAppsAllHttpMocks } from '../../../mocks';
import type { ArtifactListPageRenderingSetup } from '../mocks';
import { getArtifactListPageRenderingSetup } from '../mocks';
import type { AppContextTestRender } from '../../../../../common/mock/endpoint';
import type { trustedAppsAllHttpMocks } from '../../../../mocks';
import type { ArtifactListPageRenderingSetup } from '../../mocks';
import { getArtifactListPageRenderingSetup } from '../../mocks';
import { act, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { getDeferred } from '../../../mocks/utils';
import { getDeferred } from '../../../../mocks/utils';

describe('When displaying the Delete artifact modal in the Artifact List Page', () => {
let renderResult: ReturnType<AppContextTestRender['render']>;
Expand Down Expand Up @@ -77,14 +77,12 @@ describe('When displaying the Delete artifact modal in the Artifact List Page',
10000
);

// FLAKY: https://github.com/elastic/kibana/issues/139527
it.skip('should show Cancel and Delete buttons enabled', async () => {
it('should show Cancel and Delete buttons enabled', async () => {
expect(cancelButton).toBeEnabled();
expect(submitButton).toBeEnabled();
});

// FLAKY: https://github.com/elastic/kibana/issues/139528
it.skip('should close modal if Cancel/Close buttons are clicked', async () => {
it('should close modal if Cancel/Close buttons are clicked', async () => {
userEvent.click(cancelButton);

expect(renderResult.queryByTestId('testPage-deleteModal')).toBeNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@
* 2.0.
*/

import type { AppContextTestRender } from '../../../common/mock/endpoint';
import type { trustedAppsAllHttpMocks } from '../../mocks';
import type { ArtifactListPageProps } from './artifact_list_page';
import type { AppContextTestRender } from '../../../../common/mock/endpoint';
import type { trustedAppsAllHttpMocks } from '../../../mocks';
import type { ArtifactListPageProps } from '../artifact_list_page';
import { act, fireEvent, waitFor, waitForElementToBeRemoved } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import type { ArtifactListPageRenderingSetup } from './mocks';
import { getArtifactListPageRenderingSetup } from './mocks';
import { getDeferred } from '../../mocks/utils';
import type { ArtifactListPageRenderingSetup } from '../mocks';
import { getArtifactListPageRenderingSetup } from '../mocks';
import { getDeferred } from '../../../mocks/utils';

jest.mock('../../../common/components/user_privileges');
jest.mock('../../../../common/components/user_privileges');

// FLAKY: https://github.com/elastic/kibana/issues/140620
describe.skip('When using the ArtifactListPage component', () => {
describe('When using the ArtifactListPage component', () => {
let render: (
props?: Partial<ArtifactListPageProps>
) => ReturnType<AppContextTestRender['render']>;
Expand Down Expand Up @@ -64,6 +63,7 @@ describe.skip('When using the ArtifactListPage component', () => {
await act(async () => {
await waitFor(() => {
expect(renderResult.getByTestId('testPage-list')).toBeTruthy();
expect(mockedApi.responseProvider.trustedAppsList).toHaveBeenCalled();
});
});

Expand Down Expand Up @@ -121,11 +121,12 @@ describe.skip('When using the ArtifactListPage component', () => {
});
await act(async () => {
await waitFor(() => {
expect(getByTestId('tablePagination-20-rows'));
expect(getByTestId('tablePagination-20-rows')).toBeEnabled();
});
});
act(() => {
userEvent.click(getByTestId('tablePagination-20-rows'));

userEvent.click(getByTestId('tablePagination-20-rows'), undefined, {
skipPointerEventsCheck: true,
});

await waitFor(() => {
Expand All @@ -139,11 +140,17 @@ describe.skip('When using the ArtifactListPage component', () => {
act(() => {
switch (action) {
case 'delete':
userEvent.click(renderResult.getByTestId('testPage-card-cardDeleteAction'));
userEvent.click(
renderResult.getByTestId('testPage-card-cardDeleteAction'),
undefined,
{ skipPointerEventsCheck: true }
);
break;

case 'edit':
userEvent.click(renderResult.getByTestId('testPage-card-cardEditAction'));
userEvent.click(renderResult.getByTestId('testPage-card-cardEditAction'), undefined, {
skipPointerEventsCheck: true,
});
break;
}
});
Expand All @@ -156,8 +163,7 @@ describe.skip('When using the ArtifactListPage component', () => {
expect(getByTestId('testPage-flyout')).toBeTruthy();
});

// FLAKY: https://github.com/elastic/kibana/issues/129837
it.skip('should display the Delete modal when delete action is clicked', async () => {
it('should display the Delete modal when delete action is clicked', async () => {
const { getByTestId } = await renderWithListData();
await clickCardAction('delete');

Expand Down Expand Up @@ -228,8 +234,7 @@ describe.skip('When using the ArtifactListPage component', () => {
});
});

// FLAKY: https://github.com/elastic/kibana/issues/129837
it.skip('should persist policy filter to the URL params', async () => {
it('should persist policy filter to the URL params', async () => {
const policyId = mockedApi.responseProvider.endpointPackagePolicyList().items[0].id;
const firstPolicyTestId = `policiesSelector-popover-items-${policyId}`;

Expand All @@ -247,9 +252,10 @@ describe.skip('When using the ArtifactListPage component', () => {
await waitFor(() => {
expect(renderResult.getByTestId(firstPolicyTestId)).toBeTruthy();
});
userEvent.click(renderResult.getByTestId(firstPolicyTestId));
});

userEvent.click(renderResult.getByTestId(firstPolicyTestId));

await waitFor(() => {
expect(history.location.search).toMatch(new RegExp(`includedPolicies=${policyId}`));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,25 @@ import type {
} from '@kbn/securitysolution-io-ts-list-types';
import userEvent from '@testing-library/user-event';
import React from 'react';
import type { AppContextTestRender } from '../../../../../common/mock/endpoint';
import { createAppRootMockRenderer } from '../../../../../common/mock/endpoint';
import { HostIsolationExceptionsList } from '../host_isolation_exceptions_list';
import type { AppContextTestRender } from '../../../../../../common/mock/endpoint';
import { createAppRootMockRenderer } from '../../../../../../common/mock/endpoint';
import { HostIsolationExceptionsList } from '../../host_isolation_exceptions_list';
import { act, waitFor } from '@testing-library/react';
import { HOST_ISOLATION_EXCEPTIONS_PATH } from '../../../../../../common/constants';
import { HOST_ISOLATION_EXCEPTIONS_PATH } from '../../../../../../../common/constants';
import {
exceptionsListAllHttpMocks,
fleetGetEndpointPackagePolicyListHttpMock,
} from '../../../../mocks';
} from '../../../../../mocks';
import {
clickOnEffectedPolicy,
isEffectedPolicySelected,
} from '../../../../components/effected_policy_select/test_utils';
import { BY_POLICY_ARTIFACT_TAG_PREFIX } from '../../../../../../common/endpoint/service/artifacts';
} from '../../../../../components/effected_policy_select/test_utils';
import { BY_POLICY_ARTIFACT_TAG_PREFIX } from '../../../../../../../common/endpoint/service/artifacts';
import type { HttpFetchOptionsWithPath } from '@kbn/core/public';

jest.mock('../../../../../common/components/user_privileges');
jest.mock('../../../../../../common/components/user_privileges');

// FLAKY: https://github.com/elastic/kibana/issues/140907
describe.skip('When on the host isolation exceptions entry form', () => {
describe('When on the host isolation exceptions entry form', () => {
let render: () => Promise<ReturnType<AppContextTestRender['render']>>;
let renderResult: ReturnType<AppContextTestRender['render']>;
let history: AppContextTestRender['history'];
Expand Down Expand Up @@ -86,8 +85,7 @@ describe.skip('When on the host isolation exceptions entry form', () => {
await render();
});

// FLAKY: https://github.com/elastic/kibana/issues/140140
it.skip('should render the form with empty inputs', () => {
it('should render the form with empty inputs', () => {
expect(renderResult.getByTestId('hostIsolationExceptions-form-name-input')).toHaveValue('');
expect(renderResult.getByTestId('hostIsolationExceptions-form-ip-input')).toHaveValue('');
expect(
Expand Down Expand Up @@ -146,16 +144,14 @@ describe.skip('When on the host isolation exceptions entry form', () => {
).toBe(true);
});

// FLAKY: https://github.com/elastic/kibana/issues/139776
it.skip('should show policy as selected when user clicks on it', async () => {
it('should show policy as selected when user clicks on it', async () => {
userEvent.click(renderResult.getByTestId('perPolicy'));
await clickOnEffectedPolicy(renderResult);

await expect(isEffectedPolicySelected(renderResult)).resolves.toBe(true);
});

// FLAKY: https://github.com/elastic/kibana/issues/139899
it.skip('should retain the previous policy selection when switching from per-policy to global', async () => {
it('should retain the previous policy selection when switching from per-policy to global', async () => {
// move to per-policy and select the first
userEvent.click(renderResult.getByTestId('perPolicy'));
await clickOnEffectedPolicy(renderResult);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,21 @@
import { act, fireEvent, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';
import { HOST_ISOLATION_EXCEPTIONS_PATH } from '../../../../../common/constants';
import type { AppContextTestRender } from '../../../../common/mock/endpoint';
import { createAppRootMockRenderer } from '../../../../common/mock/endpoint';
import { HostIsolationExceptionsList } from './host_isolation_exceptions_list';
import { exceptionsListAllHttpMocks } from '../../../mocks/exceptions_list_http_mocks';
import { SEARCHABLE_FIELDS } from '../constants';
import { parseQueryFilterToKQL } from '../../../common/utils';
import { useUserPrivileges as _useUserPrivileges } from '../../../../common/components/user_privileges';
import { getUserPrivilegesMockDefaultValue } from '../../../../common/components/user_privileges/__mocks__';
import { getFirstCard } from '../../../components/artifact_list_page/mocks';

jest.mock('../../../../common/components/user_privileges');
import { HOST_ISOLATION_EXCEPTIONS_PATH } from '../../../../../../common/constants';
import type { AppContextTestRender } from '../../../../../common/mock/endpoint';
import { createAppRootMockRenderer } from '../../../../../common/mock/endpoint';
import { HostIsolationExceptionsList } from '../host_isolation_exceptions_list';
import { exceptionsListAllHttpMocks } from '../../../../mocks/exceptions_list_http_mocks';
import { SEARCHABLE_FIELDS } from '../../constants';
import { parseQueryFilterToKQL } from '../../../../common/utils';
import { useUserPrivileges as _useUserPrivileges } from '../../../../../common/components/user_privileges';
import { getUserPrivilegesMockDefaultValue } from '../../../../../common/components/user_privileges/__mocks__';
import { getFirstCard } from '../../../../components/artifact_list_page/mocks';

jest.mock('../../../../../common/components/user_privileges');
const useUserPrivilegesMock = _useUserPrivileges as jest.Mock;

// FLAKY: https://github.com/elastic/kibana/issues/140888
describe.skip('When on the host isolation exceptions page', () => {
describe('When on the host isolation exceptions page', () => {
let render: () => ReturnType<AppContextTestRender['render']>;
let renderResult: ReturnType<typeof render>;
let history: AppContextTestRender['history'];
Expand Down Expand Up @@ -78,8 +77,7 @@ describe.skip('When on the host isolation exceptions page', () => {
);
});

// FLAKY: https://github.com/elastic/kibana/issues/135587
it.skip('should hide the Create and Edit actions when host isolation authz is not allowed', async () => {
it('should hide the Create and Edit actions when host isolation authz is not allowed', async () => {
// Use case: license downgrade scenario, where user still has entries defined, but no longer
// able to create or edit them (only Delete them)
const existingPrivileges = useUserPrivilegesMock();
Expand Down

0 comments on commit 1ab287c

Please sign in to comment.