Repository navigation
Commit be67480
test(typeahead): serve the fixture pages as a build so cold loads fit (#2793)
## Summary
`typeahead.spec.mjs` now builds its four fixture pages (`mentions`,
`typeahead`, `emoji` and `messages`) once per worker in `beforeAll`. It
serves the bundle with `build` and `preview` from `vite-server.mjs`.
Before this change, it took its `baseURL` from the worker-scoped Vite
dev server in `source-fixture.mjs`. The change is test-only: no
assertions change, the navigation timeout is unchanged, and no browser
cases are added or removed.
### Problem
`Flake check (chromium, 11/11)` on #2507 failed `typeahead.spec.mjs:28`
"closing-colon emoji conversion restores literal source and caret on
undo" twice, with `TimeoutError: page.goto: Timeout 15000ms exceeded` on
`/tests/fixtures/mentions.html?test-controls`. Both times it was the
first test in the shard's second worker (16.4 s and 16.6 s), and the
same worker's next 23 tests passed. #2507 doesn't touch that page's
module graph; its `MessageRow` change only selects this spec into the
10× lane.
-
https://github.com/block/buzz-app/actions/runs/42195228817/job/127817183790
-
https://github.com/block/buzz-app/actions/runs/42169660635/job/127734602256
### Cause
The dev server transforms modules on first request. The four pages this
spec opens are 1,595 modules, and `mentions.html` alone is 1,589.
Whichever page a worker opened first loaded them cold, and on a busy
runner that took longer than the 15 s navigation timeout. #2776
describes the same cold load for `mentions.spec.mjs`, and lists this
spec under "Remaining gaps".
### Fix
- **Build:** `beforeAll` builds the four pages into a temp directory,
and `preview` serves them on an OS-assigned port. `afterAll` closes the
server and removes the directory. The config matches
`voice-notes.spec.mjs` (#2566) and #2776.
- **Dev checks kept:** the build defines `import.meta.env.DEV` and
`process.env.NODE_ENV` as development, so StrictMode's checks still
apply.
- **Paths unchanged:** `test.use` points `baseURL` at the preview
server, so every `page.goto` path stays the same.
- **No conflict with #2776:** only this spec changes, so #2776 still
merges cleanly. Once both land, the three copies of the build config
could become one helper.
### Validation
All runs were local on macOS (16 cores, load average 10–41) with the
Playwright CI config. These are not hosted CI measurements.
**Fail-before / pass-after.** A temporary `vite-server.mjs` probe (not
committed) held the `globals.css` transform for 16 s, in both the dev
server and the build:
| | main | this branch |
| --- | --- | --- |
| `:28` (moves to `:83` on this branch) | ✘ `page.goto: Timeout 15000ms
exceeded` (Chromium 15.1 s, WebKit 19.8 s) | ✓ 0.96 s Chromium, 0.97 s
WebKit |
| first `typeahead.html`, `emoji.html`, `messages.html` journeys | ✘
same error, 15.1 s each (Chromium) | ✓ 0.5–1.4 s |
| whole file | n/a | 24/24, with the 16 s spent once in `beforeAll` |
**Repeat run.** Chromium `--repeat-each=10 --workers=2`, two alternating
runs each:
| | result | wall time | user CPU | first test per worker |
| --- | --- | --- | --- | --- |
| main | 240/240 | 3.2 and 3.3 min | 839 s and 855 s | 4.2–4.8 s |
| this branch | 240/240 | 2.0 and 1.9 min | 352 s and 339 s | 0.9 s |
**Other checks:**
- **Full file:** Chromium 24/24, WebKit 24/24.
- **`scripts/flake-check.mjs select`:** I ran it for #2507's diff, a
`MessageRow.tsx`-only change, `tests/fixtures/mentions.tsx` and
`tests/fixtures/mentions.html`. Every selection matches main's, apart
from the spec's 55-line shift. The spec still links to all four pages.
- **Integration tests:** `tests/integration/flake-check.test.mjs` and
`tests/integration/vite-fixture.test.mjs` pass 33/33.
- **Biome:** clean.
### Browser coverage
No browser cases are added or removed and no assertions change. Only how
the fixture pages are served changes.
### Remaining gaps
- **Other specs:** specs that load `mentions.html` from
`source-fixture.mjs` or their own dev servers can still hit the same
cold load. These include `channel-completion`, `completion-work`,
`composer-*`, `mention-edit`, `mention-rules` and `mention-selection`.
They are not changed here.
- **Hosted CI:** it hasn't run on this branch yet, and a green run
wouldn't show the flake is gone.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Signed-off-by: Matt Toohey <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>1 parent 93a725d commit be67480
3 files changed
Lines changed: 70 additions & 44 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
4 | 23 | | |
5 | 24 | | |
6 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
139 | 182 | | |
140 | 183 | | |
141 | 184 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
13 | 7 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
| 8 | + | |
46 | 9 | | |
| 10 | + | |
47 | 11 | | |
48 | 12 | | |
49 | 13 | | |
| |||
59 | 23 | | |
60 | 24 | | |
61 | 25 | | |
62 | | - | |
| 26 | + | |
63 | 27 | | |
64 | 28 | | |
65 | 29 | | |
| |||
0 commit comments