From 24bf199b288a1ab196f0dad1c1935bb8ee11061b Mon Sep 17 00:00:00 2001 From: Alejandro Sanchez Date: Tue, 10 Oct 2023 13:40:43 -0700 Subject: [PATCH 1/3] Code cleanup --- source/frontend/src/components/Table/Table.tsx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/source/frontend/src/components/Table/Table.tsx b/source/frontend/src/components/Table/Table.tsx index 7381244822..e529694123 100644 --- a/source/frontend/src/components/Table/Table.tsx +++ b/source/frontend/src/components/Table/Table.tsx @@ -1,8 +1,6 @@ import './Table.scss'; -import classnames from 'classnames'; -import classNames from 'classnames'; -import clsx from 'classnames'; +import cx from 'classnames'; import { Form, Formik, FormikProps } from 'formik'; import keys from 'lodash/keys'; import map from 'lodash/map'; @@ -518,7 +516,7 @@ export const Table = ( {...(props.hideHeaders ? columnProps.getHeaderProps(noHeadersGetter) : columnProps.getHeaderProps(headerPropsGetter))} - className={classnames( + className={cx( 'th', columnProps.isSorted ? (columnProps.isSortedDesc ? 'sort-desc' : 'sort-asc') : '', )} @@ -635,7 +633,7 @@ export const Table = ( const renderRow = (row: Row, index: number) => { return (
-
+
{/* If canRowExpand prop is passed only allow expansions on those rows */} {props.canRowExpand && props.canRowExpand(row) && @@ -666,7 +664,7 @@ export const Table = (
( <>
@@ -769,7 +767,7 @@ export const Table = ( {canShowTotals && props.data.length > 0 && ( - {`${initialCount} - ${finalCount} of ${totalItems}`} + {`${initialCount} - ${finalCount} of ${totalItems}`} )} From 1f7af50ee1ef99b7b64e45df2a59af21913cd94c Mon Sep 17 00:00:00 2001 From: Alejandro Sanchez Date: Tue, 10 Oct 2023 13:42:37 -0700 Subject: [PATCH 2/3] Fix default page size for Document List --- .../DocumentResults/DocumentResults.test.tsx | 17 ++++--- .../list/DocumentResults/DocumentResults.tsx | 2 +- source/frontend/src/mocks/documents.mock.ts | 45 +++++++++++++++++++ 3 files changed, 54 insertions(+), 10 deletions(-) diff --git a/source/frontend/src/features/documents/list/DocumentResults/DocumentResults.test.tsx b/source/frontend/src/features/documents/list/DocumentResults/DocumentResults.test.tsx index 060dd2b59d..028b6120c1 100644 --- a/source/frontend/src/features/documents/list/DocumentResults/DocumentResults.test.tsx +++ b/source/frontend/src/features/documents/list/DocumentResults/DocumentResults.test.tsx @@ -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'; @@ -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(); }); }); diff --git a/source/frontend/src/features/documents/list/DocumentResults/DocumentResults.tsx b/source/frontend/src/features/documents/list/DocumentResults/DocumentResults.tsx index 50098afc34..f49e116450 100644 --- a/source/frontend/src/features/documents/list/DocumentResults/DocumentResults.tsx +++ b/source/frontend/src/features/documents/list/DocumentResults/DocumentResults.tsx @@ -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} > diff --git a/source/frontend/src/mocks/documents.mock.ts b/source/frontend/src/mocks/documents.mock.ts index ec7f7b7f06..1fa7f982da 100644 --- a/source/frontend/src/mocks/documents.mock.ts +++ b/source/frontend/src/mocks/documents.mock.ts @@ -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, From e6710f88dd66ae0950f6783a727991fad7fc01ae Mon Sep 17 00:00:00 2001 From: Alejandro Sanchez Date: Tue, 10 Oct 2023 13:51:53 -0700 Subject: [PATCH 3/3] Update snapshots --- .../Table/__snapshots__/Table.test.tsx.snap | 2 +- .../ContactResultComponent.test.tsx.snap | 2 +- .../ManageAccessRequestsPage.test.tsx.snap | 2 +- .../DocumentResults.test.tsx.snap | 116 +++++++++++++++--- .../DocumentListView.test.tsx.snap | 116 +++++++++++++++--- .../LeaseSearchResults.test.tsx.snap | 2 +- .../__snapshots__/NoteResults.test.tsx.snap | 2 +- 7 files changed, 199 insertions(+), 43 deletions(-) diff --git a/source/frontend/src/components/Table/__snapshots__/Table.test.tsx.snap b/source/frontend/src/components/Table/__snapshots__/Table.test.tsx.snap index d2d16b72d2..21e7cdf5da 100644 --- a/source/frontend/src/components/Table/__snapshots__/Table.test.tsx.snap +++ b/source/frontend/src/components/Table/__snapshots__/Table.test.tsx.snap @@ -218,7 +218,7 @@ exports[`Generic table component matches snapshot 1`] = ` class="align-self-center col-auto" > - 1 - 6 of 6 + 1 - 6 of 6
- 1 - 3 of 3 + 1 - 3 of 3
- 1 - 2 of 2 + 1 - 2 of 2
+
+
+
+ MOTIPLAN +
+
+ + moti_plan.txt + +
+
+
+
+ Sep 8, 2022 +
+
+ + + + + + + +
+
+
+
+ Amended +
+
+
+
+
+
.c0 { @@ -360,7 +451,7 @@ exports[`Document Results Table matches snapshot 1`] = ` class="align-self-center col-auto" > - 1 - 1 of 2 + 1 - 2 of 2
  • - -
  • -
  • diff --git a/source/frontend/src/features/documents/list/__snapshots__/DocumentListView.test.tsx.snap b/source/frontend/src/features/documents/list/__snapshots__/DocumentListView.test.tsx.snap index ad5402b7c8..4ded50e830 100644 --- a/source/frontend/src/features/documents/list/__snapshots__/DocumentListView.test.tsx.snap +++ b/source/frontend/src/features/documents/list/__snapshots__/DocumentListView.test.tsx.snap @@ -779,6 +779,97 @@ exports[`Document List View renders as expected 1`] = `
  • +
    +
    +
    + MOTIPLAN +
    +
    + + moti_plan.txt + +
    +
    +
    +
    + Sep 8, 2022 +
    +
    + + + + + + + +
    +
    +
    +
    + Amended +
    +
    +
    +
    +
    +
    - 1 - 1 of 2 + 1 - 2 of 2
  • - -
  • -
  • diff --git a/source/frontend/src/features/leases/list/LeaseSearchResults/__snapshots__/LeaseSearchResults.test.tsx.snap b/source/frontend/src/features/leases/list/LeaseSearchResults/__snapshots__/LeaseSearchResults.test.tsx.snap index aa7ae68932..dcc0d88789 100644 --- a/source/frontend/src/features/leases/list/LeaseSearchResults/__snapshots__/LeaseSearchResults.test.tsx.snap +++ b/source/frontend/src/features/leases/list/LeaseSearchResults/__snapshots__/LeaseSearchResults.test.tsx.snap @@ -485,7 +485,7 @@ exports[`Lease Search Results Table matches snapshot 1`] = ` class="align-self-center col-auto" > - 1 - 2 of 2 + 1 - 2 of 2
  • - 1 - 4 of 4 + 1 - 4 of 4