From 6304335fccec3dc705fb81aa31c7f31cc2914c55 Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Sat, 22 Aug 2026 08:33:19 +0000 Subject: [PATCH] fix(test): await pending frontend module teardown --- .../src/components/vector/__tests__/VectorBrowser.spec.ts | 4 +++- .../__tests__/connectionStore.findConnectionNode.spec.ts | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/desktop/src/components/vector/__tests__/VectorBrowser.spec.ts b/apps/desktop/src/components/vector/__tests__/VectorBrowser.spec.ts index 99df1bbed0..9951418320 100644 --- a/apps/desktop/src/components/vector/__tests__/VectorBrowser.spec.ts +++ b/apps/desktop/src/components/vector/__tests__/VectorBrowser.spec.ts @@ -85,9 +85,11 @@ beforeEach(() => { document.body.appendChild(root); }); -afterEach(() => { +afterEach(async () => { + await flushUi(); app?.unmount(); app = null; + await flushUi(); root?.remove(); root = null; document.body.innerHTML = ""; diff --git a/apps/desktop/src/stores/__tests__/connectionStore.findConnectionNode.spec.ts b/apps/desktop/src/stores/__tests__/connectionStore.findConnectionNode.spec.ts index 39d9558a94..ba3e971d3e 100644 --- a/apps/desktop/src/stores/__tests__/connectionStore.findConnectionNode.spec.ts +++ b/apps/desktop/src/stores/__tests__/connectionStore.findConnectionNode.spec.ts @@ -37,6 +37,7 @@ describe("connection root lookup", () => { // markConnectionLost → clearConnectionNodeLoading 经连接根查找定位节点: // 分组内的连接必须能被找到并清除 loading store.markConnectionLost("pg-1", new Error("connection lost")); + await vi.dynamicImportSettled(); expect(conn.isLoading).toBe(false); }); @@ -55,6 +56,7 @@ describe("connection root lookup", () => { (collidingDeepNode as { isLoading?: boolean }).isLoading = true; store.markConnectionLost("pg-1", new Error("connection lost")); + await vi.dynamicImportSettled(); // 真正的连接根被清除 loading;深层碰撞节点不受影响 expect(realRoot.isLoading).toBe(false); expect((collidingDeepNode as { isLoading?: boolean }).isLoading).toBe(true);