Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libs/Navigation/AppNavigator/AuthScreens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ function AuthScreens() {
component={FeatureTrainingModalNavigator}
listeners={modalScreenListeners}
/>
{isOnboardingCompleted === false && (
{isOnboardingCompleted === false && !Navigation.isValidateLoginFlow() && (
<RootStack.Screen
name={NAVIGATORS.ONBOARDING_MODAL_NAVIGATOR}
options={{...rootNavigatorScreenOptions.basicModalNavigator, gestureEnabled: false}}
Expand Down
7 changes: 7 additions & 0 deletions src/libs/Navigation/Navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,12 @@ function isOnboardingFlow() {
return isOnboardingFlowName(currentFocusedRoute?.name);
}

function isValidateLoginFlow() {
const state = navigationRef.getRootState();
const currentFocusedRoute = findFocusedRoute(state);
return currentFocusedRoute?.name === SCREENS.VALIDATE_LOGIN;
}

function clearPreloadedRoutes() {
const rootStateWithoutPreloadedRoutes = {...navigationRef.getRootState(), preloadedRoutes: []} as NavigationState;
navigationRef.reset(rootStateWithoutPreloadedRoutes);
Expand Down Expand Up @@ -716,6 +722,7 @@ export default {
clearPreloadedRoutes,
onModalDismissedOnce,
fireModalDismissed,
isValidateLoginFlow,
};

export {navigationRef};
43 changes: 43 additions & 0 deletions tests/navigation/NavigationTests.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import {render} from '@testing-library/react-native';
import React from 'react';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import getIsNarrowLayout from '@libs/getIsNarrowLayout';
import Navigation from '@libs/Navigation/Navigation';
import CONST from '@src/CONST';
import TestNavigationContainer from '../utils/TestNavigationContainer';

jest.mock('@hooks/useResponsiveLayout', () => jest.fn());
jest.mock('@libs/getIsNarrowLayout', () => jest.fn());

jest.mock('@pages/home/sidebar/NavigationTabBarAvatar');
jest.mock('@src/components/Navigation/TopLevelNavigationTabBar');

const mockedGetIsNarrowLayout = getIsNarrowLayout as jest.MockedFunction<typeof getIsNarrowLayout>;
const mockedUseResponsiveLayout = useResponsiveLayout as jest.MockedFunction<typeof useResponsiveLayout>;

describe('Navigation', () => {
beforeEach(() => {
mockedGetIsNarrowLayout.mockReturnValue(false);
mockedUseResponsiveLayout.mockReturnValue({...CONST.NAVIGATION_TESTS.DEFAULT_USE_RESPONSIVE_LAYOUT_VALUE, shouldUseNarrowLayout: false});
});

describe('isValidateLoginFlow', () => {
it('should return true when the current focused route is the validate login screen', () => {
// Given the navigation state with the validate login screen
render(
<TestNavigationContainer
initialState={{
index: 0,
routes: [
{
name: 'ValidateLogin',
},
],
}}
/>,
);

expect(Navigation.isValidateLoginFlow()).toBe(true);
});
});
});
4 changes: 4 additions & 0 deletions tests/utils/TestNavigationContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ function TestNavigationContainer({initialState}: TestNavigationContainerProps) {
name={NAVIGATORS.SEARCH_FULLSCREEN_NAVIGATOR}
component={TestSearchFullscreenNavigator}
/>
<RootStack.Screen
name={SCREENS.VALIDATE_LOGIN}
component={getEmptyComponent()}
/>
</RootStack.Navigator>
</NavigationContainer>
);
Expand Down
Loading