Skip to content

test: stabilize range-mode popover tests against async render#410

Merged
tomasz-tomczyk merged 1 commit intomainfrom
fix-flaky-e2e
May 1, 2026
Merged

test: stabilize range-mode popover tests against async render#410
tomasz-tomczyk merged 1 commit intomainfrom
fix-flaky-e2e

Conversation

@tomasz-tomczyk
Copy link
Copy Markdown
Owner

Summary

Two range-mode e2e tests intermittently fail in CI with expect(labels[0]).toMatch(/main/) receiving undefined — the assertion races the popover's async re-render. Surfaced on an unrelated PR (#409, pure git.go diff parsing).

Root cause: the stack popover renders a synchronous "Loading…" placeholder, then re-renders .stack-popover-item nodes only after /api/picker resolves (~2s on slower runners). Tests that snapshot the DOM via evaluateAll / allTextContents / count() immediately after clicking #stackChipBtn see the empty placeholder state.

Fix: gate the DOM reads on .stack-popover-item visibility before snapshotting. On the order assertion, replace the non-retrying evaluateAll snapshot with toHaveCount(4) so Playwright auto-retries until the popover settles.

Files:

  • e2e/tests/focus-picker.rangemode.spec.ts — both failing tests (lines 29, 46)
  • e2e/tests/stack-popover.rangemode.spec.ts — two tests with the same race

Sweep of e2e/tests/ found no other instances: zero waitForTimeout, zero networkidle-only waits, only one evaluateAll (the failing one).

Review

  • Code review: targeted at demonstrable flake, no over-engineering
  • Parity audit: N/A (e2e-only)

Test plan

  • npx playwright test focus-picker.rangemode.spec.ts stack-popover.rangemode.spec.ts --project=range-mode → 17/17 pass locally
  • Full CI e2e suite green

🤖 Generated with Claude Code

Stack popover renders a "Loading…" placeholder synchronously and
re-renders .stack-popover-item only after /api/picker resolves
(~2s). Tests that snapshotted DOM immediately after clicking the
stack chip raced the re-render and surfaced as undefined labels in
slower CI runners.

- focus-picker.rangemode.spec.ts: wait for .stack-popover-item
  visibility before reading; replace evaluateAll snapshot with
  toHaveCount(4) auto-retry on the order test
- stack-popover.rangemode.spec.ts: same wait gate for the two
  tests that read allTextContents / buttons.count() right after
  click

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tomasz-tomczyk tomasz-tomczyk merged commit 23e4615 into main May 1, 2026
7 checks passed
@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.31%. Comparing base (8162177) to head (bf28d48).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #410      +/-   ##
==========================================
+ Coverage   67.26%   67.31%   +0.05%     
==========================================
  Files          26       26              
  Lines        9650     9650              
==========================================
+ Hits         6491     6496       +5     
+ Misses       2649     2646       -3     
+ Partials      510      508       -2     
Flag Coverage Δ
e2e 34.16% <ø> (+0.02%) ⬆️
unit 63.51% <ø> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tomasz-tomczyk tomasz-tomczyk deleted the fix-flaky-e2e branch May 1, 2026 07:35
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.

1 participant