feat(frontend): settings api, typed PiModel, question-only createSession
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -2,10 +2,18 @@ import { http, HttpResponse } from "msw";
|
||||
import { server } from "../test/msw";
|
||||
import { createSession, listSessions } from "./sessions";
|
||||
|
||||
test("createSession POSTs and returns the id", async () => {
|
||||
server.use(http.post("http://localhost:8787/sessions", () => HttpResponse.json({ id: "s1" })));
|
||||
expect(await createSession({ workspace: "w", question: "q" })).toEqual({ id: "s1" });
|
||||
test("createSession POSTs only {question} and returns the id", async () => {
|
||||
let body: unknown = null;
|
||||
server.use(
|
||||
http.post("http://localhost:8787/sessions", async ({ request }) => {
|
||||
body = await request.json();
|
||||
return HttpResponse.json({ id: "s1" });
|
||||
}),
|
||||
);
|
||||
expect(await createSession({ question: "q" })).toEqual({ id: "s1" });
|
||||
expect(body).toEqual({ question: "q" });
|
||||
});
|
||||
|
||||
test("listSessions GETs the array", async () => {
|
||||
server.use(http.get("http://localhost:8787/sessions", () => HttpResponse.json([{ id: "s1", status: "open", question: "q", summary: null, created_at: "t", updated_at: null, author: null }])));
|
||||
const rows = await listSessions();
|
||||
|
||||
Reference in New Issue
Block a user