Skip to content

Commit

Permalink
[Security Solution][Endpoint] Set perPage to 1000 for package policie…
Browse files Browse the repository at this point in the history
…s 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)
  • Loading branch information
dasansol92 authored Dec 5, 2023
1 parent cb74a08 commit 4abbe84
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export const ArtifactListPage = memo<ArtifactListPageProps>(
});

const policiesRequest = useGetEndpointSpecificPolicies({
perPage: 1000,
onError: (err) => {
toasts.addWarning(getLoadPoliciesError(err));
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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));
});

Expand Down Expand Up @@ -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 });
Expand Down

0 comments on commit 4abbe84

Please sign in to comment.