diff --git a/ui/src/context/SidebarContext.test.tsx b/ui/src/context/SidebarContext.test.tsx index a25b18ee832..630f55cc48f 100644 --- a/ui/src/context/SidebarContext.test.tsx +++ b/ui/src/context/SidebarContext.test.tsx @@ -1,6 +1,6 @@ // @vitest-environment jsdom -import { act } from "react"; +import { flushSync } from "react-dom"; import { createRoot, type Root } from "react-dom/client"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { SidebarProvider, useSidebar } from "./SidebarContext"; @@ -13,6 +13,10 @@ const COLLAPSED_STORAGE_KEY = "paperclip.sidebar.collapsed"; // Mutable media state driving the matchMedia mock. const mediaState = { mobile: false, hoverFine: true }; +function act(callback: () => void) { + flushSync(callback); +} + function setViewport({ mobile, hoverFine }: { mobile?: boolean; hoverFine?: boolean }) { if (typeof mobile === "boolean") mediaState.mobile = mobile; if (typeof hoverFine === "boolean") mediaState.hoverFine = hoverFine;