Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,29 @@ describe('ReviewDetailsPatientSearchPage', () => {
});
});

it('displays incorrectFormatMessage in both ErrorBox and TextInput on validation failure', async () => {
render(
<ReviewDetailsPatientSearchStage
uploadDocuments={[]}
reviewData={mockReviewData}
setNewPatientDetails={(): void => {}}
/>,
);

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(
<ReviewDetailsPatientSearchStage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ import { DOWNLOAD_STAGE } from '../../../../types/generic/downloadStage';
import { getFormattedDateFromString } from '../../../../helpers/utils/formatDate';
import { ReviewUploadDocument } from '../../../../types/pages/UploadDocumentsPage/types';

export const incorrectFormatMessage = "Enter patient's 10 digit NHS number";
export const incorrectFormatMessage =
"Enter a valid patient NHS number. If you keep getting this message, select 'I don't know the NHS number'.";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


interface ReviewDetailsPatientSearchPageProps {
reviewData: ReviewDetails | null;
Expand Down Expand Up @@ -159,6 +160,8 @@ const ReviewDetailsPatientSearchStage = ({
<>
<BackButton backLinkText="Go back" dataTestid="back-button" />

<h1>Search for the correct patient</h1>

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

<h1>Search for the correct patient</h1>

<p>Enter the NHS number to find the correct patient demographics for this document.</p>

<form onSubmit={handleSubmit(handleValidSubmit, handleFormError)}>
Expand Down
Loading