diff --git a/app/src/components/blocks/_admin/reviewDetailsPatientSearchStage/ReviewDetailsPatientSearchStage.test.tsx b/app/src/components/blocks/_admin/reviewDetailsPatientSearchStage/ReviewDetailsPatientSearchStage.test.tsx index 9f305978c..0f4fd75c2 100644 --- a/app/src/components/blocks/_admin/reviewDetailsPatientSearchStage/ReviewDetailsPatientSearchStage.test.tsx +++ b/app/src/components/blocks/_admin/reviewDetailsPatientSearchStage/ReviewDetailsPatientSearchStage.test.tsx @@ -236,6 +236,29 @@ describe('ReviewDetailsPatientSearchPage', () => { }); }); + it('displays incorrectFormatMessage in both ErrorBox and TextInput on validation failure', async () => { + render( + {}} + />, + ); + + const input = screen.getByTestId('nhs-number-input'); + const continueButton = screen.getByTestId('continue-button'); + + // Submit with invalid NHS number + await userEvent.type(input, '12345'); + await userEvent.click(continueButton); + + await waitFor(() => { + // Check that incorrectFormatMessage appears twice (ErrorBox + TextInput) + const errorMessages = screen.getAllByText(incorrectFormatMessage); + expect(errorMessages).toHaveLength(2); + }); + }); + it('shows error for invalid NHS number format', async () => { render( +

Search for the correct patient

+ {(submissionState === PATIENT_SEARCH_STATES.FAILED || inputError === incorrectFormatMessage) && ( <> @@ -175,8 +178,6 @@ const ReviewDetailsPatientSearchStage = ({ )} -

Search for the correct patient

-

Enter the NHS number to find the correct patient demographics for this document.