import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import { createPortal } from "react-dom"; import { describe, expect, it } from "vitest"; import { ComposerUsagePopover } from "@/components/thread/ComposerUsagePopover"; import type { ContextSnapshot } from "@/lib/types"; const first: ContextSnapshot = { id: "1", contextWindowTokens: 10000, usage: { prompt_tokens: 1000 }, graph: { nodes: [{ path: "/a.md", name: "a.md", state: "loaded", tokens: 100 }], edges: [] } }; describe("Context sidebar", () => { it("stays open while writing a message and updates the graph as new snapshots arrive", async () => { const user = userEvent.setup(); const content = (snapshots: ContextSnapshot[]) => <>