diff --git a/src/components/BlockingViews/FullPageNotFoundView.tsx b/src/components/BlockingViews/FullPageNotFoundView.tsx index 029b79b432cf..ad1a659e6d9f 100644 --- a/src/components/BlockingViews/FullPageNotFoundView.tsx +++ b/src/components/BlockingViews/FullPageNotFoundView.tsx @@ -11,6 +11,9 @@ import BlockingView from './BlockingView'; import ForceFullScreenView from './ForceFullScreenView'; type FullPageNotFoundViewProps = { + /** TestID for test */ + testID?: string; + /** Child elements */ children?: React.ReactNode; @@ -44,6 +47,7 @@ type FullPageNotFoundViewProps = { // eslint-disable-next-line rulesdir/no-negated-variables function FullPageNotFoundView({ + testID, children = null, shouldShow = false, titleKey = 'notFound.notHere', @@ -65,7 +69,10 @@ function FullPageNotFoundView({ onBackButtonPress={onBackButtonPress} shouldShowBackButton={shouldShowBackButton} /> - + { Navigation.goBack(); }} > - + { if (isUserClickedSignIn) { @@ -49,10 +50,6 @@ function ValidateLoginPage({ return; } - if (!ValidationUtils.isValidValidateCode(validateCode)) { - return; - } - // The user has initiated the sign in process on the same browser, in another tab. Session.signInWithValidateCode(Number(accountID), validateCode); @@ -83,7 +80,7 @@ function ValidateLoginPage({ {autoAuthStateWithDefault === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN && is2FARequired && !isSignedIn && !!login && } {autoAuthStateWithDefault === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN && isSignedIn && !exitTo && !!login && } {/* If session.autoAuthState isn't available yet, we use shouldStartSignInWithValidateCode to conditionally render the component instead of local autoAuthState which contains a default value of NOT_STARTED */} - {(!autoAuthState ? !shouldStartSignInWithValidateCode : autoAuthStateWithDefault === CONST.AUTO_AUTH_STATE.NOT_STARTED) && !exitTo && ( + {(!autoAuthState ? !shouldStartSignInWithValidateCode : autoAuthStateWithDefault === CONST.AUTO_AUTH_STATE.NOT_STARTED && !isNavigatingToExitTo) && ( (); + +const renderPage = (initialParams: PublicScreensParamList[typeof SCREENS.VALIDATE_LOGIN]) => { + return render( + + + + + , + ); +}; + +describe('ValidateLoginPage', () => { + beforeEach(() => { + jest.clearAllMocks(); + Onyx.clear(); + }); + + it('Should show not found view when the magic code is invalid and there is an exitTo param', async () => { + await Onyx.set(ONYXKEYS.SESSION, { + autoAuthState: CONST.AUTO_AUTH_STATE.NOT_STARTED, + }); + + renderPage({accountID: '1', validateCode: 'ABCDEF', exitTo: 'concierge'}); + + expect(screen.getByTestId('validate-code-not-found')).not.toBeNull(); + }); + + it('Should not show ValidateCodeModal when signed in and there is an exitTo param', async () => { + await Onyx.set(ONYXKEYS.SESSION, { + authToken: 'abcd', + autoAuthState: CONST.AUTO_AUTH_STATE.NOT_STARTED, + }); + + renderPage({accountID: '1', validateCode: '123456', exitTo: 'concierge'}); + + expect(screen.queryByTestId('validate-code')).toBeNull(); + }); +});