@@ -581,4 +581,59 @@ describe('OnboardingWorkEmailValidation Page', () => {
581581 unmount ( ) ;
582582 await waitForBatchedUpdatesWithAct ( ) ;
583583 } ) ;
584+
585+ it ( 'should display specific error message when ONBOARDING_ERROR_MESSAGE is set' , async ( ) => {
586+ await TestHelper . signInWithTestUser ( ) ;
587+
588+ const specificErrorMessage = 'some extraordinarily specific error has occurred!' ;
589+
590+ await act ( async ( ) => {
591+ await Onyx . merge ( ONYXKEYS . NVP_ONBOARDING , {
592+ hasCompletedGuidedSetupFlow : false ,
593+ shouldValidate : true ,
594+ isMergingAccountBlocked : true ,
595+ } ) ;
596+ await Onyx . merge ( ONYXKEYS . FORMS . ONBOARDING_WORK_EMAIL_FORM , {
597+ onboardingWorkEmail : 'test@company.com' ,
598+ } ) ;
599+ await Onyx . merge ( ONYXKEYS . ONBOARDING_ERROR_MESSAGE , specificErrorMessage ) ;
600+ } ) ;
601+
602+ const { unmount} = renderOnboardingWorkEmailValidationPage ( SCREENS . ONBOARDING . WORK_EMAIL_VALIDATION , { backTo : '' } ) ;
603+
604+ await waitForBatchedUpdatesWithAct ( ) ;
605+
606+ await waitFor ( ( ) => {
607+ expect ( screen . getByText ( specificErrorMessage ) ) . toBeOnTheScreen ( ) ;
608+ } ) ;
609+
610+ unmount ( ) ;
611+ await waitForBatchedUpdatesWithAct ( ) ;
612+ } ) ;
613+
614+ it ( 'should fallback to generic error message when ONBOARDING_ERROR_MESSAGE is not set' , async ( ) => {
615+ await TestHelper . signInWithTestUser ( ) ;
616+
617+ await act ( async ( ) => {
618+ await Onyx . merge ( ONYXKEYS . NVP_ONBOARDING , {
619+ hasCompletedGuidedSetupFlow : false ,
620+ shouldValidate : true ,
621+ isMergingAccountBlocked : true ,
622+ } ) ;
623+ await Onyx . merge ( ONYXKEYS . FORMS . ONBOARDING_WORK_EMAIL_FORM , {
624+ onboardingWorkEmail : workEmail ,
625+ } ) ;
626+ } ) ;
627+
628+ const { unmount} = renderOnboardingWorkEmailValidationPage ( SCREENS . ONBOARDING . WORK_EMAIL_VALIDATION , { backTo : '' } ) ;
629+
630+ await waitForBatchedUpdatesWithAct ( ) ;
631+
632+ await waitFor ( ( ) => {
633+ expect ( screen . getByText ( translateLocal ( 'onboarding.mergeBlockScreen.subtitle' , { workEmail} ) ) ) . toBeOnTheScreen ( ) ;
634+ } ) ;
635+
636+ unmount ( ) ;
637+ await waitForBatchedUpdatesWithAct ( ) ;
638+ } ) ;
584639} ) ;
0 commit comments