Repository navigation
fix: land new account on initially opened room #92834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
marcochavezf
merged 15 commits into
Expensify:main
from
KJ21-ENG:KJ21-ENG/85242-focused-onboarding-deeplink-fix
Jul 17, 2026
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
d2ff7e8
Fix onboarding deep link preservation
KJ21-ENG 1201f47
Scope modal redirect idempotency guard
KJ21-ENG 8e5c8cb
Fix navigation guard redirect test types
KJ21-ENG 224c9ee
Merge remote-tracking branch 'upstream/main' into KJ21-ENG/85242-focu…
KJ21-ENG ed71a3d
Fix modal redirect reset typing after merge
KJ21-ENG 1430b6a
fix: preserve deeplinked report after onboarding
KJ21-ENG d316178
Merge remote-tracking branch 'upstream/main' into KJ21-ENG/85242-focu…
KJ21-ENG 2c5af5e
Merge remote-tracking branch 'upstream/main' into KJ21-ENG/85242-focu…
KJ21-ENG 172d2e0
Merge remote-tracking branch 'upstream/main' into KJ21-ENG/85242-focu…
KJ21-ENG ac7ef94
Format test files with oxfmt
KJ21-ENG b92d1b1
Address review feedback: clarify router comments, add concierge tests
KJ21-ENG d1937b6
Merge remote-tracking branch 'upstream/main' into KJ21-ENG/85242-focu…
KJ21-ENG 139315c
Merge branch 'main' into KJ21-ENG/85242-focused-onboarding-deeplink-fix
KJ21-ENG 90653e6
Merge remote-tracking branch 'upstream/main' into KJ21-ENG/85242-focu…
KJ21-ENG 2f81c04
Restore AuthScreensInitHandler.tsx to main version (undo local oxfmt …
KJ21-ENG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
199 changes: 199 additions & 0 deletions
199
tests/unit/Navigation/guards/handleNavigationGuardRedirect.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,199 @@ | ||
| import RootStackRouter from '@libs/Navigation/AppNavigator/createRootStackNavigator/RootStackRouter'; | ||
| import {evaluateGuards} from '@libs/Navigation/guards'; | ||
| import getAdaptedStateFromPath from '@libs/Navigation/helpers/getAdaptedStateFromPath'; | ||
|
|
||
| import NAVIGATORS from '@src/NAVIGATORS'; | ||
| import SCREENS from '@src/SCREENS'; | ||
|
|
||
| import type {ParamListBase, StackNavigationState} from '@react-navigation/native'; | ||
|
|
||
| jest.mock('@expensify/react-native-hybrid-app', () => ({ | ||
| __esModule: true, | ||
| default: { | ||
| isHybridApp: jest.fn(() => false), | ||
| shouldUseStaging: jest.fn(), | ||
| closeReactNativeApp: jest.fn(), | ||
| completeOnboarding: jest.fn(), | ||
| switchAccount: jest.fn(), | ||
| sendAuthToken: jest.fn(), | ||
| getHybridAppSettings: jest.fn(() => Promise.resolve(null)), | ||
| getInitialURL: jest.fn(() => Promise.resolve(null)), | ||
| onURLListenerAdded: jest.fn(), | ||
| signInToOldDot: jest.fn(), | ||
| signOutFromOldDot: jest.fn(), | ||
| startSignOut: jest.fn(), | ||
| cancelSignOut: jest.fn(), | ||
| clearOldDotAfterSignOut: jest.fn(), | ||
| }, | ||
| })); | ||
|
|
||
| jest.mock('@libs/Navigation/guards', () => ({ | ||
| __esModule: true, | ||
| createGuardContext: jest.fn(() => ({ | ||
| isAuthenticated: true, | ||
| isLoading: false, | ||
| currentUrl: '', | ||
| })), | ||
| evaluateGuards: jest.fn(() => ({type: 'ALLOW'})), | ||
| registerGuard: jest.fn(), | ||
| clearGuards: jest.fn(), | ||
| getRegisteredGuards: jest.fn(() => []), | ||
| })); | ||
|
|
||
| jest.mock('@libs/Navigation/helpers/getAdaptedStateFromPath', () => ({ | ||
| __esModule: true, | ||
| default: jest.fn(), | ||
| })); | ||
|
|
||
| const mockedEvaluateGuards = jest.mocked(evaluateGuards); | ||
| const mockedGetAdaptedStateFromPath = jest.mocked(getAdaptedStateFromPath); | ||
|
|
||
| const routeNames = [ | ||
| NAVIGATORS.TAB_NAVIGATOR, | ||
| NAVIGATORS.REPORTS_SPLIT_NAVIGATOR, | ||
| NAVIGATORS.RIGHT_MODAL_NAVIGATOR, | ||
| NAVIGATORS.ONBOARDING_MODAL_NAVIGATOR, | ||
| NAVIGATORS.SETTINGS_SPLIT_NAVIGATOR, | ||
| SCREENS.CONCIERGE, | ||
| SCREENS.HOME, | ||
| SCREENS.REPORT, | ||
| ]; | ||
|
|
||
| type StackRoute = StackNavigationState<ParamListBase>['routes'][number]; | ||
|
|
||
| function createState(routes: StackRoute[], index = routes.length - 1): StackNavigationState<ParamListBase> { | ||
| return { | ||
| key: 'root', | ||
| index, | ||
| routeNames, | ||
| routes, | ||
| stale: false, | ||
| type: 'stack', | ||
| preloadedRoutes: [], | ||
| }; | ||
| } | ||
|
|
||
| describe('handleNavigationGuards REDIRECT stack preservation', () => { | ||
| const router = RootStackRouter({}); | ||
| const configOptions = { | ||
| routeNames, | ||
| routeParamList: {} as ParamListBase, | ||
| routeGetIdList: {} as Record<string, ((params: Record<string, unknown>) => string) | undefined>, | ||
| }; | ||
| const action = {type: 'NAVIGATE' as const, payload: {name: NAVIGATORS.TAB_NAVIGATOR}}; | ||
| const onboardingRedirectState = { | ||
| routes: [ | ||
| {key: 'home', name: NAVIGATORS.TAB_NAVIGATOR}, | ||
| {key: 'onboarding', name: NAVIGATORS.ONBOARDING_MODAL_NAVIGATOR}, | ||
| ], | ||
| }; | ||
|
|
||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| mockedEvaluateGuards.mockReturnValue({type: 'REDIRECT', route: 'onboarding/work-email'}); | ||
| mockedGetAdaptedStateFromPath.mockReturnValue(onboardingRedirectState); | ||
| }); | ||
|
|
||
| it('drops the SignIn right modal before preserving a deep-linked report under onboarding', () => { | ||
| const state = createState([ | ||
| {key: 'report', name: NAVIGATORS.REPORTS_SPLIT_NAVIGATOR}, | ||
| {key: 'sign-in-rhp', name: NAVIGATORS.RIGHT_MODAL_NAVIGATOR}, | ||
| ]); | ||
|
|
||
| const result = router.getStateForAction(state, action, configOptions); | ||
|
|
||
| expect(result?.routes.map((route) => route.name)).toEqual([NAVIGATORS.REPORTS_SPLIT_NAVIGATOR, NAVIGATORS.ONBOARDING_MODAL_NAVIGATOR]); | ||
| expect(result?.index).toBe(1); | ||
| }); | ||
|
|
||
| it('falls back to the default onboarding redirect state when no fullscreen route survives', () => { | ||
| const state = createState([{key: 'concierge', name: SCREENS.CONCIERGE}]); | ||
|
|
||
| const result = router.getStateForAction(state, action, configOptions); | ||
|
|
||
| expect(result?.routes.map((route) => route.name)).toEqual([NAVIGATORS.TAB_NAVIGATOR, NAVIGATORS.ONBOARDING_MODAL_NAVIGATOR]); | ||
| expect(result?.index).toBe(1); | ||
| }); | ||
|
|
||
| it('keeps non-onboarding redirects as full state replacements', () => { | ||
| const state = createState([{key: 'report', name: NAVIGATORS.REPORTS_SPLIT_NAVIGATOR}]); | ||
| mockedEvaluateGuards.mockReturnValue({type: 'REDIRECT', route: 'settings'}); | ||
| mockedGetAdaptedStateFromPath.mockReturnValue({ | ||
| routes: [{key: 'settings', name: NAVIGATORS.SETTINGS_SPLIT_NAVIGATOR}], | ||
| }); | ||
|
|
||
| const result = router.getStateForAction(state, action, configOptions); | ||
|
|
||
| expect(result?.routes.map((route) => route.name)).toEqual([NAVIGATORS.SETTINGS_SPLIT_NAVIGATOR]); | ||
| expect(result?.index).toBe(0); | ||
| }); | ||
|
|
||
| it('does not suppress HOME redirects when TabNavigator is already focused on another tab', () => { | ||
| const state = createState([ | ||
| { | ||
| key: 'tabs', | ||
| name: NAVIGATORS.TAB_NAVIGATOR, | ||
| state: { | ||
| key: 'tabs-state', | ||
| index: 1, | ||
| routeNames: [SCREENS.HOME, NAVIGATORS.REPORTS_SPLIT_NAVIGATOR], | ||
| routes: [ | ||
| {key: 'home', name: SCREENS.HOME}, | ||
| { | ||
| key: 'reports', | ||
| name: NAVIGATORS.REPORTS_SPLIT_NAVIGATOR, | ||
| state: { | ||
| key: 'reports-state', | ||
| index: 0, | ||
| routeNames: [SCREENS.REPORT], | ||
| routes: [{key: 'report', name: SCREENS.REPORT, params: {reportID: '7075912447943023'}}], | ||
| stale: false, | ||
| type: 'stack', | ||
| }, | ||
| }, | ||
| ], | ||
| stale: false, | ||
| type: 'tab', | ||
| }, | ||
| }, | ||
| ]); | ||
| mockedEvaluateGuards.mockReturnValue({type: 'REDIRECT', route: 'home'}); | ||
| mockedGetAdaptedStateFromPath.mockReturnValue({ | ||
| routes: [ | ||
| { | ||
| key: 'tabs-home', | ||
| name: NAVIGATORS.TAB_NAVIGATOR, | ||
| state: { | ||
| key: 'tabs-home-state', | ||
| index: 0, | ||
| routeNames: [SCREENS.HOME, NAVIGATORS.REPORTS_SPLIT_NAVIGATOR], | ||
| routes: [{key: 'home', name: SCREENS.HOME}], | ||
| type: 'tab', | ||
| }, | ||
| }, | ||
| ], | ||
| }); | ||
|
|
||
| const result = router.getStateForAction(state, action, configOptions); | ||
|
|
||
| expect(result).not.toBe(state); | ||
| expect(result?.routes).toHaveLength(1); | ||
| expect(result?.routes.at(0)?.name).toBe(NAVIGATORS.TAB_NAVIGATOR); | ||
| expect(result?.routes.at(0)?.state?.index).toBe(0); | ||
| expect(result?.routes.at(0)?.state?.routes.at(0)?.name).toBe(SCREENS.HOME); | ||
| }); | ||
|
|
||
| it('returns the current state when the redirect target is already focused', () => { | ||
| const state = createState( | ||
| [ | ||
| {key: 'home', name: NAVIGATORS.TAB_NAVIGATOR}, | ||
| {key: 'onboarding', name: NAVIGATORS.ONBOARDING_MODAL_NAVIGATOR}, | ||
| ], | ||
| 1, | ||
| ); | ||
|
|
||
| const result = router.getStateForAction(state, action, configOptions); | ||
|
|
||
| expect(result).toBe(state); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.