Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tests/ui/PaginationTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,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);
Expand Down Expand Up @@ -319,7 +320,7 @@ describe('Pagination', () => {
TestHelper.expectAPICommandToHaveBeenCalledWith('GetOlderActions', 0, {reportID: REPORT_ID, reportActionID: '4'});
TestHelper.expectAPICommandToHaveBeenCalled('GetNewerActions', 0);

await waitForBatchedUpdatesWithAct();
await waitForNetworkPromises();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment here to explain why this is needed in some future prs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean by adding a code-comment or can comment directly here? @mountiny

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lorretheboy Comment here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to use waitForNetworkPromises instead of waitForBatchedUpdatesWithAct to prevent this from being flaky test. This is because the test is not waiting for the pagination middleware to fully process the GetOlderActions response and update the component tree. The waitForBatchedUpdatesWithAct() call is not sufficient because it doesn't wait for the specific pagination processing to complete


// 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.
Expand Down
Loading