Skip to content

Commit 97b3e58

Browse files
[PRMP-859] Refactor upload to use doc config (other doc types) (#922)
1 parent 2200d34 commit 97b3e58

File tree

56 files changed

+3129
-1594
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+3129
-1594
lines changed

.github/workflows/base-deploy-ui.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,12 @@ jobs:
108108
IMAGE_TAG: latest
109109
IMAGE_TAG_SHA: ${{ github.sha }}
110110
CONTAINER_PORT: ${{ env.CONTAINER_PORT }}
111+
BUILD_ENV: ${{ inputs.environment }}
111112
run: |
112113
docker build \
113114
--build-arg="CONTAINER_PORT=$CONTAINER_PORT" \
114115
--build-arg="CLOUDFRONT_DOMAIN_NAME=$CLOUDFRONT_DOMAIN_NAME" \
116+
--build-arg="BUILD_ENV=$BUILD_ENV" \
115117
-t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \
116118
-t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG_SHA .
117119
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG

app/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ RUN mkdir -p ./public/pdfjs
1313
RUN wget https://github.com/mozilla/pdf.js/releases/download/v5.4.296/pdfjs-5.4.296-dist.zip -O ./public/pdfjs/pdfjs.zip
1414
RUN unzip -o -d ./public/pdfjs ./public/pdfjs/pdfjs.zip
1515
RUN rm ./public/pdfjs/pdfjs.zip
16-
RUN npm run build
16+
17+
ARG BUILD_ENV=development
18+
ARG BUILD_ENV=$BUILD_ENV
19+
RUN npm run build -- --mode $BUILD_ENV
1720

1821
# Host the App
1922
FROM nginx:latest

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: 60 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ 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();
1616
const mockSetMergedPdfBlob = vi.fn();
17+
const mockConfirmFiles = vi.fn();
1718

1819
vi.mock('../../../../helpers/hooks/usePatient');
1920
vi.mock('../../../../helpers/hooks/useTitle');
@@ -44,17 +45,21 @@ vi.mock('../documentUploadLloydGeorgePreview/DocumentUploadLloydGeorgePreview',
4445
}
4546
return (
4647
<div data-testid="lloyd-george-preview">
47-
Lloyd George Preview for {documents.length} documents
48+
<h2>{docConfig.content.previewUploadTitle}</h2>
49+
<p>Previewing: {documents[0]?.file.name}</p>
4850
</div>
4951
);
5052
},
5153
}));
5254

55+
let docConfig: DOCUMENT_TYPE_CONFIG;
56+
5357
describe('DocumentSelectOrderStage', () => {
5458
let documents: UploadDocument[] = [];
5559

5660
beforeEach(() => {
5761
import.meta.env.VITE_ENVIRONMENT = 'vitest';
62+
docConfig = buildDocumentConfig();
5863
documents = [
5964
{
6065
docType: DOCUMENT_TYPE.LLOYD_GEORGE,
@@ -128,7 +133,9 @@ describe('DocumentSelectOrderStage', () => {
128133
renderSut(documents);
129134

130135
await waitFor(() => {
131-
expect(screen.getByText('Preview this Lloyd George record')).toBeInTheDocument();
136+
expect(
137+
screen.getByText(docConfig.content.previewUploadTitle as string),
138+
).toBeInTheDocument();
132139
expect(screen.getByTestId('lloyd-george-preview')).toBeInTheDocument();
133140
});
134141
});
@@ -476,7 +483,46 @@ describe('DocumentSelectOrderStage', () => {
476483

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

504550
await waitFor(() => {
505-
expect(mockNavigate).toHaveBeenCalledWith({
506-
pathname: '/patient/document-upload/in-progress',
507-
search: 'journey=update',
508-
});
551+
expect(mockConfirmFiles).toHaveBeenCalled();
509552
});
510553
});
511554

@@ -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,8 @@ function renderSutWithExistingDocs(
817860
setDocuments={mockSetDocuments}
818861
setMergedPdfBlob={mockSetMergedPdfBlob}
819862
existingDocuments={existingDocuments}
863+
documentConfig={docConfig}
864+
confirmFiles={mockConfirmFiles}
820865
/>
821866
</MemoryRouter>,
822867
);
@@ -830,6 +875,8 @@ function renderSut(documents: UploadDocument[]): void {
830875
setDocuments={mockSetDocuments}
831876
setMergedPdfBlob={mockSetMergedPdfBlob}
832877
existingDocuments={[]}
878+
documentConfig={docConfig}
879+
confirmFiles={mockConfirmFiles}
833880
/>
834881
</MemoryRouter>,
835882
);

0 commit comments

Comments
 (0)