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

[Security Solution][Endpoint] Set perPage to 1000 for package policies query in Endpoint Artifacts form #172563

Merged
Show file tree
Hide file tree
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 @@ -163,6 +163,7 @@ export const ArtifactListPage = memo<ArtifactListPageProps>(
});

const policiesRequest = useGetEndpointSpecificPolicies({
perPage: 1000,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just one suggestion: add a test (unit) to this page component thta validates that we call the API with a perPage value of 1000

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: f21d08b

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
Loading