diff --git a/app/src/components/blocks/_admin/reviewDetailsAssessmentStage/ReviewDetailsAssessmentStage.test.tsx b/app/src/components/blocks/_admin/reviewDetailsAssessmentStage/ReviewDetailsAssessmentStage.test.tsx index b7cf4e5441..9bbb5dfc83 100644 --- a/app/src/components/blocks/_admin/reviewDetailsAssessmentStage/ReviewDetailsAssessmentStage.test.tsx +++ b/app/src/components/blocks/_admin/reviewDetailsAssessmentStage/ReviewDetailsAssessmentStage.test.tsx @@ -14,6 +14,8 @@ import * as getReviewsModule from '../../../../helpers/requests/getReviews'; import { DOCUMENT_TYPE } from '../../../../helpers/utils/documentType'; const mockedUseNavigate = vi.fn(); +const mockSetPatientDetails = vi.fn(); +const mockUsePatientDetailsContext = vi.fn(); vi.mock('../../../../helpers/utils/getPdfObjectUrl', () => ({ getPdfObjectUrl: vi.fn().mockResolvedValue(200), @@ -91,6 +93,10 @@ vi.mock( }), ); +vi.mock('../../../../providers/patientProvider/PatientProvider', () => ({ + usePatientDetailsContext: (): unknown => mockUsePatientDetailsContext(), +})); + const mockSetReviewData = vi.fn(); const mockSetDownloadStage = vi.fn(); @@ -175,6 +181,8 @@ describe('ReviewDetailsAssessmentPage', () => { 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( { }); it('renders page title for review with existing and new files', () => { + mockUsePatientDetailsContext.mockReturnValue([null, mockSetPatientDetails]); + render( { }); it('renders accept/reject radio buttons when only canBeDiscarded is true', () => { + mockUsePatientDetailsContext.mockReturnValue([null, mockSetPatientDetails]); + render( { }); it('renders add-all and choose-files radio buttons when no existing record', () => { + mockUsePatientDetailsContext.mockReturnValue([null, mockSetPatientDetails]); + render( { }); it('renders all radio options when has existing record in storage', () => { + mockUsePatientDetailsContext.mockReturnValue([null, mockSetPatientDetails]); + render( { }); 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( { expect(screen.getByText('You are currently viewing: all files')).toBeInTheDocument(); }); + + it('displays patient demographics', async () => { + mockUsePatientDetailsContext.mockReturnValue([null, mockSetPatientDetails]); + + render( + , + ); + + expect(screen.getByTestId('patient-summary')).toBeInTheDocument(); + expect(screen.getByTestId('patient-summary-full-name')).toBeInTheDocument(); + expect(screen.getByTestId('patient-summary-nhs-number')).toBeInTheDocument(); + expect(screen.getByTestId('patient-summary-date-of-birth')).toBeInTheDocument(); + }); }); describe('File viewing', () => { diff --git a/app/src/components/blocks/_admin/reviewDetailsAssessmentStage/ReviewDetailsAssessmentStage.tsx b/app/src/components/blocks/_admin/reviewDetailsAssessmentStage/ReviewDetailsAssessmentStage.tsx index 14fbdb6e7c..08174aaef2 100644 --- a/app/src/components/blocks/_admin/reviewDetailsAssessmentStage/ReviewDetailsAssessmentStage.tsx +++ b/app/src/components/blocks/_admin/reviewDetailsAssessmentStage/ReviewDetailsAssessmentStage.tsx @@ -27,6 +27,7 @@ import { import DocumentUploadLloydGeorgePreview from '../../_documentUpload/documentUploadLloydGeorgePreview/DocumentUploadLloydGeorgePreview'; import { AxiosError } from 'axios'; import { errorToParams } from '../../../../helpers/utils/errorToParams'; +import PatientSummary, { PatientInfo } from '../../../generic/patientSummary/PatientSummary'; type FileAction = 'add-all' | 'choose-files' | 'duplicate' | 'accept' | 'reject' | ''; @@ -327,6 +328,14 @@ const ReviewDetailsAssessmentStage = ({

{pageTitle}

+
+ + + + + +
+ {canBeUpdatedAndDiscarded && reviewData.existingFiles!.length > 0 && ( ({ })); const mockNavigate = vi.fn(); +const mockSetPatientDetails = vi.fn(); +const mockUsePatientDetailsContext = vi.fn(); const mockReviewId = 'test-review-123'; let currentReviewId: string | undefined = mockReviewId; @@ -30,6 +32,10 @@ vi.mock('react-router-dom', async (): Promise => { }; }); +vi.mock('../../../../providers/patientProvider/PatientProvider', () => ({ + usePatientDetailsContext: (): unknown => mockUsePatientDetailsContext(), +})); + const mockGetConfigForDocType = getConfigForDocType as Mock; const makeReviewDoc = ( @@ -76,6 +82,8 @@ describe('ReviewDetailsFileSelectStage', () => { }); it('renders a spinner when reviewData is null', () => { + mockUsePatientDetailsContext.mockReturnValue([null, mockSetPatientDetails]); + render( { }); it('renders heading and only shows REVIEW documents in the table', () => { + mockUsePatientDetailsContext.mockReturnValue([null, mockSetPatientDetails]); + const documents: ReviewUploadDocument[] = [ makeReviewDoc('file1.pdf', DOCUMENT_UPLOAD_STATE.UNSELECTED, UploadDocumentType.REVIEW), makeReviewDoc( @@ -116,7 +126,36 @@ describe('ReviewDetailsFileSelectStage', () => { expect(screen.queryByText('existing.pdf')).not.toBeInTheDocument(); }); + it('renders patient demograhics', () => { + mockUsePatientDetailsContext.mockReturnValue([null, mockSetPatientDetails]); + + const documents: ReviewUploadDocument[] = [ + makeReviewDoc('file1.pdf', DOCUMENT_UPLOAD_STATE.UNSELECTED, UploadDocumentType.REVIEW), + makeReviewDoc( + 'existing.pdf', + DOCUMENT_UPLOAD_STATE.UNSELECTED, + UploadDocumentType.EXISTING, + ), + ]; + + render( + , + ); + + expect(screen.getByTestId('patient-summary')).toBeInTheDocument(); + expect(screen.getByTestId('patient-summary-full-name')).toBeInTheDocument(); + expect(screen.getByTestId('patient-summary-nhs-number')).toBeInTheDocument(); + expect(screen.getByTestId('patient-summary-date-of-birth')).toBeInTheDocument(); + + }); + it('allows viewing a selected file and passes the object URL to the PDF viewer', async () => { + mockUsePatientDetailsContext.mockReturnValue([null, mockSetPatientDetails]); + const user = userEvent.setup(); const documents: ReviewUploadDocument[] = [ makeReviewDoc('file1.pdf', DOCUMENT_UPLOAD_STATE.UNSELECTED, UploadDocumentType.REVIEW), @@ -165,6 +204,8 @@ describe('ReviewDetailsFileSelectStage', () => { }); it('clears the error summary after selecting a file', async () => { + mockUsePatientDetailsContext.mockReturnValue([null, mockSetPatientDetails]); + const user = userEvent.setup(); const initialDocs: ReviewUploadDocument[] = [ makeReviewDoc('file1.pdf', DOCUMENT_UPLOAD_STATE.UNSELECTED, UploadDocumentType.REVIEW), @@ -194,6 +235,8 @@ describe('ReviewDetailsFileSelectStage', () => { }); it('navigates to add-more-choice when all files are selected', async () => { + mockUsePatientDetailsContext.mockReturnValue([null, mockSetPatientDetails]); + const user = userEvent.setup(); const initialDocs: ReviewUploadDocument[] = [ makeReviewDoc('file1.pdf', DOCUMENT_UPLOAD_STATE.SELECTED, UploadDocumentType.REVIEW), @@ -217,6 +260,8 @@ describe('ReviewDetailsFileSelectStage', () => { }); it('navigates to download-choice when some files are unselected', async () => { + mockUsePatientDetailsContext.mockReturnValue([null, mockSetPatientDetails]); + const user = userEvent.setup(); const initialDocs: ReviewUploadDocument[] = [ makeReviewDoc('file1.pdf', DOCUMENT_UPLOAD_STATE.SELECTED, UploadDocumentType.REVIEW), @@ -238,6 +283,8 @@ describe('ReviewDetailsFileSelectStage', () => { }); it('does not navigate if reviewId is missing', async () => { + mockUsePatientDetailsContext.mockReturnValue([null, mockSetPatientDetails]); + const user = userEvent.setup(); currentReviewId = undefined; diff --git a/app/src/components/blocks/_admin/reviewDetailsFileSelectStage/ReviewDetailsFileSelectStage.tsx b/app/src/components/blocks/_admin/reviewDetailsFileSelectStage/ReviewDetailsFileSelectStage.tsx index 34aeef531f..86c5f93305 100644 --- a/app/src/components/blocks/_admin/reviewDetailsFileSelectStage/ReviewDetailsFileSelectStage.tsx +++ b/app/src/components/blocks/_admin/reviewDetailsFileSelectStage/ReviewDetailsFileSelectStage.tsx @@ -13,6 +13,7 @@ import { ReviewUploadDocument, UploadDocumentType, } from '../../../../types/pages/UploadDocumentsPage/types'; +import PatientSummary, { PatientInfo } from '../../../generic/patientSummary/PatientSummary'; export type ReviewDetailsFileSelectStageProps = { reviewData: ReviewDetails | null; @@ -142,6 +143,14 @@ const ReviewDetailsFileSelectStage = ({

Choose files to add to the existing {reviewTypeLabel.toSentenceCase()}

+
+ + + + + +
+

New files