diff --git a/app/src/components/blocks/_admin/reviewDetailsAddMoreChoiceStage/ReviewDetailsAddMoreChoiceStage.test.tsx b/app/src/components/blocks/_admin/reviewDetailsAddMoreChoiceStage/ReviewDetailsAddMoreChoiceStage.test.tsx index fdb159e70..a5e6d4ded 100644 --- a/app/src/components/blocks/_admin/reviewDetailsAddMoreChoiceStage/ReviewDetailsAddMoreChoiceStage.test.tsx +++ b/app/src/components/blocks/_admin/reviewDetailsAddMoreChoiceStage/ReviewDetailsAddMoreChoiceStage.test.tsx @@ -1,11 +1,18 @@ import { render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import { afterEach, beforeEach, describe, expect, it, vi, Mock } from 'vitest'; -import ReviewDetailsAddMoreChoiceStage from './ReviewDetailsAddMoreChoiceStage'; +import { afterEach, beforeEach, describe, expect, it, Mock, vi } from 'vitest'; import { runAxeTest } from '../../../../helpers/test/axeTestHelper'; +import * as documentTypeModule from '../../../../helpers/utils/documentType'; +import { ReviewDetails } from '../../../../types/generic/reviews'; +import ReviewDetailsAddMoreChoiceStage from './ReviewDetailsAddMoreChoiceStage'; +import { DOCUMENT_TYPE } from '../../../../helpers/utils/documentType'; const mockNavigate = vi.fn(); const mockReviewId = 'test-review-123'; +const testData = { + yesText: 'Yes, I have more scanned paper notes to add for this patient', + noText: "No, I don't have anymore scanned paper notes to add for this patient", +}; vi.mock('react-router-dom', async (): Promise => { const actual = await vi.importActual('react-router-dom'); @@ -16,10 +23,23 @@ vi.mock('react-router-dom', async (): Promise => { }; }); -describe('ReviewDetailsAddMoreChoicePage', () => { +describe('ReviewDetailsAddMoreChoiceStage', () => { + const mockReviewData = { + snomedCode: DOCUMENT_TYPE.LLOYD_GEORGE, + } as ReviewDetails; + beforeEach(() => { vi.clearAllMocks(); import.meta.env.VITE_ENVIRONMENT = 'vitest'; + const mockGetConfig = vi.spyOn(documentTypeModule, 'getConfigForDocType'); + mockGetConfig.mockReturnValue({ + ...documentTypeModule.getConfigForDocType(DOCUMENT_TYPE.LLOYD_GEORGE), + multifileZipped: true, + content: { + addMoreFilesRadioNoText: testData.noText, + addMoreFilesRadioYesText: testData.yesText, + }, + } as any); }); afterEach(() => { @@ -28,29 +48,29 @@ describe('ReviewDetailsAddMoreChoicePage', () => { describe('Rendering', () => { it('renders the page heading correctly', () => { - render(); + render(); expect( screen.getByRole('heading', { - name: 'Do you want to add more files to this patients record?', + name: "Do you want to add more files to this patient's record?", }), ).toBeInTheDocument(); }); it('renders back button with correct text', () => { - render(); + render(); expect(screen.getByText('Go back')).toBeInTheDocument(); }); it('renders both radio button options', () => { - render(); + render(); const yesRadio = screen.getByRole('radio', { - name: /Yes I have more scanned paper records to add for this patient/i, + name: testData.yesText, }); const noRadio = screen.getByRole('radio', { - name: /No, I don't have anymore scanned paper records to add for this patient/i, + name: testData.noText, }); expect(yesRadio).toBeInTheDocument(); @@ -60,13 +80,13 @@ describe('ReviewDetailsAddMoreChoicePage', () => { }); it('renders continue button', () => { - render(); + render(); expect(screen.getByRole('button', { name: 'Continue' })).toBeInTheDocument(); }); it('does not show error message initially', () => { - render(); + render(); expect(screen.queryByText('Select an option')).not.toBeInTheDocument(); }); @@ -74,7 +94,7 @@ describe('ReviewDetailsAddMoreChoicePage', () => { describe('Error Handling', () => { it('displays error message when continue is clicked without selection', async () => { - render(); + render(); const continueButton = screen.getByRole('button', { name: 'Continue' }); await userEvent.click(continueButton); @@ -85,7 +105,7 @@ describe('ReviewDetailsAddMoreChoicePage', () => { }); it('does not navigate when no selection is made', async () => { - render(); + render(); const continueButton = screen.getByRole('button', { name: 'Continue' }); await userEvent.click(continueButton); @@ -97,7 +117,7 @@ describe('ReviewDetailsAddMoreChoicePage', () => { }); it('clears error message when yes radio button is selected', async () => { - render(); + render(); const continueButton = screen.getByRole('button', { name: 'Continue' }); await userEvent.click(continueButton); @@ -107,7 +127,7 @@ describe('ReviewDetailsAddMoreChoicePage', () => { }); const yesRadio = screen.getByRole('radio', { - name: /Yes I have more scanned paper records to add for this patient/i, + name: testData.yesText, }); await userEvent.click(yesRadio); @@ -117,7 +137,7 @@ describe('ReviewDetailsAddMoreChoicePage', () => { }); it('clears error message when no radio button is selected', async () => { - render(); + render(); const continueButton = screen.getByRole('button', { name: 'Continue' }); await userEvent.click(continueButton); @@ -127,7 +147,7 @@ describe('ReviewDetailsAddMoreChoicePage', () => { }); const noRadio = screen.getByRole('radio', { - name: /No, I don't have anymore scanned paper records to add for this patient/i, + name: testData.noText, }); await userEvent.click(noRadio); @@ -139,10 +159,10 @@ describe('ReviewDetailsAddMoreChoicePage', () => { describe('User Interactions', () => { it('allows selecting the yes radio button', async () => { - render(); + render(); const yesRadio = screen.getByRole('radio', { - name: /Yes I have more scanned paper records to add for this patient/i, + name: testData.yesText, }); await userEvent.click(yesRadio); @@ -152,10 +172,10 @@ describe('ReviewDetailsAddMoreChoicePage', () => { }); it('allows selecting the no radio button', async () => { - render(); + render(); const noRadio = screen.getByRole('radio', { - name: /No, I don't have anymore scanned paper records to add for this patient/i, + name: testData.noText, }); await userEvent.click(noRadio); @@ -165,13 +185,13 @@ describe('ReviewDetailsAddMoreChoicePage', () => { }); it('allows changing selection from yes to no', async () => { - render(); + render(); const yesRadio = screen.getByRole('radio', { - name: /Yes I have more scanned paper records to add for this patient/i, + name: testData.yesText, }); const noRadio = screen.getByRole('radio', { - name: /No, I don't have anymore scanned paper records to add for this patient/i, + name: testData.noText, }); await userEvent.click(yesRadio); @@ -187,7 +207,7 @@ describe('ReviewDetailsAddMoreChoicePage', () => { }); it('prevents default form submission', async () => { - render(); + render(); const form = screen.getByRole('button', { name: 'Continue' }).closest('form'); const submitHandler = vi.fn((e: Event) => e.preventDefault()); @@ -202,10 +222,10 @@ describe('ReviewDetailsAddMoreChoicePage', () => { describe('Navigation', () => { it('navigates to add more files when yes is selected', async () => { - render(); + render(); const yesRadio = screen.getByRole('radio', { - name: /Yes I have more scanned paper records to add for this patient/i, + name: testData.yesText, }); await userEvent.click(yesRadio); @@ -229,7 +249,7 @@ describe('ReviewDetailsAddMoreChoicePage', () => { render(); const noRadio = screen.getByRole('radio', { - name: /No, I don't have anymore scanned paper records to add for this patient/i, + name: testData.noText, }); await userEvent.click(noRadio); @@ -253,7 +273,7 @@ describe('ReviewDetailsAddMoreChoicePage', () => { render(); const noRadio = screen.getByRole('radio', { - name: /No, I don't have anymore scanned paper records to add for this patient/i, + name: testData.noText, }); await userEvent.click(noRadio); @@ -277,7 +297,7 @@ describe('ReviewDetailsAddMoreChoicePage', () => { render(); const noRadio = screen.getByRole('radio', { - name: /No, I don't have anymore scanned paper records to add for this patient/i, + name: testData.noText, }); await userEvent.click(noRadio); @@ -295,14 +315,18 @@ describe('ReviewDetailsAddMoreChoicePage', () => { describe('Accessibility', () => { it('passes axe accessibility tests in initial state', async () => { - const { container } = render(); + const { container } = render( + , + ); const results = await runAxeTest(container); expect(results).toHaveNoViolations(); }); it('passes axe accessibility tests in error state', async () => { - const { container } = render(); + const { container } = render( + , + ); const continueButton = screen.getByRole('button', { name: 'Continue' }); await userEvent.click(continueButton); @@ -316,10 +340,12 @@ describe('ReviewDetailsAddMoreChoicePage', () => { }); it('passes axe accessibility tests with radio button selected', async () => { - const { container } = render(); + const { container } = render( + , + ); const yesRadio = screen.getByRole('radio', { - name: /Yes I have more scanned paper records to add for this patient/i, + name: testData.yesText, }); await userEvent.click(yesRadio); diff --git a/app/src/components/blocks/_admin/reviewDetailsAddMoreChoiceStage/ReviewDetailsAddMoreChoiceStage.tsx b/app/src/components/blocks/_admin/reviewDetailsAddMoreChoiceStage/ReviewDetailsAddMoreChoiceStage.tsx index ebc1bd609..28925082b 100644 --- a/app/src/components/blocks/_admin/reviewDetailsAddMoreChoiceStage/ReviewDetailsAddMoreChoiceStage.tsx +++ b/app/src/components/blocks/_admin/reviewDetailsAddMoreChoiceStage/ReviewDetailsAddMoreChoiceStage.tsx @@ -4,6 +4,7 @@ import { useNavigate, useParams } from 'react-router-dom'; import { navigateUrlParam, routeChildren } from '../../../../types/generic/routes'; import BackButton from '../../../generic/backButton/BackButton'; import { ReviewDetails } from '../../../../types/generic/reviews'; +import { getConfigForDocType } from '../../../../helpers/utils/documentType'; type ReviewDetailsAddMoreChoicePageProps = { reviewData: ReviewDetails | null; @@ -19,6 +20,13 @@ const ReviewDetailsAddMoreChoiceStage: React.FC(); + if (!reviewData) { + navigate(routeChildren.ADMIN_REVIEW); + return <>; + } + + const reviewConfig = getConfigForDocType(reviewData?.snomedCode || ''); + const handleContinue = (): void => { if (!addMoreChoice || !reviewId) { setShowError(true); @@ -33,7 +41,7 @@ const ReviewDetailsAddMoreChoiceStage: React.FC 1 + reviewData.files!.length > 1 ? routeChildren.ADMIN_REVIEW_UPLOAD_FILE_ORDER : routeChildren.ADMIN_REVIEW_UPLOAD, { reviewId }, @@ -54,7 +62,7 @@ const ReviewDetailsAddMoreChoiceStage: React.FC
- Do you want to add more files to this patients record? + Do you want to add more files to this patient's record? - Yes I have more scanned paper records to add for this patient + {reviewConfig.content.addMoreFilesRadioYesText} - No, I don't have anymore scanned paper records to add for this - patient + {reviewConfig.content.addMoreFilesRadioNoText}
diff --git a/app/src/components/blocks/_admin/reviewDetailsAssessmentStage/ExistingRecordTable.tsx b/app/src/components/blocks/_admin/reviewDetailsAssessmentStage/ExistingRecordTable.tsx index 84dadd7d7..86bd6fea0 100644 --- a/app/src/components/blocks/_admin/reviewDetailsAssessmentStage/ExistingRecordTable.tsx +++ b/app/src/components/blocks/_admin/reviewDetailsAssessmentStage/ExistingRecordTable.tsx @@ -14,7 +14,7 @@ const ExistingRecordTable = ({ return (

Existing files

- +
Filename diff --git a/app/src/components/blocks/_admin/reviewDetailsAssessmentStage/ReviewDetailsAssessmentStage.test.tsx b/app/src/components/blocks/_admin/reviewDetailsAssessmentStage/ReviewDetailsAssessmentStage.test.tsx index af9ed6b83..9df0f1031 100644 --- a/app/src/components/blocks/_admin/reviewDetailsAssessmentStage/ReviewDetailsAssessmentStage.test.tsx +++ b/app/src/components/blocks/_admin/reviewDetailsAssessmentStage/ReviewDetailsAssessmentStage.test.tsx @@ -1,6 +1,5 @@ import { render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import { act } from 'react'; import { describe, expect, it, Mock, vi } from 'vitest'; import ReviewDetailsAssessmentStage from './ReviewDetailsAssessmentStage'; import { DOWNLOAD_STAGE } from '../../../../types/generic/downloadStage'; @@ -175,15 +174,14 @@ const createMockUploadDocuments = (): ReviewUploadDocument[] => [ }, ]; -describe('ReviewDetailsAssessmentPage', () => { +describe('ReviewDetailsAssessmentStage', () => { beforeEach(() => { vi.clearAllMocks(); + mockUsePatientDetailsContext.mockReturnValue([null, mockSetPatientDetails]); }); describe('Rendering', () => { it('displays spinner when reviewData is null', () => { - mockUsePatientDetailsContext.mockReturnValue([null, mockSetPatientDetails]); - render( { }); it('displays spinner only when uploadDocuments is null/undefined or reviewData is null', () => { - mockUsePatientDetailsContext.mockReturnValue([null, mockSetPatientDetails]); - const { rerender } = render( { />, ); - expect( - screen.getByText(/Review the new and existing Scanned paper notes/i), - ).toBeInTheDocument(); + expect(screen.getByText(/Review the new Scanned paper notes/i)).toBeInTheDocument(); }); - it('renders page title for review with existing and new files', () => { - mockUsePatientDetailsContext.mockReturnValue([null, mockSetPatientDetails]); - + it('renders page title for review the new scanned paper notes', () => { render( { />, ); - expect( - screen.getByText(/Review the new and existing Scanned paper notes/i), - ).toBeInTheDocument(); + expect(screen.getByText(/Review the new scanned paper notes/)).toBeInTheDocument(); }); it('renders accept/reject radio buttons when only canBeDiscarded is true', () => { - mockUsePatientDetailsContext.mockReturnValue([null, mockSetPatientDetails]); - render( { uploadDocuments={createMockUploadDocuments()} downloadStage={DOWNLOAD_STAGE.SUCCEEDED} setDownloadStage={mockSetDownloadStage} - hasExistingRecordInStorage={false} + hasExistingRecordInStorage={true} />, ); @@ -272,30 +260,7 @@ describe('ReviewDetailsAssessmentPage', () => { expect(screen.getByRole('radio', { name: 'Reject record' })).toBeInTheDocument(); }); - it('renders add-all and choose-files radio buttons when no existing record', () => { - mockUsePatientDetailsContext.mockReturnValue([null, mockSetPatientDetails]); - - render( - , - ); - - expect(screen.getByLabelText('Add all these files')).toBeInTheDocument(); - expect(screen.getByLabelText('Choose which files to add')).toBeInTheDocument(); - expect( - screen.queryByText(/I don't need these files, they are duplicates/), - ).not.toBeInTheDocument(); - }); - it('renders all radio options when has existing record in storage', () => { - mockUsePatientDetailsContext.mockReturnValue([null, mockSetPatientDetails]); - render( { name: /Add all files to the existing Scanned paper notes/i, }), ).toBeInTheDocument(); - expect( - screen.getByRole('radio', { name: /Choose which files to add to the existing/i }), - ).toBeInTheDocument(); expect( screen.getByRole('radio', { name: /I don't need these files, they are duplicates/i, @@ -323,8 +285,6 @@ describe('ReviewDetailsAssessmentPage', () => { }); it('displays existing files table when available', () => { - mockUsePatientDetailsContext.mockReturnValue([null, mockSetPatientDetails]); - render( { }); it('displays new files table', () => { - mockUsePatientDetailsContext.mockReturnValue([null, mockSetPatientDetails]); - render( { }); it('displays "all files" viewing message by default', () => { - mockUsePatientDetailsContext.mockReturnValue([null, mockSetPatientDetails]); - render( { uploadDocuments={createMockUploadDocuments()} downloadStage={DOWNLOAD_STAGE.SUCCEEDED} setDownloadStage={mockSetDownloadStage} - hasExistingRecordInStorage={false} + hasExistingRecordInStorage={true} />, ); @@ -417,9 +373,7 @@ describe('ReviewDetailsAssessmentPage', () => { ); const viewButtons = screen.getAllByRole('button', { name: /View/i }); - await act(async () => { - await user.click(viewButtons[1]); - }); + await user.click(viewButtons[1]); await waitFor(() => { expect(mockSetDownloadStage).toHaveBeenCalledWith(DOWNLOAD_STAGE.PENDING); @@ -444,9 +398,7 @@ describe('ReviewDetailsAssessmentPage', () => { ); const viewButtons = screen.getAllByRole('button', { name: /View/i }); - await act(async () => { - await user.click(viewButtons[1]); - }); + await user.click(viewButtons[1]); await waitFor(() => { expect(mockGetReviewById).toHaveBeenCalled(); @@ -471,9 +423,7 @@ describe('ReviewDetailsAssessmentPage', () => { ); const viewButtons = screen.getAllByRole('button', { name: /View/i }); - await act(async () => { - await user.click(viewButtons[1]); - }); + await user.click(viewButtons[1]); await waitFor(() => { expect( @@ -506,9 +456,7 @@ describe('ReviewDetailsAssessmentPage', () => { const existingFileViewButton = screen.getByTestId('existing-record-table'); const viewButton = existingFileViewButton.querySelector('button'); - await act(async () => { - await user.click(viewButton!); - }); + await user.click(viewButton!); await waitFor(() => { expect( @@ -573,9 +521,7 @@ describe('ReviewDetailsAssessmentPage', () => { ); const viewButtons = screen.getAllByRole('button', { name: /View duplicate.pdf/i }); - await act(async () => { - await user.click(viewButtons[0]); // Click first duplicate - }); + await user.click(viewButtons[0]); // Click first duplicate await waitFor(() => { expect(screen.getByText(/\(new files\)/)).toBeInTheDocument(); @@ -648,9 +594,7 @@ describe('ReviewDetailsAssessmentPage', () => { const existingFileViewButton = screen.getByTestId('existing-record-table'); const viewButton = existingFileViewButton.querySelector('button'); - await act(async () => { - await user.click(viewButton!); - }); + await user.click(viewButton!); await waitFor(() => { expect(screen.getByText(/\(existing files\)/)).toBeInTheDocument(); @@ -690,28 +634,6 @@ describe('ReviewDetailsAssessmentPage', () => { expect(addAllRadio).toBeChecked(); }); - it('allows selecting choose-files option', async () => { - const user = userEvent.setup(); - - render( - , - ); - - const chooseFilesRadio = screen.getByLabelText( - /Choose which files to add to the existing/i, - ); - await user.click(chooseFilesRadio); - - expect(chooseFilesRadio).toBeChecked(); - }); - it('allows selecting duplicate option', async () => { const user = userEvent.setup(); @@ -749,7 +671,7 @@ describe('ReviewDetailsAssessmentPage', () => { uploadDocuments={createMockUploadDocuments()} downloadStage={DOWNLOAD_STAGE.SUCCEEDED} setDownloadStage={mockSetDownloadStage} - hasExistingRecordInStorage={false} + hasExistingRecordInStorage={true} />, ); @@ -774,7 +696,7 @@ describe('ReviewDetailsAssessmentPage', () => { uploadDocuments={createMockUploadDocuments()} downloadStage={DOWNLOAD_STAGE.SUCCEEDED} setDownloadStage={mockSetDownloadStage} - hasExistingRecordInStorage={false} + hasExistingRecordInStorage={true} />, ); @@ -837,34 +759,6 @@ describe('ReviewDetailsAssessmentPage', () => { ); }); - it('navigates to choose which files when choose-files is selected', async () => { - const user = userEvent.setup(); - - render( - , - ); - - const chooseFilesRadio = screen.getByRole('radio', { - name: /Choose which files to add to the existing/i, - }); - await user.click(chooseFilesRadio); - - const continueButton = screen.getByRole('button', { name: 'Continue' }); - await user.click(continueButton); - - expect(mockedUseNavigate).toHaveBeenCalledWith( - '/admin/reviews/test-review-id.v1/files', - undefined, - ); - }); - it('navigates to no files choice when duplicate is selected', async () => { const user = userEvent.setup(); @@ -903,7 +797,7 @@ describe('ReviewDetailsAssessmentPage', () => { uploadDocuments={createMockUploadDocuments()} downloadStage={DOWNLOAD_STAGE.SUCCEEDED} setDownloadStage={mockSetDownloadStage} - hasExistingRecordInStorage={false} + hasExistingRecordInStorage={true} />, ); @@ -1008,9 +902,7 @@ describe('ReviewDetailsAssessmentPage', () => { ); const viewButtons = screen.getAllByRole('button', { name: /View/i }); - await act(async () => { - await user.click(viewButtons[1]); - }); + await user.click(viewButtons[1]); await waitFor(() => { expect(mockedUseNavigate).toHaveBeenCalledWith('/session-expired'); @@ -1034,9 +926,7 @@ describe('ReviewDetailsAssessmentPage', () => { ); const viewButtons = screen.getAllByRole('button', { name: /View/i }); - await act(async () => { - await user.click(viewButtons[1]); - }); + await user.click(viewButtons[1]); await waitFor(() => { expect(mockedUseNavigate).toHaveBeenCalledWith( @@ -1083,7 +973,7 @@ describe('ReviewDetailsAssessmentPage', () => { uploadDocuments={singleUploadDoc} downloadStage={DOWNLOAD_STAGE.SUCCEEDED} setDownloadStage={mockSetDownloadStage} - hasExistingRecordInStorage={false} + hasExistingRecordInStorage={true} />, ); @@ -1148,7 +1038,7 @@ describe('ReviewDetailsAssessmentPage', () => { uploadDocuments={multiUploadDocs} downloadStage={DOWNLOAD_STAGE.SUCCEEDED} setDownloadStage={mockSetDownloadStage} - hasExistingRecordInStorage={false} + hasExistingRecordInStorage={true} />, ); @@ -1183,4 +1073,47 @@ describe('ReviewDetailsAssessmentPage', () => { expect(screen.getByTestId('back-button')).toBeInTheDocument(); }); }); + + describe('Redirect behavior when no existing record in storage', () => { + it('redirects to add more choice page with replace option when hasExistingRecordInStorage is false', async () => { + vi.useFakeTimers(); + + render( + , + ); + + // Fast-forward timers to trigger the setTimeout + await vi.advanceTimersByTimeAsync(0); + + expect(mockedUseNavigate).toHaveBeenCalledWith( + '/admin/reviews/test-review-id.v1/add-more-choice', + { replace: true }, + ); + + vi.useRealTimers(); + }); + + it('renders empty fragment when redirecting', () => { + const { container } = render( + , + ); + + // Should render empty fragment (no content) + expect(container.firstChild).toBeNull(); + }); + }); }); diff --git a/app/src/components/blocks/_admin/reviewDetailsAssessmentStage/ReviewDetailsAssessmentStage.tsx b/app/src/components/blocks/_admin/reviewDetailsAssessmentStage/ReviewDetailsAssessmentStage.tsx index 340e70abb..b3c885d2f 100644 --- a/app/src/components/blocks/_admin/reviewDetailsAssessmentStage/ReviewDetailsAssessmentStage.tsx +++ b/app/src/components/blocks/_admin/reviewDetailsAssessmentStage/ReviewDetailsAssessmentStage.tsx @@ -62,10 +62,20 @@ const ReviewDetailsAssessmentStage = ({ const baseUrl = useBaseAPIUrl(); const baseHeaders = useBaseAPIHeaders(); + if (!hasExistingRecordInStorage && reviewId !== undefined) { + setTimeout(() => { + navigateUrlParam(routeChildren.ADMIN_REVIEW_ADD_MORE_CHOICE, { reviewId }, navigate, { + replace: true, + }); + }, 0); + return <>; + } + const handleExistingFileView = async (filename: string, id: string): Promise => { if (!reviewData) { return; } + if (isLocal) { const file = reviewData.existingFiles?.find((f) => f.fileName === filename); if (!file) { @@ -209,8 +219,7 @@ const ReviewDetailsAssessmentStage = ({ if (reviewConfig.canBeUpdated === false && reviewConfig.canBeDiscarded) { pageTitle = 'Do you want to accept these records?'; } else if (reviewConfig.canBeUpdated && reviewConfig.canBeDiscarded) { - const andExisting = reviewData.existingFiles!.length > 0 ? ' and existing ' : ' '; - pageTitle = `Review the new${andExisting}${reviewTypeLabel.toSentenceCase()}`; + pageTitle = reviewConfig.content.reviewAssessmentPageTitle as string; } else { pageTitle = `Review the ${reviewTypeLabel.toSentenceCase()}`; } @@ -257,15 +266,6 @@ const ReviewDetailsAssessmentStage = ({ > Add all files to the existing {reviewTypeLabel.toSentenceCase()} - { - setFileAction(e.currentTarget.value as FileAction); - }} - > - Choose which files to add to the existing {reviewTypeLabel.toSentenceCase()} -

- This shows how these {documentConfig.displayName} will look when - combined into a single document.{' '} + {documentConfig.content.stitchedPreviewFirstParagraph} + {journey === 'update' && `Any files added will appear after the existing ${documentConfig.displayName}.`}

diff --git a/app/src/components/blocks/generic/patientVerifyPage/PatientVerifyPage.test.tsx b/app/src/components/blocks/generic/patientVerifyPage/PatientVerifyPage.test.tsx index d5ad7801a..1efc4e3f5 100644 --- a/app/src/components/blocks/generic/patientVerifyPage/PatientVerifyPage.test.tsx +++ b/app/src/components/blocks/generic/patientVerifyPage/PatientVerifyPage.test.tsx @@ -316,10 +316,12 @@ describe('PatientVerifyPage', () => { }); await userEvent.click(confirmButton); - await waitFor(async () => { - const results = await runAxeTest(document.body); - expect(results).toHaveNoViolations(); + await waitFor(() => { + expect(screen.getByText('There is a problem')).toBeInTheDocument(); }); + + const results = await runAxeTest(document.body); + expect(results).toHaveNoViolations(); }); }); }); diff --git a/app/src/config/electronicHealthRecordAttachmentsConfig.json b/app/src/config/electronicHealthRecordAttachmentsConfig.json index 6f6529f12..36ffb2e9e 100644 --- a/app/src/config/electronicHealthRecordAttachmentsConfig.json +++ b/app/src/config/electronicHealthRecordAttachmentsConfig.json @@ -33,6 +33,10 @@ "previewUploadTitle": "Preview electronic health record attachment", "uploadFilesExtraParagraph": "", "reviewDocumentTitle": "EHR Attachments", - "skipDocumentLinkText": "Continue without uploading any EHR attachments" + "skipDocumentLinkText": "Continue without uploading any EHR attachments", + "addMoreFilesRadioNoText": "", + "addMoreFilesRadioYesText": "", + "reviewAssessmentPageTitle": "", + "stitchedPreviewFirstParagraph": "" } } \ No newline at end of file diff --git a/app/src/config/lettersAndDocumentsConfig.json b/app/src/config/lettersAndDocumentsConfig.json index 0f0053847..0833b72ea 100644 --- a/app/src/config/lettersAndDocumentsConfig.json +++ b/app/src/config/lettersAndDocumentsConfig.json @@ -31,6 +31,10 @@ "beforeYouUploadTitle": "Before you upload", "previewUploadTitle": "Preview your PDF files", "uploadFilesExtraParagraph": "", - "reviewDocumentTitle": "Letters and documents" + "reviewDocumentTitle": "Letters and documents", + "addMoreFilesRadioNoText": "", + "addMoreFilesRadioYesText": "", + "reviewAssessmentPageTitle": "", + "stitchedPreviewFirstParagraph": "" } } \ No newline at end of file diff --git a/app/src/config/lloydGeorgeConfig.json b/app/src/config/lloydGeorgeConfig.json index a35946e31..fcf835621 100644 --- a/app/src/config/lloydGeorgeConfig.json +++ b/app/src/config/lloydGeorgeConfig.json @@ -31,8 +31,12 @@ "confirmFilesTableTitle": "Scanned paper notes to upload", "confirmFilesTableParagraph": "", "beforeYouUploadTitle": "Before you upload", - "previewUploadTitle": "Preview these scanned paper notes", + "previewUploadTitle": "Preview existing scanned paper notes record", "uploadFilesExtraParagraph": "You can add a note to the patient's electronic health record to say their Lloyd George record is stored in this service. Use SNOMED code 16521000000101.", - "reviewDocumentTitle": "Scanned paper notes" + "reviewDocumentTitle": "Scanned paper notes", + "addMoreFilesRadioNoText": "No, I don't have anymore scanned paper notes to add for this patient", + "addMoreFilesRadioYesText": "Yes, I have more scanned paper notes to add for this patient", + "reviewAssessmentPageTitle": "Review the new scanned paper notes", + "stitchedPreviewFirstParagraph": "This shows how the final notes will look when combined into a single document. " } } \ No newline at end of file diff --git a/app/src/helpers/utils/documentType.ts b/app/src/helpers/utils/documentType.ts index d1e60497c..eb9c382f5 100644 --- a/app/src/helpers/utils/documentType.ts +++ b/app/src/helpers/utils/documentType.ts @@ -26,7 +26,11 @@ export type ContentKey = | 'uploadFilesBulletPoints' | 'skipDocumentLinkText' | 'confirmFilesTableTitle' - | 'confirmFilesTableParagraph'; + | 'confirmFilesTableParagraph' + | 'addMoreFilesRadioNoText' + | 'addMoreFilesRadioYesText' + | 'reviewAssessmentPageTitle' + | 'stitchedPreviewFirstParagraph'; export interface IndividualDocumentTypeContent extends Record {} // The individual config for each document type diff --git a/app/src/pages/lloydGeorgeRecordPage/LloydGeorgeRecordPage.test.tsx b/app/src/pages/lloydGeorgeRecordPage/LloydGeorgeRecordPage.test.tsx index 1113e93a5..d3d37ed67 100644 --- a/app/src/pages/lloydGeorgeRecordPage/LloydGeorgeRecordPage.test.tsx +++ b/app/src/pages/lloydGeorgeRecordPage/LloydGeorgeRecordPage.test.tsx @@ -25,6 +25,10 @@ vi.mock('../../helpers/hooks/useBaseAPIHeaders'); vi.mock('../../helpers/hooks/useBaseAPIUrl'); vi.mock('../../helpers/hooks/useRole'); +vi.mock('../../providers/analyticsProvider/AnalyticsProvider', () => ({ + useAnalyticsContext: (): [null, () => void] => [null, (): void => {}], +})); + const mockAxios = axios as Mocked; const mockPatientDetails = buildPatientDetails(); const mockedUsePatient = usePatient as Mock; diff --git a/app/src/pages/privacyPage/PrivacyPage.test.tsx b/app/src/pages/privacyPage/PrivacyPage.test.tsx index bf92f385f..fc14cf11e 100644 --- a/app/src/pages/privacyPage/PrivacyPage.test.tsx +++ b/app/src/pages/privacyPage/PrivacyPage.test.tsx @@ -27,7 +27,7 @@ describe('PrivacyPage', () => { }); describe('Rendering', () => { - it('renders page headers', () => { + it('renders page headers', async () => { render(); const contentHeaders = [ @@ -38,8 +38,11 @@ describe('PrivacyPage', () => { 'Feedback form privacy notice', 'Contact us', ]; - contentHeaders.forEach((str) => { - expect(screen.getByRole('heading', { name: str })).toBeInTheDocument(); + + await waitFor(async () => { + contentHeaders.forEach((str) => { + expect(screen.getByRole('heading', { name: str })).toBeInTheDocument(); + }); }); });