Skip to content

Commit

Permalink
Fix default page size for Document List
Browse files Browse the repository at this point in the history
  • Loading branch information
asanchezr committed Oct 10, 2023
1 parent 24bf199 commit 1f7af50
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { noop } from 'lodash';

import { Claims } from '@/constants/claims';
import { DocumentRow } from '@/features/documents/ComposedDocument';
import { mockDocumentsResponse } from '@/mocks/documents.mock';
import { mockDocumentResponse, mockDocumentsResponse } from '@/mocks/documents.mock';
import { cleanup, mockKeycloak, render, RenderOptions } from '@/utils/test-utils';

import { DocumentResults, IDocumentResultProps } from './DocumentResults';
Expand Down Expand Up @@ -121,13 +121,12 @@ describe('Document Results Table', () => {
expect(deleteButtons[0]).toBeVisible();
});

it('displays document delete button', async () => {
mockKeycloak({ claims: [Claims.DOCUMENT_VIEW, Claims.DOCUMENT_DELETE] });
const { getAllByTestId } = setup({
results: mockDocumentsResponse().map(x => DocumentRow.fromApi(x)),
});

const deleteButtons = await getAllByTestId('document-delete-button');
expect(deleteButtons[0]).toBeVisible();
it('displays default number of entries of 10', async () => {
mockKeycloak({ claims: [Claims.DOCUMENT_VIEW] });
const largeDataset = Array.from({ length: 15 }, (id: number) =>
DocumentRow.fromApi(mockDocumentResponse(id)),
);
const { findByText } = setup({ results: largeDataset });
expect(await findByText('1 - 10 of 15')).toBeVisible();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const DocumentResults: React.FunctionComponent<
externalSort={{ sort, setSort }}
data={results ?? []}
noRowsMessage="No matching Documents found"
pageSize={1}
pageSize={10}
manualPagination={false}
{...rest}
></Table>
Expand Down
45 changes: 45 additions & 0 deletions source/frontend/src/mocks/documents.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,51 @@ import {
Api_Storage_DocumentTypeMetadataType,
} from '@/models/api/DocumentStorage';

export const mockDocumentResponse = (id = 1): Api_DocumentRelationship => ({
id,
parentId: 1,
isDisabled: false,
document: {
id: 21,
mayanDocumentId: 33,
documentType: {
id: 8,
documentType: 'MoTI Plan',
documentTypeDescription: 'MOTIPLAN',
mayanId: 24,
appCreateTimestamp: '2022-09-08T21:18:09.01',
appLastUpdateTimestamp: '2022-09-08T21:18:09.01',
appLastUpdateUserid: 'admin',
appCreateUserid: 'admin',
appLastUpdateUserGuid: '14c9a273-6f4a-4859-8d59-9264d3cee53f',
appCreateUserGuid: '14c9a273-6f4a-4859-8d59-9264d3cee53f',
rowVersion: 1,
isDisabled: false,
},
statusTypeCode: {
id: 'AMENDD',
description: 'Amended',
isDisabled: false,
},
fileName: 'moti_plan.txt',
appCreateTimestamp: '2022-09-08T21:18:54.057',
appLastUpdateTimestamp: '2022-09-08T21:18:54.057',
appLastUpdateUserid: 'admin',
appCreateUserid: 'admin',
appLastUpdateUserGuid: '14c9a273-6f4a-4859-8d59-9264d3cee53f',
appCreateUserGuid: '14c9a273-6f4a-4859-8d59-9264d3cee53f',
rowVersion: 1,
},
relationshipType: DocumentRelationshipType.ACQUISITION_FILES,
appCreateTimestamp: '2022-09-08T21:18:54.057',
appLastUpdateTimestamp: '2022-09-08T21:18:54.057',
appLastUpdateUserid: 'admin',
appCreateUserid: 'admin',
appLastUpdateUserGuid: '14c9a273-6f4a-4859-8d59-9264d3cee53f',
appCreateUserGuid: '14c9a273-6f4a-4859-8d59-9264d3cee53f',
rowVersion: 1,
});

export const mockDocumentsResponse = (): Api_DocumentRelationship[] => [
{
id: 1,
Expand Down

0 comments on commit 1f7af50

Please sign in to comment.