Skip to content

Commit 15263fa

Browse files
Merge pull request #7089 from Shopify/fix-flaky-poll-app-logs
Fix flaky test in usePollAppLogs.test.tsx
2 parents 126a4e2 + dd5a291 commit 15263fa

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

packages/app/src/cli/services/app-logs/logs-command/ui/components/hooks/usePollAppLogs.test.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,11 @@ describe('usePollAppLogs', () => {
404404
// needed to await the render
405405
await vi.advanceTimersByTimeAsync(0)
406406

407+
// Wait for the async polling function to execute
408+
await waitForMockCalls(mockedPollAppLogs, 1)
409+
// Flush React 19 batched state updates so hook.lastResult reflects the new state
410+
await vi.advanceTimersByTimeAsync(0)
411+
407412
// Initial invocation, 429 returned
408413
expect(mockedPollAppLogs).toHaveBeenCalledTimes(1)
409414

@@ -447,6 +452,11 @@ describe('usePollAppLogs', () => {
447452
// needed to await the render
448453
await vi.advanceTimersByTimeAsync(0)
449454

455+
// Wait for the async polling function to execute
456+
await waitForMockCalls(mockedPollAppLogs, 1)
457+
// Flush React 19 batched state updates so hook.lastResult reflects the new state
458+
await vi.advanceTimersByTimeAsync(0)
459+
450460
// Initial invocation, 422 returned
451461
expect(mockedPollAppLogs).toHaveBeenCalledTimes(1)
452462

0 commit comments

Comments
 (0)