test(editor-host): 慢 runner 上给「等树渲染出行」一个 5s 条件预算
CI(ubuntu lane,2 核、与 184 个文件并行)稳定红在 `tests/editor-host.spec.tsx > EditorHost native-tab context-menu actions > keeps the bottom-workbench split for a tab that lives there`,签名是 `AssertionError: expected false to be true`、落在 **spec:74**(`waitForTreeRow` 里的 `expect(found).toBe(true)`),耗时 ~1026ms —— 正好是 `vi.waitFor` 的 **默认 1000ms**。 根因不是产品缺陷,而是预算错配:`vi.waitFor` 的默认超时与套件的 `testTimeout`(15s,当年为 Windows lane 的真实子进程抬的)**互不相干**,仍是 1s。 上次 `630d10f` 已经把这个 helper 从「drain 微任务」改成「等真实渲染条件」,但条件 等待的预算没跟着抬,于是一旦 `fs.trees` 的应答 + React flush 越过 1s(满载的 2 核 runner 上很容易),断言还是先超时。 本机复现(往 `fs.trees` mock 注入 1200ms): - 默认 1s 预算 → 1049ms 红,签名与 CI 逐字相同; - 5s 预算 → 1296ms 绿。 仍是**条件**等待而不是固定时长:行一渲染出来就返回;树永远列不出该行时用例照样 失败(只是从 1s 变成 5s),`630d10f` 的反判别性检查继续成立。测试改动,产品代码 零改动。同一暴露面还有 7 处 `vi.waitFor` 未给预算(`zip.spec.ts` ×4 / `dock-fallback.spec.tsx` ×2 / 本文件外),暂未在 lane 上翻车,未一并改动。
This commit is contained in:
1 parent
657f75c1be
commit
5d259cca61
1 file changed
+18
-3
@@ -53,6 +53,22 @@ vi.mock('../src/client/api.ts', () => ({
|
||||
import { setupReactAct } from './test-utils.ts'
|
||||
setupReactAct()
|
||||
|
||||
/**
|
||||
* How long a rendered CONDITION may take to appear on a loaded runner.
|
||||
*
|
||||
* `vi.waitFor` defaults to 1000ms, which is INDEPENDENT of this suite's
|
||||
* `testTimeout` (15s — raised for the Windows lane, where real child processes
|
||||
* are slow to start). On a saturated 2-core ubuntu runner this file runs in
|
||||
* parallel with 184 others and the tree's async level load can miss that first
|
||||
* second: the lane failed here at ~1026ms, i.e. exactly the waitFor budget,
|
||||
* with the tree still on its loading row.
|
||||
*
|
||||
* This is still a CONDITION wait, not the "bigger fixed slice of time" the
|
||||
* note below warns against: it returns the moment the row renders, and a tree
|
||||
* that can never list it still fails the case — just after 5s instead of 1s.
|
||||
*/
|
||||
const RENDER_WAIT_MS = 5_000
|
||||
|
||||
/**
|
||||
* Wait until the tree has rendered the row for `name` — the precondition of
|
||||
* every tree interaction below.
|
||||
@@ -64,15 +80,14 @@ setupReactAct()
|
||||
* showing its loading row: the CI failure read `names=` (nothing rendered)
|
||||
* or `names=tmp` (the root row only). Wait for the rendered CONDITION, never
|
||||
* for a bigger fixed slice of time — a tree that never lists `name` is a real
|
||||
* product failure and still fails the case, on the default `vi.waitFor`
|
||||
* timeout.
|
||||
* product failure and still fails the case.
|
||||
*/
|
||||
async function waitForTreeRow(container: HTMLElement, name: string): Promise<void> {
|
||||
await vi.waitFor(() => {
|
||||
const found = [...container.querySelectorAll('[class*="explorerName"]')]
|
||||
.some(el => el.textContent === name)
|
||||
expect(found).toBe(true)
|
||||
})
|
||||
}, { timeout: RENDER_WAIT_MS })
|
||||
}
|
||||
|
||||
/** A store with the seeded editor-home tab (default prefs: separate mode;
|
||||
|
||||
Reference in new issue
Block a user