From 5d259cca612e67184ec801f1237aa67170a57940 Mon Sep 17 00:00:00 2001 From: Menghuan1918 Date: Thu, 8 Oct 2026 21:58:13 +0800 Subject: [PATCH] =?UTF-8?q?test(editor-host):=20=E6=85=A2=20runner=20?= =?UTF-8?q?=E4=B8=8A=E7=BB=99=E3=80=8C=E7=AD=89=E6=A0=91=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=E5=87=BA=E8=A1=8C=E3=80=8D=E4=B8=80=E4=B8=AA=205s=20=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E9=A2=84=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 上翻车,未一并改动。 --- tests/editor-host.spec.tsx | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tests/editor-host.spec.tsx b/tests/editor-host.spec.tsx index d8302d38..a5940fb3 100644 --- a/tests/editor-host.spec.tsx +++ b/tests/editor-host.spec.tsx @@ -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 { 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;