File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
app/src/pages/patientSearchPage Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ describe('PatientSearchPage', () => {
7878 userEvent . type ( screen . getByRole ( 'textbox' , { name : 'Enter NHS number' } ) , '21212' ) ;
7979 userEvent . click ( screen . getByRole ( 'button' , { name : 'Search' } ) ) ;
8080 await waitFor ( ( ) => {
81- expect ( screen . getByText ( incorrectFormatMessage ) ) . toBeInTheDocument ( ) ;
81+ expect ( screen . getAllByText ( incorrectFormatMessage ) ) . toHaveLength ( 2 ) ;
8282 } ) ;
8383 } ) ;
8484 } ) ;
@@ -422,7 +422,7 @@ describe('PatientSearchPage', () => {
422422 renderPatientSearchPage ( ) ;
423423 userEvent . click ( screen . getByRole ( 'button' , { name : 'Search' } ) ) ;
424424 await waitFor ( ( ) => {
425- expect ( screen . getByText ( incorrectFormatMessage ) ) . toBeInTheDocument ( ) ;
425+ expect ( screen . getAllByText ( incorrectFormatMessage ) ) . toHaveLength ( 2 ) ;
426426 } ) ;
427427 } ) ;
428428
@@ -436,7 +436,7 @@ describe('PatientSearchPage', () => {
436436 ) ;
437437 userEvent . click ( screen . getByRole ( 'button' , { name : 'Search' } ) ) ;
438438 await waitFor ( ( ) => {
439- expect ( screen . getByText ( incorrectFormatMessage ) ) . toBeInTheDocument ( ) ;
439+ expect ( screen . getAllByText ( incorrectFormatMessage ) ) . toHaveLength ( 2 ) ;
440440 } ) ;
441441 } ,
442442 ) ;
Original file line number Diff line number Diff line change @@ -67,7 +67,6 @@ function PatientSearchPage() {
6767 setInputError ( null ) ;
6868 setStatusCode ( null ) ;
6969 const nhsNumber = data . nhsNumber . replace ( / [ - \s ] / gi, '' ) ;
70-
7170 try {
7271 const patientDetails = await getPatientDetails ( {
7372 nhsNumber,
@@ -127,7 +126,8 @@ function PatientSearchPage() {
127126 < BackLink asElement = "a" href = { routes . HOME } >
128127 Return to Home
129128 </ BackLink >
130- { submissionState === SEARCH_STATES . FAILED && (
129+ { ( submissionState === SEARCH_STATES . FAILED ||
130+ inputError === incorrectFormatMessage ) && (
131131 < >
132132 { isError ? (
133133 < ServiceError />
@@ -141,8 +141,9 @@ function PatientSearchPage() {
141141 ) }
142142 </ >
143143 ) }
144+
144145 < h1 > { pageTitle } </ h1 >
145- < form onSubmit = { handleSubmit ( handleSearch , handleError ) } noValidate >
146+ < form onSubmit = { handleSubmit ( handleSearch , handleError ) } >
146147 < TextInput
147148 id = "nhs-number-input"
148149 data-testid = "nhs-number-input"
You can’t perform that action at this time.
0 commit comments