From 6072eade58af624cf831aaf4ef86d79442c4c3fc Mon Sep 17 00:00:00 2001 From: Dotta Date: Tue, 9 Jun 2026 22:20:24 +0000 Subject: [PATCH] test(ui): make sidebar context test flush synchronously Co-Authored-By: Paperclip --- ui/src/context/SidebarContext.test.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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;