@@ -7,9 +7,11 @@ import useRole from '../../../../helpers/hooks/useRole';
77import { REPOSITORY_ROLE } from '../../../../types/generic/authRole' ;
88import { routeChildren , routes } from '../../../../types/generic/routes' ;
99import useConfig from '../../../../helpers/hooks/useConfig' ;
10- import { buildConfig } from '../../../../helpers/test/testBuilders' ;
10+ import { buildConfig , buildPatientDetails } from '../../../../helpers/test/testBuilders' ;
1111import { runAxeTest } from '../../../../helpers/test/axeTestHelper' ;
1212import { afterEach , beforeEach , describe , expect , it , vi , Mock } from 'vitest' ;
13+ import usePatient from '../../../../helpers/hooks/usePatient' ;
14+ import { PatientDetails } from '../../../../types/generic/patientDetails' ;
1315
1416vi . mock ( '../../../../helpers/hooks/useRole' ) ;
1517vi . mock ( '../../../../helpers/hooks/useConfig' ) ;
@@ -22,6 +24,8 @@ vi.mock('react-router-dom', () => ({
2224const mockUseRole = useRole as Mock ;
2325const mockUseConfig = useConfig as Mock ;
2426const mockNavigate = vi . fn ( ) ;
27+ const mockPatient = usePatient as Mock ;
28+ const mockDeceasedPatientDetails : PatientDetails = buildPatientDetails ( { deceased : true } ) ;
2529
2630describe ( 'LloydGeorgeRecordError' , ( ) => {
2731 beforeEach ( ( ) => {
@@ -145,6 +149,35 @@ describe('LloydGeorgeRecordError', () => {
145149 screen . queryByRole ( 'button' , { name : 'Upload files for this patient' } ) ,
146150 ) . not . toBeInTheDocument ( ) ;
147151 } ) ;
152+
153+ it . each ( [ REPOSITORY_ROLE . GP_ADMIN , REPOSITORY_ROLE . GP_CLINICAL ] ) (
154+ "renders a message but no upload button when the document download status is 'No records', user role is '%s' and upload flags are enabled and patient is deceased" ,
155+ ( role ) => {
156+ const noRecordsStatus = DOWNLOAD_STAGE . NO_RECORDS ;
157+ mockPatient . mockReturnValue ( mockDeceasedPatientDetails ) ;
158+ mockUseConfig . mockReturnValue (
159+ buildConfig (
160+ { } ,
161+ {
162+ uploadLloydGeorgeWorkflowEnabled : true ,
163+ uploadLambdaEnabled : true ,
164+ } ,
165+ ) ,
166+ ) ;
167+ mockUseRole . mockReturnValue ( role ) ;
168+
169+ render ( < LloydGeorgeRecordError downloadStage = { noRecordsStatus } /> ) ;
170+
171+ expect (
172+ screen . getByText (
173+ / T h i s p a t i e n t d o e s n o t h a v e a L l o y d G e o r g e r e c o r d s t o r e d i n t h i s s e r v i c e / i,
174+ ) ,
175+ ) . toBeInTheDocument ( ) ;
176+ expect (
177+ screen . queryByRole ( 'button' , { name : 'Upload files for this patient' } ) ,
178+ ) . not . toBeInTheDocument ( ) ;
179+ } ,
180+ ) ;
148181 } ) ;
149182
150183 describe ( 'Accessibility' , ( ) => {
0 commit comments