From 8bc926d74860f69daf2862cf563f58aa6355b31e Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Fri, 10 Jan 2025 09:54:04 +0100 Subject: [PATCH] Refactor old names in nav tests --- tests/navigation/GoBackTests.tsx | 10 +++++----- tests/navigation/NavigateTests.tsx | 10 +++++----- tests/navigation/SwitchPolicyIDTests.tsx | 18 +++++++++--------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/tests/navigation/GoBackTests.tsx b/tests/navigation/GoBackTests.tsx index 347cde2a232a..08483f6d01fd 100644 --- a/tests/navigation/GoBackTests.tsx +++ b/tests/navigation/GoBackTests.tsx @@ -4,7 +4,7 @@ import {act, render} from '@testing-library/react-native'; import React from 'react'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import getIsNarrowLayout from '@libs/getIsNarrowLayout'; -import createResponsiveStackNavigator from '@libs/Navigation/AppNavigator/createResponsiveStackNavigator'; +import createRootStackNavigator from '@libs/Navigation/AppNavigator/createRootStackNavigator'; import createSplitNavigator from '@libs/Navigation/AppNavigator/createSplitNavigator'; import Navigation from '@libs/Navigation/Navigation'; import navigationRef from '@libs/Navigation/navigationRef'; @@ -14,7 +14,7 @@ import NAVIGATORS from '@src/NAVIGATORS'; import ROUTES from '@src/ROUTES'; import SCREENS from '@src/SCREENS'; -const RootStack = createResponsiveStackNavigator(); +const RootStack = createRootStackNavigator(); const ReportsSplit = createSplitNavigator(); const SettingsSplit = createSplitNavigator(); @@ -90,7 +90,7 @@ function TestNavigationContainer({initialState}: TestNavigationContainerProps) { component={SettingsSplitNavigator} /> jest.fn()} /> @@ -340,7 +340,7 @@ describe('Go back on the narrow layout', () => { }, }, { - name: SCREENS.SEARCH.CENTRAL_PANE, + name: SCREENS.SEARCH.ROOT, }, ], }} @@ -349,7 +349,7 @@ describe('Go back on the narrow layout', () => { const rootStateBeforeGoBack = navigationRef.current?.getRootState(); expect(rootStateBeforeGoBack?.index).toBe(2); - expect(rootStateBeforeGoBack?.routes.at(-1)?.name).toBe(SCREENS.SEARCH.CENTRAL_PANE); + expect(rootStateBeforeGoBack?.routes.at(-1)?.name).toBe(SCREENS.SEARCH.ROOT); // When go back to the page present in the split navigator that is more than 1 route away act(() => { diff --git a/tests/navigation/NavigateTests.tsx b/tests/navigation/NavigateTests.tsx index 23386739bbde..f4bc3be4a001 100644 --- a/tests/navigation/NavigateTests.tsx +++ b/tests/navigation/NavigateTests.tsx @@ -4,7 +4,7 @@ import {act, render} from '@testing-library/react-native'; import React from 'react'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import getIsNarrowLayout from '@libs/getIsNarrowLayout'; -import createResponsiveStackNavigator from '@libs/Navigation/AppNavigator/createResponsiveStackNavigator'; +import createRootStackNavigator from '@libs/Navigation/AppNavigator/createRootStackNavigator'; import createSplitNavigator from '@libs/Navigation/AppNavigator/createSplitNavigator'; import Navigation from '@libs/Navigation/Navigation'; import navigationRef from '@libs/Navigation/navigationRef'; @@ -14,7 +14,7 @@ import NAVIGATORS from '@src/NAVIGATORS'; import ROUTES from '@src/ROUTES'; import SCREENS from '@src/SCREENS'; -const RootStack = createResponsiveStackNavigator(); +const RootStack = createRootStackNavigator(); const ReportsSplit = createSplitNavigator(); const SettingsSplit = createSplitNavigator(); @@ -90,7 +90,7 @@ function TestNavigationContainer({initialState}: TestNavigationContainerProps) { component={SettingsSplitNavigator} /> jest.fn()} /> @@ -233,7 +233,7 @@ describe('Navigate', () => { index: 0, routes: [ { - name: SCREENS.SEARCH.CENTRAL_PANE, + name: SCREENS.SEARCH.ROOT, params: { q: 'type:expense status:all sortBy:date sortOrder:desc policyID:1', }, @@ -246,7 +246,7 @@ describe('Navigate', () => { const rootStateBeforeNavigate = navigationRef.current?.getRootState(); const lastSplitBeforeNavigate = rootStateBeforeNavigate?.routes.at(-1); expect(rootStateBeforeNavigate?.index).toBe(0); - expect(lastSplitBeforeNavigate?.name).toBe(SCREENS.SEARCH.CENTRAL_PANE); + expect(lastSplitBeforeNavigate?.name).toBe(SCREENS.SEARCH.ROOT); // When navigate to the Home page when the active workspace is set act(() => { diff --git a/tests/navigation/SwitchPolicyIDTests.tsx b/tests/navigation/SwitchPolicyIDTests.tsx index 50778b8fe698..b041f3046899 100644 --- a/tests/navigation/SwitchPolicyIDTests.tsx +++ b/tests/navigation/SwitchPolicyIDTests.tsx @@ -4,7 +4,7 @@ import {act, render} from '@testing-library/react-native'; import React from 'react'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import getIsNarrowLayout from '@libs/getIsNarrowLayout'; -import createResponsiveStackNavigator from '@libs/Navigation/AppNavigator/createResponsiveStackNavigator'; +import createRootStackNavigator from '@libs/Navigation/AppNavigator/createRootStackNavigator'; import createSplitNavigator from '@libs/Navigation/AppNavigator/createSplitNavigator'; import navigationRef from '@libs/Navigation/navigationRef'; import type {AuthScreensParamList, ReportsSplitNavigatorParamList} from '@libs/Navigation/types'; @@ -13,7 +13,7 @@ import CONST from '@src/CONST'; import NAVIGATORS from '@src/NAVIGATORS'; import SCREENS from '@src/SCREENS'; -const RootStack = createResponsiveStackNavigator(); +const RootStack = createRootStackNavigator(); const ReportsSplit = createSplitNavigator(); jest.mock('@hooks/useResponsiveLayout', () => jest.fn()); @@ -57,7 +57,7 @@ function TestNavigationContainer({initialState}: TestNavigationContainerProps) { component={ReportsSplitNavigator} /> jest.fn()} /> @@ -126,7 +126,7 @@ describe('Switch policy ID', () => { index: 0, routes: [ { - name: SCREENS.SEARCH.CENTRAL_PANE, + name: SCREENS.SEARCH.ROOT, params: { q: 'type:expense status:all sortBy:date sortOrder:desc', }, @@ -139,7 +139,7 @@ describe('Switch policy ID', () => { const rootStateBeforeSwitch = navigationRef.current?.getRootState(); expect(rootStateBeforeSwitch?.index).toBe(0); const lastRouteBeforeSwitch = rootStateBeforeSwitch?.routes?.at(-1); - expect(lastRouteBeforeSwitch?.name).toBe(SCREENS.SEARCH.CENTRAL_PANE); + expect(lastRouteBeforeSwitch?.name).toBe(SCREENS.SEARCH.ROOT); expect(lastRouteBeforeSwitch?.params).toMatchObject({q: 'type:expense status:all sortBy:date sortOrder:desc'}); // When switch to the specific policy from the Search page @@ -151,7 +151,7 @@ describe('Switch policy ID', () => { const rootStateAfterSwitch = navigationRef.current?.getRootState(); expect(rootStateAfterSwitch?.index).toBe(1); const lastRouteAfterSwitch = rootStateAfterSwitch?.routes?.at(-1); - expect(lastRouteAfterSwitch?.name).toBe(SCREENS.SEARCH.CENTRAL_PANE); + expect(lastRouteAfterSwitch?.name).toBe(SCREENS.SEARCH.ROOT); expect(lastRouteAfterSwitch?.params).toMatchObject({q: 'type:expense status:all sortBy:date sortOrder:desc policyID:1'}); }); }); @@ -212,7 +212,7 @@ describe('Switch policy ID', () => { index: 0, routes: [ { - name: SCREENS.SEARCH.CENTRAL_PANE, + name: SCREENS.SEARCH.ROOT, params: { q: 'type:expense status:all sortBy:date sortOrder:desc policyID:1', }, @@ -225,7 +225,7 @@ describe('Switch policy ID', () => { const rootStateBeforeSwitch = navigationRef.current?.getRootState(); expect(rootStateBeforeSwitch?.index).toBe(0); const lastRouteBeforeSwitch = rootStateBeforeSwitch?.routes?.at(-1); - expect(lastRouteBeforeSwitch?.name).toBe(SCREENS.SEARCH.CENTRAL_PANE); + expect(lastRouteBeforeSwitch?.name).toBe(SCREENS.SEARCH.ROOT); expect(lastRouteBeforeSwitch?.params).toMatchObject({q: 'type:expense status:all sortBy:date sortOrder:desc policyID:1'}); // When switch policy to the global from the Search page @@ -237,7 +237,7 @@ describe('Switch policy ID', () => { const rootStateAfterSwitch = navigationRef.current?.getRootState(); expect(rootStateAfterSwitch?.index).toBe(1); const lastRouteAfterSwitch = rootStateAfterSwitch?.routes?.at(-1); - expect(lastRouteAfterSwitch?.name).toBe(SCREENS.SEARCH.CENTRAL_PANE); + expect(lastRouteAfterSwitch?.name).toBe(SCREENS.SEARCH.ROOT); expect(lastRouteAfterSwitch?.params).toMatchObject({q: 'type:expense status:all sortBy:date sortOrder:desc'}); }); });