Skip to content

Commit

Permalink
[Security Solution][Endpoint] Fix test stability and un-skip flaky te…
Browse files Browse the repository at this point in the history
…sts (#130176)

* artifact list page component: fix url params for pagination not being defined as numbers
* Improvement to tests (maybe)
  • Loading branch information
paul-tavares authored Apr 18, 2022
1 parent 0fdccf7 commit 34dfeeb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ import {

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

// FLAKY: https://github.com/elastic/kibana/issues/129837
// FLAKY: https://github.com/elastic/kibana/issues/129836
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 @@ -115,7 +113,7 @@ describe.skip('When using the ArtifactListPage component', () => {
});
});

it('should persist pagination `page size` changes to the URL', async () => {
it('should persist pagination `pageSize` changes to the URL', async () => {
const { getByTestId } = await renderWithListData();
act(() => {
userEvent.click(getByTestId('tablePaginationPopoverButton'));
Expand All @@ -124,6 +122,8 @@ describe.skip('When using the ArtifactListPage component', () => {
await waitFor(() => {
expect(getByTestId('tablePagination-20-rows'));
});
});
act(() => {
userEvent.click(getByTestId('tablePagination-20-rows'));
});

Expand Down Expand Up @@ -159,7 +159,9 @@ describe.skip('When using the ArtifactListPage component', () => {
const { getByTestId } = await renderWithListData();
await clickCardAction('delete');

expect(getByTestId('testPage-deleteModal')).toBeTruthy();
await waitFor(() => {
expect(getByTestId('testPage-deleteModal')).toBeTruthy();
});
});
});

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

await waitFor(() => {
// console.log(`\n\n${renderResult.getByTestId('testPage-list').outerHTML}\n\n\n`);
expect(renderResult.getByTestId('testPage-list-noResults')).toBeTruthy();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ import { Pagination } from '@elastic/eui';
import { useQuery } from 'react-query';
import type { ServerApiError } from '../../../../common/types';
import { useIsMounted } from '../../hooks/use_is_mounted';
import {
MANAGEMENT_DEFAULT_PAGE_SIZE,
MANAGEMENT_PAGE_SIZE_OPTIONS,
} from '../../../common/constants';
import { MANAGEMENT_PAGE_SIZE_OPTIONS } from '../../../common/constants';
import { useUrlParams } from '../../hooks/use_url_params';
import { ExceptionsListApiClient } from '../../../services/exceptions_list/exceptions_list_api_client';
import { ArtifactListPageUrlParams } from '../types';
import { MaybeImmutable } from '../../../../../common/endpoint/types';
import { useKueryFromExceptionsSearchFilter } from './use_kuery_from_exceptions_search_filter';
import { useListArtifact } from '../../../hooks/artifacts';
import { useUrlPagination } from '../../hooks/use_url_pagination';

type WithArtifactListDataInterface = ReturnType<typeof useListArtifact> & {
/**
Expand All @@ -46,9 +44,13 @@ export const useWithArtifactListData = (
const isMounted = useIsMounted();

const {
urlParams: { page = 1, pageSize = MANAGEMENT_DEFAULT_PAGE_SIZE, filter, includedPolicies },
urlParams: { filter, includedPolicies },
} = useUrlParams<ArtifactListPageUrlParams>();

const {
pagination: { page, pageSize },
} = useUrlPagination();

// Used to determine if the `does data exist` check should be done.
const kuery = useKueryFromExceptionsSearchFilter(filter, searchableFields, includedPolicies);

Expand Down

0 comments on commit 34dfeeb

Please sign in to comment.