e2e: Fix flaky login and redirect tests#2521
Open
jcscottiii wants to merge 1 commit into
Open
Conversation
Resolve flakiness in E2E tests by using deterministic waiting mechanisms for backend API responses.
- Login Test (`login.spec.ts`):
- Make the syncing state screenshot test deterministic by intercepting the `/v1/users/me/ping` API request and blocking it using a Promise until both light and dark theme screenshots are captured. This prevents the UI from prematurely transitioning to the idle state, which was causing race conditions and snapshot mismatches (especially in WebKit).
- Redirect Tests (`feature-page.spec.ts`, `utils.ts`):
- Synchronize E2E tests by waiting for backend API GET responses before asserting redirects, rather than relying on page load events or timing out.
- In `feature-page.spec.ts`:
- Update `redirects for a moved feature` test to wait for both the redirect response (`old-feature`) and the redirect target response (`new-feature`), filtering both by `GET` method to avoid matching CORS `OPTIONS` preflights. This ensures the test doesn't assert the URL before the redirect target has finished loading, resolving failures on cold start cache misses.
- Update `shows gone page for a split feature` to wait for the `before-split-feature` GET response before asserting the 410 URL.
- In `utils.ts`:
- Update `goTo404Page` helper to wait for the feature's GET response before asserting the 404 URL.
This shifts network wait times to the safe 30-second default timeout of `waitForResponse`, preventing them from eating into the strict 5-second assertion timeout of `toHaveURL` in resource-constrained CI environments.
Collaborator
|
If not already done, it would be good to verify the fix by running the tests with npx's |
neilv-g
approved these changes
Jun 6, 2026
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.
Resolve flakiness in E2E tests by using deterministic waiting mechanisms for backend API responses.
Login Test (
login.spec.ts):/v1/users/me/pingAPI request and blocking it using a Promise until both light and dark theme screenshots are captured. This prevents the UI from prematurely transitioning to the idle state, which was causing race conditions and snapshot mismatches (especially in WebKit).Redirect Tests (
feature-page.spec.ts,utils.ts):feature-page.spec.ts:redirects for a moved featuretest to wait for both the redirect response (old-feature) and the redirect target response (new-feature), filtering both byGETmethod to avoid matching CORSOPTIONSpreflights. This ensures the test doesn't assert the URL before the redirect target has finished loading, resolving failures on cold start cache misses.shows gone page for a split featureto wait for thebefore-split-featureGET response before asserting the 410 URL.utils.ts:goTo404Pagehelper to wait for the feature's GET response before asserting the 404 URL.This shifts network wait times to the safe 30-second default timeout of
waitForResponse, preventing them from eating into the strict 5-second assertion timeout oftoHaveURLin resource-constrained CI environments.