Skip to content
Closed
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
10 changes: 10 additions & 0 deletions tests/unit/MiddlewareTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ describe('Middleware', () => {
}));

SequentialQueue.unpause();
// Wait for the first request to complete and for Onyx to process the preexistingReportID
// update before the second request is dispatched. A single waitForNetworkPromises() call
// is not enough because the middleware re-queues the second request after the Onyx update
// resolves, which happens in a subsequent microtask/batch cycle.
await waitForNetworkPromises();
await waitForBatchedUpdates();
await waitForNetworkPromises();

expect(global.fetch).toHaveBeenCalledTimes(2);
Expand Down Expand Up @@ -338,7 +344,11 @@ describe('Middleware', () => {
}));

SequentialQueue.unpause();
// Both requests are sequential; we need to wait for all network activity to settle,
// including the second fetch triggered after Onyx processes preexistingReportID.
await waitForNetworkPromises();
await waitForBatchedUpdates();
await waitForNetworkPromises();

expect(global.fetch).toHaveBeenCalledTimes(2);

Expand Down