From 7abf1d2ac75be789c53cf6fc9d1a50028d2b4e83 Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Sun, 6 Dec 2026 05:04:48 +0800 Subject: [PATCH] test(vcs): close the blame popup inside act in teardown (#8300) closeBlamePopup renders null into the popup's React root; called outside act in afterEach, React sometimes ran that work after the test environment was torn down, failing the Frontend job with an unhandled window-is-not-defined error. Both blame test files now close it inside act. --- src/features/vcs/__tests__/blame.test.tsx | 3 ++- src/features/vcs/__tests__/ijAnnotations.test.ts | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/features/vcs/__tests__/blame.test.tsx b/src/features/vcs/__tests__/blame.test.tsx index bff0141e32..7889eb814c 100644 --- a/src/features/vcs/__tests__/blame.test.tsx +++ b/src/features/vcs/__tests__/blame.test.tsx @@ -94,7 +94,8 @@ beforeEach(() => { }); afterEach(() => { - closeBlamePopup(); + // Inside act: the popup's root renders the close now, not after the test environment is gone. + act(() => closeBlamePopup()); view?.destroy(); view = undefined; vi.useRealTimers(); diff --git a/src/features/vcs/__tests__/ijAnnotations.test.ts b/src/features/vcs/__tests__/ijAnnotations.test.ts index 37505b97af..ebccfb1074 100644 --- a/src/features/vcs/__tests__/ijAnnotations.test.ts +++ b/src/features/vcs/__tests__/ijAnnotations.test.ts @@ -5,6 +5,7 @@ // change) is crates/ide-svn/tests/ij_history.rs. import { EditorState } from "@codemirror/state"; import { EditorView } from "@codemirror/view"; +import { act } from "@testing-library/react"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import type { BlameLine } from "@/bindings"; import { useI18n } from "@/platform/i18n"; @@ -78,7 +79,8 @@ beforeEach(() => { }); afterEach(() => { - closeBlamePopup(); + // Inside act: the popup's root renders the close now, not after the test environment is gone. + act(() => closeBlamePopup()); view?.destroy(); view = undefined; vi.useRealTimers();