Skip to content

Fix flaky test in usePollAppLogs.test.tsx#7089

Merged
gonzaloriestra merged 1 commit intomainfrom
fix-flaky-poll-app-logs
Mar 24, 2026
Merged

Fix flaky test in usePollAppLogs.test.tsx#7089
gonzaloriestra merged 1 commit intomainfrom
fix-flaky-poll-app-logs

Conversation

@gonzaloriestra
Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Fixes flaky test usePollAppLogs > retries after unknown error:

Error: AssertionError: expected undefined to deeply equal 'Error while polling app logs'

- Expected: 
"Error while polling app logs"

+ Received: 
undefined

 ❯ src/cli/services/app-logs/logs-command/ui/components/hooks/usePollAppLogs.test.tsx:454:40

Example: https://github.com/Shopify/cli/actions/runs/23492398606/job/68363913877

WHAT is this pull request doing?

The test asserted on hook.lastResult?.errors immediately after advanceTimersByTimeAsync(0), but the async poll chain (performPollawait pollAppLogs()await handleFetchAppLogsError()setErrors()) could still be in-flight, so React hadn't flushed the state update yet.

Added waitForMockCalls + an extra advanceTimersByTimeAsync(0) to drain microtasks and flush React 19 batched state updates before asserting — matching the pattern already used by the other passing tests in the same file. Applied the same fix to the "retries after throttle interval on 429" test which had the identical race condition.

How to test your changes?

CI

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

@github-actions
Copy link
Copy Markdown
Contributor

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements 82.17% 14932/18172
🟡 Branches 74.52% 7375/9897
🟢 Functions 81.3% 3779/4648
🟢 Lines 82.55% 14116/17099

Test suite run success

3933 tests passing in 1514 suites.

Report generated by 🧪jest coverage report action from dd5a291

@gonzaloriestra gonzaloriestra marked this pull request as ready for review March 24, 2026 14:13
@gonzaloriestra gonzaloriestra requested a review from a team as a code owner March 24, 2026 14:13
@github-actions
Copy link
Copy Markdown
Contributor

We detected some changes at packages/*/src and there are no updates in the .changeset.
If the changes are user-facing, run pnpm changeset add to track your changes and include them in the next release CHANGELOG.

Caution

DO NOT create changesets for features which you do not wish to be included in the public changelog of the next CLI release.

Copy link
Copy Markdown
Contributor Author

gonzaloriestra commented Mar 24, 2026

Merge activity

  • Mar 24, 2:42 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Mar 24, 2:42 PM UTC: @gonzaloriestra added this pull request to the GitHub merge queue with Graphite.

@gonzaloriestra gonzaloriestra added this pull request to the merge queue Mar 24, 2026
Merged via the queue into main with commit 15263fa Mar 24, 2026
30 checks passed
@gonzaloriestra gonzaloriestra deleted the fix-flaky-poll-app-logs branch March 24, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants