修复 CreatorPages 回关用例在并发负载下的偶发失败(修 CI flaky) #646
Reference in New Issue
Block a user
Delete Branch "fix/creator-follow-flaky"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
关联 Issue #644(合并时自动关闭:Closes #644)
概述
仅修 master 上既有的 flaky 用例(由已并入 master 的 PR #638 引入),与买断制功能无关,不涉及任何产品代码。改动
1 file changed, +7/-2,仅src/components/creator/CreatorPages.test.tsx。机理
disabled=true,但文本已经是「回关」(followed默认 false)→findByRole('回关')会在这一帧就命中。onClick→fireEvent.click被吞,写入从未发生(实测 onClick 命中 0 次)。CreatorPages.test.tsx:145)。findBy超时无效——该帧之后 DOM 不再变化;只有 CPU 严重超卖(CI runner 上 5 个 job 并发)时才会带着首帧 DOM 继续执行,故表现为偶发。改动
先等按钮从
disabled变为可用再点击。仓库内已有同款先例:src/components/game-distribution/GameDistributionPages.test.tsx:237-242。验证证据
runs=144 failures=3 seconds=78 exit=1,失败签名与 CI run 3548 一致(CreatorPages.test.tsx:145/Unable to find role="button" and name "取消关注");另有一次 140 次尝试记录了 2 次失败。runs=144 failures=0 seconds=70 exit=0。runs=240 failures=0 seconds=148 exit=0。npx vitest run src/components/creator/CreatorPages.test.tsx×10 → 10/10 全绿(每次 13 tests)。npm run test:ci:frontend→ exit 0,Test Files 253 passed (253)、Tests 2861 passed | 12 skipped。process.platform显式跳过的用例,文件/用例总数由vitest.frontend-ci.config.ts的 glob 固定,单文件改动不会改变它。影响面
修掉后不再随机让任何 PR 的
Frontend tests变红,省去人工重跑与排查成本。