@@ -15,22 +15,8 @@ import blipReducer from '@app/redux/reducers';
1515import MenuBar , { OVERVIEW_TAB_INDEX , STACKED_DAILY_TAB_INDEX } from '@app/components/PatientDrawer/MenuBar/MenuBar' ;
1616import i18n from '@app/core/language' ;
1717
18- // Mock actions
19- jest . mock ( '@app/redux/actions' , ( ) => ( { } ) ) ;
20-
2118// Mock connected-react-router
22- jest . mock ( 'connected-react-router' , ( ) => ( {
23- push : jest . fn ( ) ,
24- } ) ) ;
25-
26- // Mock api
27- jest . mock ( '@app/core/api' , ( ) => ( { } ) ) ;
28-
29- jest . mock ( '@app/pages/clinicworkspace/components/ReviewPatientToggle/PatientLastReviewed' , ( ) => {
30- return function MockPatientLastReviewed ( props ) {
31- return < div data-testid = "patient-last-reviewed" > Last Reviewed Component</ div > ;
32- } ;
33- } ) ;
19+ jest . mock ( 'connected-react-router' , ( ) => ( { push : jest . fn ( ) } ) ) ;
3420
3521// Mock the agpCGMText function from @tidepool /viz while preserving other exports
3622jest . mock ( '@tidepool/viz' , ( ) => {
@@ -47,13 +33,16 @@ jest.mock('@tidepool/viz', () => {
4733 } ;
4834} ) ;
4935
36+ jest . mock ( '@app/providers/ToastProvider' , ( ) => ( {
37+ useToasts : ( ) => ( { set : jest . fn ( ) } ) ,
38+ } ) ) ;
39+
5040const TEST_TIMEOUT_MS = 30_000 ;
5141
5242const patientUrl = 'http://app.tidepool.test/v1/clinics/clinic123/patients/patient123' ;
53- const defaultPatient = { fullName : 'Zhilei Zhang' , birthDate : '1990-01-15' } ;
5443
5544const server = setupServer (
56- http . get ( patientUrl , ( ) => HttpResponse . json ( defaultPatient ) ) ,
45+ http . get ( patientUrl , ( ) => HttpResponse . json ( { fullName : 'Zhilei Zhang' , birthDate : '1990-01-15' } ) ) ,
5746) ;
5847
5948const defaultProps = {
@@ -139,11 +128,11 @@ describe('MenuBar Component', () => {
139128 } ) ;
140129
141130 describe ( 'Last Reviewed Component' , ( ) => {
142- it ( 'should display last reviewed section' , ( ) => {
131+ it ( 'should display last reviewed section' , async ( ) => {
143132 renderMenuBar ( ) ;
144133
145134 expect ( screen . getByTestId ( 'last-reviewed-section' ) ) . toBeInTheDocument ( ) ;
146- expect ( screen . getByTestId ( 'patient-last-reviewed ' ) ) . toBeInTheDocument ( ) ;
135+ expect ( await screen . findByTestId ( 'patient-review-toggle ' ) ) . toBeInTheDocument ( ) ; // shows on patient fetch
147136 expect ( screen . getByText ( 'Last Reviewed' ) ) . toBeInTheDocument ( ) ;
148137 } , TEST_TIMEOUT_MS ) ;
149138 } ) ;
0 commit comments