From 089761d354ff84c16fc40ba1b5d6dfbd4e4f8edb Mon Sep 17 00:00:00 2001 From: "mkhutornyi (via MelvinBot)" Date: Tue, 14 Jul 2026 13:32:36 +0000 Subject: [PATCH 1/3] Fix: render SubmitPlanWelcomeModal test inside NavigationContainer Co-authored-by: mkhutornyi --- .../components/SubmitPlanWelcomeModalTest.tsx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/ui/components/SubmitPlanWelcomeModalTest.tsx b/tests/ui/components/SubmitPlanWelcomeModalTest.tsx index 79bb77bb0e6e..789dd50de28e 100644 --- a/tests/ui/components/SubmitPlanWelcomeModalTest.tsx +++ b/tests/ui/components/SubmitPlanWelcomeModalTest.tsx @@ -8,6 +8,8 @@ import ONYXKEYS from '@src/ONYXKEYS'; import type {ViewProps} from 'react-native'; import type ReactNative from 'react-native'; +import {NavigationContainer} from '@react-navigation/native'; +import {createStackNavigator} from '@react-navigation/stack'; import React from 'react'; import Onyx from 'react-native-onyx'; @@ -48,6 +50,20 @@ jest.mock('@components/ImageSVG', () => { return (props: ViewProps) => ; }); +const Stack = createStackNavigator(); + +// The modal renders FormAlertWithSubmitButton, which uses usePressLoading -> useFocusEffect. That hook +// needs a navigation context, so the modal must be rendered inside a NavigationContainer/screen. +function withNavigation(ui: React.ReactElement): React.ReactElement { + return ( + + + {() => ui} + + + ); +} + describe('SubmitPlanWelcomeModal', () => { beforeAll(() => { Onyx.init({keys: ONYXKEYS}); @@ -63,7 +79,7 @@ describe('SubmitPlanWelcomeModal', () => { function renderModal() { return render( - + {withNavigation()} , ); } From bba2ef9d9cc4f5ad12580861cfa12856a552ea53 Mon Sep 17 00:00:00 2001 From: "mkhutornyi (via MelvinBot)" Date: Tue, 14 Jul 2026 13:44:31 +0000 Subject: [PATCH 2/3] Apply oxfmt formatting to SubmitPlanWelcomeModalTest Co-authored-by: mkhutornyi --- tests/ui/components/SubmitPlanWelcomeModalTest.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/ui/components/SubmitPlanWelcomeModalTest.tsx b/tests/ui/components/SubmitPlanWelcomeModalTest.tsx index 789dd50de28e..7d8d2ba6658e 100644 --- a/tests/ui/components/SubmitPlanWelcomeModalTest.tsx +++ b/tests/ui/components/SubmitPlanWelcomeModalTest.tsx @@ -77,11 +77,7 @@ describe('SubmitPlanWelcomeModal', () => { }); function renderModal() { - return render( - - {withNavigation()} - , - ); + return render({withNavigation()}); } it('creates a Submit workspace with the current user name when "Get the free plan" is pressed', () => { From 610209fd1b93ca61a6ee08f22fedc4bf5859eea2 Mon Sep 17 00:00:00 2001 From: "mkhutornyi (via MelvinBot)" Date: Tue, 14 Jul 2026 13:47:07 +0000 Subject: [PATCH 3/3] Fix failing tests: await deferred submit + bucket new NVP key in export coverage Co-authored-by: mkhutornyi --- src/libs/ExportOnyxState/common.ts | 1 + tests/ui/components/SubmitPlanWelcomeModalTest.tsx | 13 +++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/libs/ExportOnyxState/common.ts b/src/libs/ExportOnyxState/common.ts index ace445635726..cf341eacc182 100644 --- a/src/libs/ExportOnyxState/common.ts +++ b/src/libs/ExportOnyxState/common.ts @@ -245,6 +245,7 @@ const safeOnyxKeys = new Set([ ONYXKEYS.NVP_SEARCH_SIDEBAR, ONYXKEYS.NVP_SEEN_NEW_USER_MODAL, ONYXKEYS.NVP_SIDE_PANEL, + ONYXKEYS.NVP_SUBMIT_MIGRATION_MODAL_SHOWN, ONYXKEYS.NVP_TRY_FOCUS_MODE, ONYXKEYS.NVP_TRY_NEW_DOT, ONYXKEYS.ONBOARDING_ADMINS_CHAT_REPORT_ID, diff --git a/tests/ui/components/SubmitPlanWelcomeModalTest.tsx b/tests/ui/components/SubmitPlanWelcomeModalTest.tsx index 789dd50de28e..d59ee8f5845c 100644 --- a/tests/ui/components/SubmitPlanWelcomeModalTest.tsx +++ b/tests/ui/components/SubmitPlanWelcomeModalTest.tsx @@ -1,4 +1,4 @@ -import {fireEvent, render, screen} from '@testing-library/react-native'; +import {fireEvent, render, screen, waitFor} from '@testing-library/react-native'; import OnyxListItemProvider from '@components/OnyxListItemProvider'; import SubmitPlanWelcomeModal from '@components/SubmitPlanWelcomeModal'; @@ -77,19 +77,16 @@ describe('SubmitPlanWelcomeModal', () => { }); function renderModal() { - return render( - - {withNavigation()} - , - ); + return render({withNavigation()}); } - it('creates a Submit workspace with the current user name when "Get the free plan" is pressed', () => { + it('creates a Submit workspace with the current user name when "Get the free plan" is pressed', async () => { renderModal(); fireEvent.press(screen.getByText('submitPlanWelcomeModal.confirmText')); - expect(mockAutoCreateSubmitWorkspace).toHaveBeenCalledWith('John', 'Doe', false); + // FormAlertWithSubmitButton runs onSubmit through usePressLoading, which defers the work by one macrotask, so wait for the call. + await waitFor(() => expect(mockAutoCreateSubmitWorkspace).toHaveBeenCalledWith('John', 'Doe', false)); }); it('navigates back (dismissing the modal) when "No thanks" is pressed', () => {