From 4abbe846089b573b51e4d62254ffa9b590a02670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20S=C3=A1nchez?= Date: Tue, 5 Dec 2023 19:20:04 +0100 Subject: [PATCH] [Security Solution][Endpoint] Set perPage to 1000 for package policies query in Endpoint Artifacts form (#172563) ## Summary It sets the `perPage` value to 1000 (overrides the default one set to `20`) in order to display more policies in Artifacts form and also in the policy filter for artifacts list. ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --- .../artifact_list_page/artifact_list_page.tsx | 1 + .../artifact_list_page.test.tsx | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/x-pack/plugins/security_solution/public/management/components/artifact_list_page/artifact_list_page.tsx b/x-pack/plugins/security_solution/public/management/components/artifact_list_page/artifact_list_page.tsx index fa2332eef20c7..abe52767c5d5e 100644 --- a/x-pack/plugins/security_solution/public/management/components/artifact_list_page/artifact_list_page.tsx +++ b/x-pack/plugins/security_solution/public/management/components/artifact_list_page/artifact_list_page.tsx @@ -163,6 +163,7 @@ export const ArtifactListPage = memo( }); const policiesRequest = useGetEndpointSpecificPolicies({ + perPage: 1000, onError: (err) => { toasts.addWarning(getLoadPoliciesError(err)); }, diff --git a/x-pack/plugins/security_solution/public/management/components/artifact_list_page/integration_tests/artifact_list_page.test.tsx b/x-pack/plugins/security_solution/public/management/components/artifact_list_page/integration_tests/artifact_list_page.test.tsx index 0a8eb19513a81..7f9a22d5ec0e4 100644 --- a/x-pack/plugins/security_solution/public/management/components/artifact_list_page/integration_tests/artifact_list_page.test.tsx +++ b/x-pack/plugins/security_solution/public/management/components/artifact_list_page/integration_tests/artifact_list_page.test.tsx @@ -13,6 +13,12 @@ import userEvent from '@testing-library/user-event'; import type { ArtifactListPageRenderingSetup } from '../mocks'; import { getArtifactListPageRenderingSetup } from '../mocks'; import { getDeferred } from '../../../mocks/utils'; +import { useGetEndpointSpecificPolicies } from '../../../services/policies/hooks'; + +jest.mock('../../../services/policies/hooks', () => ({ + useGetEndpointSpecificPolicies: jest.fn(), +})); +const mockUseGetEndpointSpecificPolicies = useGetEndpointSpecificPolicies as jest.Mock; jest.mock('../../../../common/components/user_privileges'); @@ -30,6 +36,10 @@ describe('When using the ArtifactListPage component', () => { ({ history, mockedApi, getFirstCard } = renderSetup); + mockUseGetEndpointSpecificPolicies.mockReturnValue({ + data: mockedApi.responseProvider.endpointPackagePolicyList(), + }); + render = (props = {}) => (renderResult = renderSetup.renderArtifactListPage(props)); }); @@ -134,6 +144,14 @@ describe('When using the ArtifactListPage component', () => { }); }); + it('should call useGetEndpointSpecificPolicies hook with specific perPage value', () => { + expect(mockUseGetEndpointSpecificPolicies).toHaveBeenCalledWith( + expect.objectContaining({ + perPage: 1000, + }) + ); + }); + describe('and interacting with card actions', () => { const clickCardAction = async (action: 'edit' | 'delete') => { await getFirstCard({ showActions: true });