Commit af043bd
committed
e2e: Fix flaky login and redirect tests
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.1 parent 675d99b commit af043bd
3 files changed
Lines changed: 37 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
218 | | - | |
219 | | - | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
220 | 226 | | |
221 | 227 | | |
222 | | - | |
| 228 | + | |
| 229 | + | |
223 | 230 | | |
224 | 231 | | |
225 | 232 | | |
| |||
248 | 255 | | |
249 | 256 | | |
250 | 257 | | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
251 | 264 | | |
| 265 | + | |
252 | 266 | | |
253 | 267 | | |
254 | 268 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
32 | 37 | | |
33 | | - | |
| 38 | + | |
34 | 39 | | |
35 | 40 | | |
36 | 41 | | |
| |||
58 | 63 | | |
59 | 64 | | |
60 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
61 | 71 | | |
62 | 72 | | |
63 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
264 | 269 | | |
| 270 | + | |
| 271 | + | |
265 | 272 | | |
266 | 273 | | |
267 | 274 | | |
| |||
0 commit comments