diff --git a/__mocks__/react-native-permissions.ts b/__mocks__/react-native-permissions.ts index 9ee11ea473f55..4bf9f434f9efb 100644 --- a/__mocks__/react-native-permissions.ts +++ b/__mocks__/react-native-permissions.ts @@ -1,6 +1,14 @@ -import {PERMISSIONS, RESULTS} from 'react-native-permissions/dist/commonjs/permissions'; +import {PERMISSIONS} from 'react-native-permissions/dist/commonjs/permissions'; import type {ValueOf} from 'type-fest'; +const RESULTS = { + UNAVAILABLE: 'unavailable', + BLOCKED: 'blocked', + DENIED: 'denied', + GRANTED: 'granted', + LIMITED: 'limited', +} as const; + type Results = ValueOf; type ResultsCollection = Record; type NotificationSettings = Record; @@ -8,8 +16,8 @@ type Notification = {status: Results; settings: NotificationSettings}; const openLimitedPhotoLibraryPicker: jest.Mock = jest.fn(() => {}); const openSettings: jest.Mock = jest.fn(() => {}); -const check = jest.fn(() => RESULTS.GRANTED as string); -const request = jest.fn(() => RESULTS.GRANTED as string); +const check = jest.fn(() => Promise.resolve(RESULTS.GRANTED as string)); +const request = jest.fn(() => Promise.resolve(RESULTS.GRANTED as string)); const checkLocationAccuracy: jest.Mock = jest.fn(() => 'full'); const requestLocationAccuracy: jest.Mock = jest.fn(() => 'full'); diff --git a/tests/ui/SessionTest.tsx b/tests/ui/SessionTest.tsx index 6f3b64b28b4a5..f74ec76992b6c 100644 --- a/tests/ui/SessionTest.tsx +++ b/tests/ui/SessionTest.tsx @@ -15,7 +15,6 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import {createRandomReport} from '../utils/collections/reports'; import * as TestHelper from '../utils/TestHelper'; -import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; import waitForBatchedUpdatesWithAct from '../utils/waitForBatchedUpdatesWithAct'; import waitForNetworkPromises from '../utils/waitForNetworkPromises'; @@ -117,7 +116,7 @@ describe('Deep linking', () => { Linking.setInitialURL(url); const {unmount} = render(); - await waitForBatchedUpdates(); + await waitForBatchedUpdatesWithAct(); expect(lastVisitedPath).toBe(`/${ROUTES.REPORT}/${report.reportID}`); diff --git a/tests/ui/components/IOURequestStepConfirmationPageTest.tsx b/tests/ui/components/IOURequestStepConfirmationPageTest.tsx index 8103ed3f50f37..e6c3c14731431 100644 --- a/tests/ui/components/IOURequestStepConfirmationPageTest.tsx +++ b/tests/ui/components/IOURequestStepConfirmationPageTest.tsx @@ -98,6 +98,7 @@ jest.mock('@libs/Navigation/Navigation', () => { navigate: jest.fn(), goBack: jest.fn(), dismissModalWithReport: jest.fn(), + setNavigationActionToMicrotaskQueue: jest.fn((callback: () => void) => callback()), navigationRef: mockRef, }; }); @@ -1263,6 +1264,7 @@ describe('IOURequestStepConfirmationPageTest', () => { await waitForBatchedUpdatesWithAct(); fireEvent.press(await screen.findByText(/^Create .*expense/i)); + await waitForBatchedUpdatesWithAct(); // Unreported distance requests should skip createDistanceRequest and use requestMoney expect(IOU.createDistanceRequest).not.toHaveBeenCalled();