test(e2e): fix flaky attachments UI tests with web-first wait#1327
Merged
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Codecov Results 📊✅ Patch coverage is 100.00%. Project has 678 uncovered lines. 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
Contributor
Codecov Results 📊✅ Patch coverage is 100.00%. Project has 678 uncovered lines. 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 readingtextContent()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 (thesendTestEnvelopefixture sleeps 500ms, orwaitForTimeout(1000)); the failing test sends no envelope, so it had no slack and flaked under CI load.Fix
waitForAppReady(page)helper infixtures.tsthat 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-retryingtoBeVisible()eliminates the render race.body.textContent()checks throughoutattachments.e2e.test.tswithwaitForAppReady(page).This is also a stronger assertion: if the UI crashed into the
ErrorBoundaryfallback (which renders no nav), these tests now correctly fail instead of passing on non-empty body text.Verification