feat(shell): add SessionDocumentsPanel read-only left drawer (Task 11)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-29 13:05:40 +02:00
co-authored by Claude Sonnet 4.6
parent f8c246a1b6
commit 964bfa39ea
2 changed files with 139 additions and 0 deletions
@@ -0,0 +1,45 @@
import { render, screen } from "@testing-library/react";
import { http, HttpResponse } from "msw";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { server } from "../test/msw";
import { SessionDocumentsPanel } from "./SessionDocumentsPanel";
import type { SessionSummary } from "../api/types";
function makeClient() {
return new QueryClient({ defaultOptions: { queries: { retry: false } } });
}
function wrap(ui: React.ReactElement, client = makeClient()) {
const Wrapper = ({ children }: { children: React.ReactNode }) => (
<QueryClientProvider client={client}>{children}</QueryClientProvider>
);
return render(ui, { wrapper: Wrapper });
}
const base: SessionSummary = {
id: "s1", status: "open", question: "How many ablations?", summary: null,
created_at: "2026-01-01T00:00:00Z", updated_at: null, author: null,
name: null, group: null, archived: false,
};
beforeEach(() => {
server.use(http.get("http://localhost:8787/sessions/s1/documents", () =>
HttpResponse.json([
{ phase: "—", key: "question", title: "Original question", format: "text", content: "How many ablations?" },
{ phase: "F7", key: "sql", title: "Final SQL", format: "sql", content: "SELECT 1" },
]),
));
});
test("renders the document titles from the API", async () => {
wrap(<SessionDocumentsPanel session={base} onClose={vi.fn()} onResume={vi.fn()} />);
expect(await screen.findByText("Original question")).toBeInTheDocument();
expect(screen.getByText("Final SQL")).toBeInTheDocument();
});
test("shows Resume for resumable, hides it for finalized", async () => {
const { rerender } = wrap(<SessionDocumentsPanel session={base} onClose={vi.fn()} onResume={vi.fn()} />);
expect(await screen.findByRole("button", { name: /resume/i })).toBeInTheDocument();
rerender(<SessionDocumentsPanel session={{ ...base, status: "finalized" }} onClose={vi.fn()} onResume={vi.fn()} />);
expect(screen.queryByRole("button", { name: /resume/i })).not.toBeInTheDocument();
});