import { render, screen } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import { vi } from "vitest"; import { SessionMenu } from "./SessionMenu"; import type { SessionSummary } from "../api/types"; const base: SessionSummary = { id: "s1", status: "open", question: "q", summary: null, created_at: "2026-01-01T00:00:00Z", updated_at: null, author: null, name: null, group: null, archived: false, }; function renderMenu(over: Partial, onResume = vi.fn()) { render( , ); return onResume; } test("Resume shows for an open, non-archived session and calls onResume", async () => { const onResume = renderMenu({ status: "open", archived: false }); await userEvent.click(screen.getByRole("button", { name: /session actions/i })); await userEvent.click(await screen.findByText("Resume")); expect(onResume).toHaveBeenCalledTimes(1); }); test("Resume is hidden for a finalized session", async () => { renderMenu({ status: "finalized" }); await userEvent.click(screen.getByRole("button", { name: /session actions/i })); await screen.findByText("Split view"); // menu is open expect(screen.queryByText("Resume")).not.toBeInTheDocument(); }); test("Resume is hidden for an archived session", async () => { renderMenu({ status: "open", archived: true }); await userEvent.click(screen.getByRole("button", { name: /session actions/i })); await screen.findByText("Split view"); // menu is open expect(screen.queryByText("Resume")).not.toBeInTheDocument(); });