diff --git a/ui/src/components/IssueProperties.test.tsx b/ui/src/components/IssueProperties.test.tsx index e7b72d14d6a..ec0ec658b6c 100644 --- a/ui/src/components/IssueProperties.test.tsx +++ b/ui/src/components/IssueProperties.test.tsx @@ -1,7 +1,7 @@ // @vitest-environment jsdom -import { act } from "react"; import type { ComponentProps, ReactNode } from "react"; +import { flushSync } from "react-dom"; import { createRoot } from "react-dom/client"; import type { ExecutionWorkspace, @@ -115,6 +115,14 @@ vi.mock("@/components/ui/popover", () => ({ // eslint-disable-next-line @typescript-eslint/no-explicit-any (globalThis as any).IS_REACT_ACT_ENVIRONMENT = true; +async function act(callback: () => void | Promise) { + let result: void | Promise = undefined; + flushSync(() => { + result = callback(); + }); + await result; +} + async function flush() { await act(async () => { await new Promise((resolve) => setTimeout(resolve, 0)); diff --git a/ui/src/components/interrupt-handoff/InterruptHandoffViews.test.tsx b/ui/src/components/interrupt-handoff/InterruptHandoffViews.test.tsx index 9c9fd660b63..2d080840202 100644 --- a/ui/src/components/interrupt-handoff/InterruptHandoffViews.test.tsx +++ b/ui/src/components/interrupt-handoff/InterruptHandoffViews.test.tsx @@ -1,7 +1,7 @@ // @vitest-environment jsdom -import { act } from "react"; import type { ReactNode } from "react"; +import { flushSync } from "react-dom"; import { createRoot, type Root } from "react-dom/client"; import { afterEach, describe, expect, it, vi } from "vitest"; import { @@ -30,6 +30,14 @@ const resolvers: HandoffChipResolvers = { currentUserId: "user-board", }; +async function act(callback: () => void | Promise) { + let result: void | Promise = undefined; + flushSync(() => { + result = callback(); + }); + await result; +} + let activeRoot: Root | null = null; let activeHost: HTMLDivElement | null = null;