@@ -145,6 +145,44 @@ describe('PatientSearchPage', () => {
145145 ) . toHaveLength ( 2 ) ;
146146 } ) ;
147147
148+ it ( 'returns patient info when patient is inactive and deceased' , async ( ) => {
149+ const patientDetails = buildPatientDetails ( {
150+ active : false ,
151+ deceased : true ,
152+ } ) ;
153+
154+ mockedAxios . get . mockImplementation ( ( ) => Promise . resolve ( { data : patientDetails } ) ) ;
155+
156+ renderPatientSearchPage ( ) ;
157+ userEvent . type ( screen . getByRole ( 'textbox' , { name : 'Enter NHS number' } ) , '9000000000' ) ;
158+ userEvent . click ( screen . getByRole ( 'button' , { name : 'Search' } ) ) ;
159+
160+ await waitFor ( ( ) => {
161+ expect ( mockedUseNavigate ) . toHaveBeenCalledWith ( routes . VERIFY_PATIENT ) ;
162+ } ) ;
163+ } ) ;
164+
165+ it ( 'returns an error when patient is inactive and not deceased and user is clinical' , async ( ) => {
166+ const patientDetails = buildPatientDetails ( {
167+ active : false ,
168+ deceased : false ,
169+ } ) ;
170+
171+ mockedAxios . get . mockImplementation ( ( ) => Promise . resolve ( { data : patientDetails } ) ) ;
172+
173+ mockedUseRole . mockReturnValue ( REPOSITORY_ROLE . GP_CLINICAL ) ;
174+
175+ renderPatientSearchPage ( ) ;
176+ userEvent . type ( screen . getByRole ( 'textbox' , { name : 'Enter NHS number' } ) , '9000000000' ) ;
177+ userEvent . click ( screen . getByRole ( 'button' , { name : 'Search' } ) ) ;
178+
179+ expect (
180+ await screen . findAllByText (
181+ "You cannot access this patient's record because they are not registered at your practice. The patient's current practice can access this record." ,
182+ ) ,
183+ ) . toHaveLength ( 2 ) ;
184+ } ) ;
185+
148186 it ( 'returns a service error when service is down' , async ( ) => {
149187 const errorResponse = {
150188 response : {
0 commit comments