Skip to content

test(e2e): fix flaky attachments UI tests with web-first wait#1327

Merged
BYK merged 1 commit into
mainfrom
fix/e2e-ui-attachments-flake
Jun 23, 2026
Merged

test(e2e): fix flaky attachments UI tests with web-first wait#1327
BYK merged 1 commit into
mainfrom
fix/e2e-ui-attachments-flake

Conversation

@BYK

@BYK BYK commented Jun 23, 2026

Copy link
Copy Markdown
Member

Summary

Fixes the flaky E2E UI Tests failure on attachments.e2e.test.ts (the "should display attachments from fixture directory" test timed out with an empty body in PR #1326's CI run, passing only on re-run).

Root cause

Every test in the file asserted body.textContent() !== "" by reading textContent() once, right after the <body> element attached. In an SPA the body shell exists before React's first paint, so this races the initial render with no auto-retry. The passing tests incidentally got settle time (the sendTestEnvelope fixture sleeps 500ms, or waitForTimeout(1000)); the failing test sends no envelope, so it had no slack and flaked under CI load.

Fix

  • Add a web-first waitForAppReady(page) helper in fixtures.ts that asserts the navigation sidebar (nav[aria-label="Navigation"]) is visible. The sidebar (TelemetrySidebar) renders unconditionally once the app mounts, independent of telemetry data, so Playwright's auto-retrying toBeVisible() eliminates the render race.
  • Replace the fragile one-shot body.textContent() checks throughout attachments.e2e.test.ts with waitForAppReady(page).

This is also a stronger assertion: if the UI crashed into the ErrorBoundary fallback (which renders no nav), these tests now correctly fail instead of passing on non-empty body text.

Verification

  • Lint (biome) + TypeScript check pass on the changed files.
  • ⚠️ I could not run the Playwright UI suite locally — this environment couldn't download the chromium browser (CDN download stalled/retried repeatedly). CI has browsers preinstalled and is the exact environment where the flake occurred; I'll confirm stability by running the E2E UI job here (including re-runs).

The attachments E2E UI tests asserted `body.textContent() !== ""` by
reading textContent once, immediately after the <body> element attached.
In an SPA the body shell exists before React's first paint, so this raced
the initial render with no auto-retry. The 'should display attachments
from fixture directory' test (no envelope, so no incidental settle delay)
flaked on CI, timing out with an empty body.

Replace the one-shot reads with a web-first `waitForAppReady(page)` helper
that asserts the navigation sidebar (nav[aria-label="Navigation"]) is
visible. The sidebar renders unconditionally once the app mounts, so the
auto-retrying toBeVisible() assertion eliminates the render race. It is
also a stronger check: if the UI crashed into the ErrorBoundary fallback
(which has no nav), these tests now correctly fail.
@BYK BYK self-assigned this Jun 23, 2026
@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spotlightjs Ready Ready Preview, Comment Jun 23, 2026 1:53pm

Request Review

@BYK BYK deployed to Preview June 23, 2026 13:53 — with GitHub Actions Active
@github-actions

Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ Patch coverage is 100.00%. Project has 678 uncovered lines.
✅ Project coverage is 57.62%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    57.62%    57.62%        —%
==========================================
  Files           49        49         —
  Lines         1602      1602         —
  Branches      1153      1153         —
==========================================
+ Hits           924       924         —
- Misses         678       678         —
- Partials       123       123         —

Generated by Codecov Action

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ Patch coverage is 100.00%. Project has 678 uncovered lines.
✅ Project coverage is 57.62%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    57.62%    57.62%        —%
==========================================
  Files           49        49         —
  Lines         1602      1602         —
  Branches      1153      1153         —
==========================================
+ Hits           924       924         —
- Misses         678       678         —
- Partials       123       123         —

Generated by Codecov Action

@BYK BYK merged commit 1e43a6f into main Jun 23, 2026
45 checks passed
@BYK BYK deleted the fix/e2e-ui-attachments-flake branch June 23, 2026 14:07
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