From 89d9e0d85e37fa04ef2e90e25b174c173e56d0eb Mon Sep 17 00:00:00 2001 From: EMRG Evolution Date: Thu, 27 Aug 2026 11:46:30 +0800 Subject: [PATCH] =?UTF-8?q?emrg:=20renderer=20shell=20test=20=E2=80=94=20w?= =?UTF-8?q?aitFor=20the=20Edit=20form=20name=20prefill=20(fix=20flaky=20ta?= =?UTF-8?q?skUpdate=20test)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The '任务行 Edit' test read name.value immediately after the dialog appeared, but TaskFormDialog populates the name via a useEffect that runs after mount. Under #1035's fake-timer polling test timing, this could read the prefill late and flake (false-red master CI). Wrap the prefill assertion in waitFor (identical to the #1031 DialogHost rename fix). --- emrg/gui/renderer/src/components/Shell.test.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/emrg/gui/renderer/src/components/Shell.test.tsx b/emrg/gui/renderer/src/components/Shell.test.tsx index 91275120..12829a17 100644 --- a/emrg/gui/renderer/src/components/Shell.test.tsx +++ b/emrg/gui/renderer/src/components/Shell.test.tsx @@ -377,8 +377,11 @@ describe("Shell (Batch 5 slice 3 chat wiring)", () => { await waitFor(() => expect(screen.getByTestId("task-row")).toBeInTheDocument()); fireEvent.click(screen.getByTitle("Edit")); await waitFor(() => expect(screen.getByTestId("task-form-dialog")).toBeInTheDocument()); + // 预填由 TaskFormDialog 的 useEffect 在 mount 后执行(vanilla openTaskForm 语义, + // 见 #1031 同类 flaky 修复)。用 waitFor 等待 effect 填充值,避免在 effect 跑完前 + // 读到空 name.value(#1035 轮询测试的 fake-timer/async 交错曾偶发暴露此竞态)。 const name = screen.getByTestId("task-form-name") as HTMLInputElement; - expect(name.value).toBe("evo"); + await waitFor(() => expect(name.value).toBe("evo")); expect(name.disabled).toBe(true); fireEvent.change(screen.getByTestId("task-form-interval"), { target: { value: "7200" } }); fireEvent.click(screen.getByTestId("task-form-save"));