diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 082376430ed8..dc13e0e8b3a9 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -2533,6 +2533,7 @@ function buildOnyxDataForTrackExpense({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport.reportID}`, value: { + lastReadTime: actionableTrackExpenseWhisper.created, lastVisibleActionCreated: actionableTrackExpenseWhisper.created, lastMessageText: CONST.ACTIONABLE_TRACK_EXPENSE_WHISPER_MESSAGE, }, diff --git a/tests/README.md b/tests/README.md index edf0cec9b295..9ef720fd3671 100644 --- a/tests/README.md +++ b/tests/README.md @@ -7,7 +7,7 @@ - Much of the logic in the app is asynchronous in nature. [`react-native-onyx`](https://github.com/expensify/react-native-onyx) writes data async before updating subscribers. - [Actions](https://github.com/Expensify/App#actions) do not typically return a `Promise` and therefore can't always be "awaited" before running an assertion. - To test a result after some asynchronous code has run we can use [`Onyx.connect()`](https://github.com/Expensify/react-native-onyx/blob/2c94a94e51fab20330f7bd5381b72ea6c25553d9/lib/Onyx.js#L217-L231) and the helper method [`waitForBatchedUpdates()`](https://github.com/Expensify/ReactNativeChat/blob/ca2fa88a5789b82463d35eddc3d57f70a7286868/tests/utils/waitForBatchedUpdates.js#L1-L9) which returns a `Promise` and will ensure that all other `Promises` have finished running before resolving. -- **Important Note:** When writing any asynchronous Jest test it's very important that your test itself **return a `Promise`**. +- **Important Note:** When writing any asynchronous Jest test it's very important that your test itself **return a `Promise`**. In hooks like BeforeEach, BeforeAll, AfterAll, etc., you also need to return a promise or use async/await if they perform any asynchronous calls. ## Mocking Network Requests diff --git a/tests/ui/UnreadIndicatorsTest.tsx b/tests/ui/UnreadIndicatorsTest.tsx index 627fcb0bf164..8a461d9cacb6 100644 --- a/tests/ui/UnreadIndicatorsTest.tsx +++ b/tests/ui/UnreadIndicatorsTest.tsx @@ -187,10 +187,12 @@ describe('Unread Indicators', () => { beforeEach(() => { jest.clearAllMocks(); - Onyx.clear(); + global.fetch = TestHelper.getGlobalFetchMock(); // Unsubscribe to pusher channels PusherHelper.teardown(); + + return Onyx.clear().then(waitForBatchedUpdates); }); it('Display bold in the LHN for unread chat and new line indicator above the chat message when we navigate to it', () =>