Skip to content

Commit 2d96d65

Browse files
[PRMP-859] Refactor upload to use doc config (other doc types)
1 parent 31aa2e0 commit 2d96d65

38 files changed

+1237
-363
lines changed

app/cypress/e2e/0-ndr-core-tests/auth_routes/auth_gp_clinical_path_access.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ describe('GP Clinical user role has access to the expected GP_CLINICAL workflow
4848
cy.url().should('eq', baseUrl + lloydGeorgeViewUrl);
4949
});
5050
});
51-
});
51+
});

app/package-lock.json

Lines changed: 37 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"@testing-library/react": "16.3.0",
2929
"@testing-library/user-event": "14.6.1",
3030
"@vitejs/plugin-react-swc": "^4.2.2",
31+
"@zip.js/zip.js": "^2.8.11",
3132
"aws-rum-web": "^1.25.0",
3233
"axios": "^1.13.2",
3334
"dotenv": "^17.2.3",
@@ -79,8 +80,8 @@
7980
"@types/uuid": "^11.0.0",
8081
"@types/validator": "^13.15.10",
8182
"@vitest/coverage-v8": "^4.0.13",
82-
"@vitest/ui": "^4.0.13",
8383
"@vitest/spy": "^4.0.13",
84+
"@vitest/ui": "^4.0.13",
8485
"babel-plugin-named-exports-order": "^0.0.2",
8586
"cypress": "^15.7.0",
8687
"cypress-real-events": "^1.15.0",

app/src/components/blocks/_documentUpload/documentSelectOrderStage/DocumentSelectOrderStage.test.tsx

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import {
77
} from '../../../../types/pages/UploadDocumentsPage/types';
88
import { MemoryRouter } from 'react-router-dom';
99
import { fileUploadErrorMessages } from '../../../../helpers/utils/fileUploadErrorMessages';
10-
import { buildLgFile } from '../../../../helpers/test/testBuilders';
10+
import { buildDocumentConfig, buildLgFile } from '../../../../helpers/test/testBuilders';
1111
import { Mock } from 'vitest';
12-
import { DOCUMENT_TYPE } from '../../../../helpers/utils/documentType';
12+
import { DOCUMENT_TYPE, DOCUMENT_TYPE_CONFIG } from '../../../../helpers/utils/documentType';
1313

1414
const mockNavigate = vi.fn();
1515
const mockSetDocuments = vi.fn();
@@ -44,17 +44,21 @@ vi.mock('../documentUploadLloydGeorgePreview/DocumentUploadLloydGeorgePreview',
4444
}
4545
return (
4646
<div data-testid="lloyd-george-preview">
47-
Lloyd George Preview for {documents.length} documents
47+
<h2>{docConfig.content.previewUploadTitle}</h2>
48+
<p>Previewing: {documents[0]?.file.name}</p>
4849
</div>
4950
);
5051
},
5152
}));
5253

