Skip to content

✅ Test(gui): wait for schema sync in plugin detail panel tests - #1449

Merged
Molunerfinn merged 1 commit into
devfrom
fix-flaky-plugin-detail-test
Oct 5, 2026
Merged

Molunerfinn merged 1 commit into
devfrom
fix-flaky-plugin-detail-test

Conversation

@Molunerfinn

Copy link
Copy Markdown
Owner

背景

plugin-detail-panel.spec.tsx 在 CI 上偶发失败,例如 https://github.com/Molunerfinn/PicGo/actions/runs/37287839458/job/111690891506 :

AssertionError: expected 'verbosity▼' to contain 'debug'
 ❯ src/__tests__/renderer/components/plugin-detail-panel.spec.tsx:329:60

同一个 commit 在 master 上是通过的。

原因

use-plugin-config-section.ts 先同步执行 setValues(hydrated),Mode 立刻显示 advanced;Verbosity / API version 的可选项则要等异步的 refreshConfigSchema 返回 advanced 状态的 schema 后才有 debug / v2。在那之前,Select 显示的是占位文本(field.name)。

两个用例都只用 waitFor 等 Mode,之后对 Verbosity / API version 的断言是同步的。CI 机器慢的时候,断言执行时 schema 还没回来,于是失败。

改动

把两个用例里 Verbosity / API version 的断言都挪进 waitFor。只改了测试,业务代码不变。

验证

  • 临时给 refreshConfigSchema 的 mock 加 100ms 延迟:修改前两个用例都稳定失败,报错和 CI 上一致;修改后两个用例都通过
  • 去掉延迟后连续跑 30 次,30 次全部通过
  • eslint 通过

Mode is hydrated synchronously, but Verbosity / API version only show the saved values after the async refreshConfigSchema call resolves with the advanced-state choices. Both tests waited for Mode and then asserted the dependent fields synchronously, so on a slow CI runner they could still see the placeholder ("verbosity▼"). Move those assertions into waitFor.
@Molunerfinn
Molunerfinn merged commit 1c0716f into dev Oct 5, 2026
3 checks passed
@Molunerfinn
Molunerfinn deleted the fix-flaky-plugin-detail-test branch October 5, 2026 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant