test(desktop): customProviderDialogPresetLocale 三条 Escape/scrim 用例抖动,间歇性把任意 PR 的 verify 判红
- Dominant language
- TypeScript
- Stars
- 2.7k
- Forks
- 395
- Avg merge
- 21h 48m
- Merged PRs (30d)
- 776
Description
## 现象
`apps/desktop/src/renderer/__tests__/customProviderDialogPresetLocale.test.tsx` 会**间歇性**失败,失败用例在多次运行之间漂移:
- `dismisses only the topmost preset menu on a scrim gesture`
- `keeps IME Escape inside composition for %s`(`:179`)
- `dismisses the model picker before the underlying form on Escape`(`:196`)
因为 `verify` 这个必需 check 的门是 `LINUX_UNIT_SHARDS_RESULT = success`,任何一次抖动都会同时把 `Linux unit tests (1/2)` 和 `verify` 判红,看起来像是被测 PR 引入的回归。
## 证据
1. **main 自己就红过**:`240247e52`(run 31657742646,job 94315806949)失败的正是
`dismisses only the topmost preset menu on a scrim gesture`;而 main 的 `a034e93a8`(run 31661981622)同一条测试通过。
2. **本地可复现**:在一个完全没有触碰 renderer 的分支上连跑 8 次,2 次失败、6 次通过,且两次失败停在**不同**断言行(`:179` / `:196`)。
3 次 5 连跑里也是 4 过 1 败。
3. 最近一次误伤是 #2560 —— 那个 PR 的 diff 只有 4 个文件、全在 `packages/maker-core/src/agents/`,与 renderer 无任何交集。
## 疑似根因
这三条都在测 Radix Popover / DismissableLayer 的**退场时序**。测试文件自己的注释已经写明了这一点:
> Radix Popover 的退场 DismissableLayer 会短暂保留 document-capture listener。显式模拟它消费 Escape,确保 window-capture 的当前层 owner 先结算 picker,而不是被一个已关闭的菜单吞掉。
也就是说用例依赖「退场动画/微任务在断言之前跑完」,这个前提在 CI 与本机负载下都不稳定。手工插 `staleLayerListener` 是在对抗这个时序,而不是消除它。
## 建议方向
不要靠 retry 掩盖。让层的归属在测试里变成可确定的:等到退场层真正卸载(`waitForElementToBeRemoved` / 显式 `await` 层状态)再断言,或在测试环境关掉 Radix 的退场动画,使 DismissableLayer 同步卸载。
## 影响
不影响产品行为,但它会**随机把无关 PR 的必需 check 判红**,每次都要人去分辨是回归还是抖动 —— 这个分辨成本已经在多个 PR 上重复付过了。
Contributor guide
Research direction
Start with apps/desktop/src/renderer/__tests__/customProviderDialogPresetLocale.test.tsx and run the named tests repeatedly to reproduce the flake. Read the existing DismissableLayer timing comment and inspect how the tests wait for menu or picker dismissal. Done means all three Escape/scrim cases pass reliably without retries or causing unrelated PR checks to fail.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100