import { render, screen } from "@testing-library/react"; import { beforeEach } from "vitest"; import { useSessionStore } from "../store/sessionStore"; import { CentralStatus } from "./CentralStatus"; beforeEach(() => useSessionStore.getState().resetSession()); test("the working spinner is a pure status indicator (no activity toggle on it)", () => { useSessionStore.getState().applyEvent({ type: "text_delta", text: "reading the schema" }); render(); // The spinner no longer opens the panel — that moved to the header arrow toggle. expect(screen.queryByRole("button", { name: /model activity/i })).not.toBeInTheDocument(); expect(screen.getByRole("status")).toBeInTheDocument(); }); test("renders nothing when not working and there is no user entry or step messages", () => { const { container } = render(); expect(container).toBeEmptyDOMElement(); }); test("echoes the last user entry and the step messages", () => { const st = useSessionStore.getState(); st.setLastUserEntry({ kind: "input", text: "how many patients?" }); st.applyEvent({ type: "info", level: "info", text: "Searching the schema…" }); render(); expect(screen.getByText("how many patients?")).toBeInTheDocument(); expect(screen.getByText("Searching the schema…")).toBeInTheDocument(); }); test("shows a working indicator with elapsed time and the model-stream tail while working", () => { useSessionStore.getState().applyEvent({ type: "text_delta", text: "Reading the schema for dim_patient" }); render(); // elapsed time (e.g. "0s") expect(screen.getByText(/\d+s/)).toBeInTheDocument(); // a short tail of the model's current output expect(screen.getByText(/Reading the schema for dim_patient/)).toBeInTheDocument(); }); test("no working indicator when not working, even with a transcript", () => { useSessionStore.getState().applyEvent({ type: "text_delta", text: "background narration" }); render(); expect(screen.queryByText(/\d+s/)).not.toBeInTheDocument(); });