// @vitest-environment jsdom import React, { act } from "react"; import { createRoot, type Root } from "react-dom/client"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import CanvasSidebar from "@/components/canvas/canvas-sidebar"; import type { Id } from "@/convex/_generated/dataModel"; vi.mock("@/hooks/use-auth-query", () => ({ useAuthQuery: () => ({ name: "Demo Canvas" }), })); vi.mock("@/components/canvas/canvas-user-menu", () => ({ CanvasUserMenu: ({ compact }: { compact?: boolean }) => (
), })); vi.mock("@/components/ui/progressive-blur", () => ({ ProgressiveBlur: () => , })); vi.mock("next/image", () => ({ __esModule: true, default: ({ alt }: { alt?: string }) => , })); (globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true; describe("CanvasSidebar", () => { let container: HTMLDivElement | null = null; let root: Root | null = null; beforeEach(() => { container = document.createElement("div"); document.body.appendChild(container); root = createRoot(container); }); afterEach(async () => { if (root) { await act(async () => { root?.unmount(); }); } container?.remove(); container = null; root = null; }); it("shows divider-separated category sections with two-column grids in rail mode", async () => { await act(async () => { root?.render(