游戏分发 web E2E 的冷启动假失败改为浏览器级预热
Project CI / AI game creator shell Rust crates (push) Successful in 1m31s
Project CI / AI game creator shell Rust smoke (push) Successful in 1m56s
Project CI / Backend tests (push) Successful in 3m56s
Project CI / Frontend tests (push) Successful in 2m7s
Project CI / Native shell tests (push) Successful in 6m0s
Project CI / AI game creator shell Rust lane 2/2 (push) Successful in 8m34s
Project CI / AI game creator shell web tests (push) Successful in 1m42s
Project CI / AI game creator shell Rust lane 1/2 (push) Successful in 9m40s
Project CI / Repository checks (push) Successful in 2m15s

- 现象:冷 Vite 下 check:game-distribution-web-e2e 先卡在目录卡片 20 秒等待,重跑又卡在游玩页「开始游戏」15 秒等待;同一时刻公开目录 API 已把该游戏排在第一
- 根因:原先的 fetch 预热只拿到 SPA 外壳(HTML 里没有路由模块),Vite 仍在断言阶段现编译这些模块图
- 修复:改成起浏览器后用一次性 context 真走 /games、/games/detail、/games/play(domcontentloaded + 2 秒 settle,120 秒上限,失败只告警),首个 goto 的 120 秒超时保留
- 复验:重启 dev 栈(冷缓存)→ 24/24 PASS;四条 web E2E(web / publish / publish-recovery / a11y)全部复跑通过
- 文档:里程碑补 2026-09-29 复跑记录,pitfalls 同日条目按实测证据补正
This commit is contained in:
kdletters
2026-09-29 06:54:47 +08:00
parent 198c208172
commit d8011a72fa
3 changed files with 49 additions and 24 deletions
@@ -277,4 +277,15 @@
- `check:game-distribution-web-publish-recovery-e2e` → 全部通过(中断恢复草稿、重登继续沿用原版本、恢复后清理草稿、换账号看不到他人草稿)。
- `check:game-distribution-web-a11y-e2e` → 全部通过(桌面/移动导航、键盘可达、全屏、安全区、移动发布面板无横向溢出)。
**顺带修掉一处取证噪声**:`check:game-distribution-web-e2e` 的首个 `goto` 用的是默认 30 秒超时,碰上 Vite dev 冷启动(实测 `/games` 首请求 20.2 秒、warm 后 14 毫秒)会以 `Timeout 30000ms exceeded` 假失败。现在脚本在导航前先 `fetch` 预热 `/games`、`/games/detail?id=…`、`/games/play?id=…` 三条路由并把首个 `goto` 超时提到 120 秒;冷启动重跑即 24/24 PASS(详见 pitfalls 同日条目)。
**顺带修掉一处取证噪声**:`check:game-distribution-web-e2e` 的首个 `goto` 用的是默认 30 秒超时,碰上 Vite dev 冷启动(实测 `/games` 首请求 20.2 秒、warm 后 14 毫秒)会以 `Timeout 30000ms exceeded` 假失败。当时只是在导航前 `fetch` 预热三条路由并把首个 `goto` 超时提到 120 秒——**这版预热不够**(`fetch` 拿到的 SPA 外壳里没有路由模块),2026-09-29 已改成浏览器级预热,见下。
## 2026-09-29 复跑(四条 E2E 全绿 + 冷启动噪声彻底修掉)
重新拉起 `npm run dev` 后把四条真实网页栈 E2E 全部重跑,**四条全绿**:`check:game-distribution-web-e2e` **24/24 PASS**、`check:game-distribution-web-publish-e2e` / `-web-publish-recovery-e2e` / `-web-a11y-e2e` 全部通过(列表、发布待审、中断恢复草稿、桌面与移动导航/键盘可达都在内)。
其中 `web-e2e` 的冷启动假失败这次才真正修干净:
- **现象**:冷缓存下重跑,先在 `button.game-card:visible` 的 **20 秒**等待超时;第二次(目录已热)推进到游玩页 `getByRole('button', { name: '开始游戏' })` 的 **15 秒**等待超时。两次都停在「该路由第一次被浏览器加载」的那一步,而同一时刻公开目录 API 已把该游戏排在第一(说明后端与数据都没问题)。
- **根因**:`fetch('/games')` 只取到 SPA 外壳,HTML 里没有路由模块,所以 Vite dev 仍是在断言阶段现编译这些模块图,超过单步等待就被判成"页面打不开"。
- **修复**:`scripts/check-game-distribution-web-e2e.mjs` 改成**浏览器级预热**——起浏览器后用一次性 context 真的访问 `/games`、`/games/detail?id=…`、`/games/play?id=…`(`domcontentloaded` + 2 秒 settle,120 秒上限,失败只告警),再做断言;首个 `goto` 的 120 秒超时保留。
- **复验**:重启 dev 栈(Vite 冷缓存)→ 修复版 **24/24 PASS**;同一冷启动条件下修复前版本会在上述两处各失败一次。判据已写入 pitfalls 同日条目。