Skip to content
Merged
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
11 changes: 5 additions & 6 deletions tests/navigation/NavigateTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ const mockedGetIsNarrowLayout = jest.mocked(getIsNarrowLayout);
const mockedUseResponsiveLayout = jest.mocked(useResponsiveLayout);

/**
* Looks the Workspace navigator up by name rather than by a hardcoded index, so adding a tab to TAB_SCREENS
* doesn't silently shift the index and make these assertions read `undefined`.
* Looks the Tab and Workspace navigators up by name rather than by hardcoded indexes, so adding or reordering routes
* doesn't silently shift an index and make these assertions read `undefined`.
*/
function getWorkspaceNavigatorState() {
return navigationRef.current
?.getRootState()
.routes.at(0)
?.state?.routes.findLast((route) => route.name === NAVIGATORS.WORKSPACE_NAVIGATOR)?.state;
const tabNavigatorState = navigationRef.current?.getRootState().routes.findLast((route) => route.name === NAVIGATORS.TAB_NAVIGATOR)?.state;
return tabNavigatorState?.routes.findLast((route) => route.name === NAVIGATORS.WORKSPACE_NAVIGATOR)?.state;
}

describe('Navigate', () => {
Expand Down Expand Up @@ -283,6 +281,7 @@ describe('Navigate', () => {
{name: SCREENS.HOME},
{name: NAVIGATORS.REPORTS_SPLIT_NAVIGATOR},
{name: NAVIGATORS.SEARCH_FULLSCREEN_NAVIGATOR},
{name: SCREENS.INSIGHTS},
{name: NAVIGATORS.SETTINGS_SPLIT_NAVIGATOR},
{name: NAVIGATORS.WORKSPACE_NAVIGATOR},
],
Expand Down
Loading