Skip to content

Commit 391daf0

Browse files
[PRMP-859] Refactor upload to use doc config (other doc types)
1 parent 6054ed5 commit 391daf0

38 files changed

+1142
-353
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: 54 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,7 @@ describe('DocumentSelectOrderStage', () => {
128132
renderSut(documents);
129133

130134
await waitFor(() => {
131-
expect(screen.getByText('Preview this Lloyd George record')).toBeInTheDocument();
135+
expect(screen.getByText(docConfig.content.previewUploadTitle as string)).toBeInTheDocument();
132136
expect(screen.getByTestId('lloyd-george-preview')).toBeInTheDocument();
133137
});
134138
});
@@ -476,7 +480,46 @@ describe('DocumentSelectOrderStage', () => {
476480

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

545588
expect(
546589
screen.getByText(
547-
"When you upload your files, they will be added to the end of the patient's existing Lloyd George record.",
590+
`When you upload your files, they will be added to the end of the patient's existing ${docConfig.displayName}.`,
548591
),
549592
).toBeInTheDocument();
550593
expect(
@@ -562,7 +605,7 @@ describe('DocumentSelectOrderStage', () => {
562605

563606
expect(
564607
screen.getByText(
565-
"When you upload your files, they will be added to the end of the patient's existing Lloyd George record.",
608+
`When you upload your files, they will be added to the end of the patient's existing ${docConfig.displayName}.`,
566609
),
567610
).toBeInTheDocument();
568611

@@ -593,7 +636,7 @@ describe('DocumentSelectOrderStage', () => {
593636

594637
renderSutWithExistingDocs(documents, existingDocs);
595638

596-
expect(screen.getByText('Existing Lloyd George record')).toBeInTheDocument();
639+
expect(screen.getByText(`Existing ${docConfig.displayName}`)).toBeInTheDocument();
597640
});
598641

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

614657
const rows = screen.getAllByRole('row');
615658
const existingRow = rows.find((row) =>
616-
row.textContent?.includes('Existing Lloyd George record'),
659+
row.textContent?.includes(`Existing ${docConfig.displayName}`),
617660
);
618661

619662
expect(existingRow).toBeInTheDocument();
@@ -817,6 +860,7 @@ function renderSutWithExistingDocs(
817860
setDocuments={mockSetDocuments}
818861
setMergedPdfBlob={mockSetMergedPdfBlob}
819862
existingDocuments={existingDocuments}
863+
documentConfig={docConfig}
820864
/>
821865
</MemoryRouter>,
822866
);
@@ -830,6 +874,7 @@ function renderSut(documents: UploadDocument[]): void {
830874
setDocuments={mockSetDocuments}
831875
setMergedPdfBlob={mockSetMergedPdfBlob}
832876
existingDocuments={[]}
877+
documentConfig={docConfig}
833878
/>
834879
</MemoryRouter>,
835880
);

0 commit comments

Comments
 (0)