From ba2419302e245868e3fa5d1605d467cff739e7c3 Mon Sep 17 00:00:00 2001 From: lorretheboy Date: Mon, 25 Aug 2025 23:25:27 +0800 Subject: [PATCH 1/3] fix: pagination flaky test --- tests/ui/PaginationTest.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/ui/PaginationTest.tsx b/tests/ui/PaginationTest.tsx index 2fcc9f1fabf4..8e484c89cd4a 100644 --- a/tests/ui/PaginationTest.tsx +++ b/tests/ui/PaginationTest.tsx @@ -12,6 +12,7 @@ import App from '@src/App'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {ReportAction} from '@src/types/onyx'; +import waitForNetworkPromises from 'tests/utils/waitForNetworkPromises'; import type {NativeNavigationMock} from '../../__mocks__/@react-navigation/native'; import PusherHelper from '../utils/PusherHelper'; import * as TestHelper from '../utils/TestHelper'; @@ -321,6 +322,8 @@ describe('Pagination', () => { await waitForBatchedUpdatesWithAct(); + await waitForNetworkPromises(); + // We now have 18 messages. 15 (MIN_INITIAL_REPORT_ACTION_COUNT) from the initial OpenReport and 3 from GetOlderActions. // GetOlderActions only returns 3 actions since it reaches id '1', which is the created action. expect(getReportActions()).toHaveLength(18); From 1b3e12db56a42807052529b7ff3653bfd83ef2e4 Mon Sep 17 00:00:00 2001 From: lorretheboy Date: Mon, 25 Aug 2025 23:29:01 +0800 Subject: [PATCH 2/3] fix: pagination flaky test --- tests/ui/PaginationTest.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/PaginationTest.tsx b/tests/ui/PaginationTest.tsx index 8e484c89cd4a..f4179494ef22 100644 --- a/tests/ui/PaginationTest.tsx +++ b/tests/ui/PaginationTest.tsx @@ -4,6 +4,7 @@ import {act, fireEvent, render, screen, waitFor, within} from '@testing-library/ import {addSeconds, format, subMinutes} from 'date-fns'; import React from 'react'; import Onyx from 'react-native-onyx'; +import waitForNetworkPromises from 'tests/utils/waitForNetworkPromises'; import {translateLocal} from '@libs/Localize'; import {waitForIdle} from '@libs/Network/SequentialQueue'; import {setSidebarLoaded} from '@userActions/App'; @@ -12,7 +13,6 @@ import App from '@src/App'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {ReportAction} from '@src/types/onyx'; -import waitForNetworkPromises from 'tests/utils/waitForNetworkPromises'; import type {NativeNavigationMock} from '../../__mocks__/@react-navigation/native'; import PusherHelper from '../utils/PusherHelper'; import * as TestHelper from '../utils/TestHelper'; From 51b457286c468b930fe52835ee10063d548f6300 Mon Sep 17 00:00:00 2001 From: lorretheboy Date: Mon, 25 Aug 2025 23:33:09 +0800 Subject: [PATCH 3/3] fix: pagination flaky test --- tests/ui/PaginationTest.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/ui/PaginationTest.tsx b/tests/ui/PaginationTest.tsx index f4179494ef22..071e631b339d 100644 --- a/tests/ui/PaginationTest.tsx +++ b/tests/ui/PaginationTest.tsx @@ -4,7 +4,6 @@ import {act, fireEvent, render, screen, waitFor, within} from '@testing-library/ import {addSeconds, format, subMinutes} from 'date-fns'; import React from 'react'; import Onyx from 'react-native-onyx'; -import waitForNetworkPromises from 'tests/utils/waitForNetworkPromises'; import {translateLocal} from '@libs/Localize'; import {waitForIdle} from '@libs/Network/SequentialQueue'; import {setSidebarLoaded} from '@userActions/App'; @@ -18,6 +17,7 @@ import PusherHelper from '../utils/PusherHelper'; import * as TestHelper from '../utils/TestHelper'; import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; import waitForBatchedUpdatesWithAct from '../utils/waitForBatchedUpdatesWithAct'; +import waitForNetworkPromises from '../utils/waitForNetworkPromises'; // We need a large timeout here as we are lazy loading React Navigation screens and this test is running against the entire mounted App jest.setTimeout(60000); @@ -320,8 +320,6 @@ describe('Pagination', () => { TestHelper.expectAPICommandToHaveBeenCalledWith('GetOlderActions', 0, {reportID: REPORT_ID, reportActionID: '4'}); TestHelper.expectAPICommandToHaveBeenCalled('GetNewerActions', 0); - await waitForBatchedUpdatesWithAct(); - await waitForNetworkPromises(); // We now have 18 messages. 15 (MIN_INITIAL_REPORT_ACTION_COUNT) from the initial OpenReport and 3 from GetOlderActions.