54+
let docConfig: DOCUMENT_TYPE_CONFIG;
55+
5356
describe('DocumentSelectOrderStage', () => {
5457
let documents: UploadDocument[] = [];
5558

5659
beforeEach(() => {
5760
import.meta.env.VITE_ENVIRONMENT = 'vitest';
61+
docConfig = buildDocumentConfig();
5862
documents = [
5963
{
6064
docType: DOCUMENT_TYPE.LLOYD_GEORGE,
@@ -128,7 +132,9 @@ describe('DocumentSelectOrderStage', () => {
128132
renderSut(documents);
129133

130134
await waitFor(() => {
131-
expect(screen.getByText('Preview this Lloyd George record')).toBeInTheDocument();
135+
expect(
136+
screen.getByText(docConfig.content.previewUploadTitle as string),
137+
).toBeInTheDocument();
132138
expect(screen.getByTestId('lloyd-george-preview')).toBeInTheDocument();
133139
});
134140
});
@@ -476,7 +482,46 @@ describe('DocumentSelectOrderStage', () => {
476482

477483
await waitFor(() => {
478484
expect(
479-
screen.getByText('Lloyd George Preview for 2 documents'),
485+
screen.getByText(docConfig.content.previewUploadTitle as string),
486+
).toBeInTheDocument();
487+
});
488+
});
489+
490+
it('loads currently selected document into PDF viewer', async () => {
491+
docConfig = buildDocumentConfig({
492+
stitched: false,
493+
snomedCode: DOCUMENT_TYPE.EHR_ATTACHMENTS,
494+
});
495+
496+
const multipleDocuments = [
497+
{
498+
docType: DOCUMENT_TYPE.EHR_ATTACHMENTS,
499+
id: '1',
500+
file: buildLgFile(1),
501+
attempts: 0,
502+
state: DOCUMENT_UPLOAD_STATE.SELECTED,
503+
numPages: 5,
504+
position: 1,
505+
},
506+
{
507+
docType: DOCUMENT_TYPE.EHR_ATTACHMENTS,
508+
id: '2',
509+
file: buildLgFile(2),
510+
attempts: 0,
511+
state: DOCUMENT_UPLOAD_STATE.SELECTED,
512+
numPages: 3,
513+
position: 2,
514+
},
515+
];
516+
517+
renderSut(multipleDocuments);
518+
519+
await waitFor(() => {
520+
expect(
521+
screen.getByText(docConfig.content.previewUploadTitle as string),
522+
).toBeInTheDocument();
523+
expect(
524+
screen.getByText(`Previewing: ${multipleDocuments[0].file.name}`),
480525
).toBeInTheDocument();
481526
});
482527
});
@@ -544,7 +589,7 @@ describe('DocumentSelectOrderStage', () => {
544589

545590
expect(
546591
screen.getByText(
547-
"When you upload your files, they will be added to the end of the patient's existing Lloyd George record.",
592+
`When you upload your files, they will be added to the end of the patient's existing ${docConfig.displayName}.`,
548593
),
549594
).toBeInTheDocument();
550595
expect(
@@ -562,7 +607,7 @@ describe('DocumentSelectOrderStage', () => {
562607

563608
expect(
564609
screen.getByText(
565-
"When you upload your files, they will be added to the end of the patient's existing Lloyd George record.",
610+
`When you upload your files, they will be added to the end of the patient's existing ${docConfig.displayName}.`,
566611
),
567612
).toBeInTheDocument();
568613

@@ -593,7 +638,7 @@ describe('DocumentSelectOrderStage', () => {
593638

594639
renderSutWithExistingDocs(documents, existingDocs);
595640

596-
expect(screen.getByText('Existing Lloyd George record')).toBeInTheDocument();
641+
expect(screen.getByText(`Existing ${docConfig.displayName}`)).toBeInTheDocument();
597642
});
598643

599644
it('existing Lloyd George record has position 1 and cannot be repositioned or removed', () => {
@@ -613,7 +658,7 @@ describe('DocumentSelectOrderStage', () => {
613658

614659
const rows = screen.getAllByRole('row');
615660
const existingRow = rows.find((row) =>
616-
row.textContent?.includes('Existing Lloyd George record'),
661+
row.textContent?.includes(`Existing ${docConfig.displayName}`),
617662
);
618663

619664
expect(existingRow).toBeInTheDocument();
@@ -817,6 +862,7 @@ function renderSutWithExistingDocs(
817862
setDocuments={mockSetDocuments}
818863
setMergedPdfBlob={mockSetMergedPdfBlob}
819864
existingDocuments={existingDocuments}
865+
documentConfig={docConfig}
820866
/>
821867
</MemoryRouter>,
822868
);
@@ -830,6 +876,7 @@ function renderSut(documents: UploadDocument[]): void {
830876
setDocuments={mockSetDocuments}
831877
setMergedPdfBlob={mockSetMergedPdfBlob}
832878
existingDocuments={[]}
879+
documentConfig={docConfig}
833880
/>
834881
</MemoryRouter>,
835882
);

0 commit comments

Comments
 (0)