import { http, HttpResponse } from "msw"; import { server } from "../test/msw"; import { apiFetch } from "./client"; test("body-less POST omits content-type (avoids Fastify empty-body 400)", async () => { let contentType: string | null = "unset"; server.use( http.post("http://localhost:8787/sessions/s1/resume", ({ request }) => { contentType = request.headers.get("content-type"); return HttpResponse.json({ id: "s1" }); }), ); await apiFetch("/sessions/s1/resume", { method: "POST" }); expect(contentType).toBeNull(); }); test("POST with a body sends application/json content-type", async () => { let contentType: string | null = null; server.use( http.post("http://localhost:8787/sessions/s1/steer", ({ request }) => { contentType = request.headers.get("content-type"); return new HttpResponse(null, { status: 204 }); }), ); await apiFetch("/sessions/s1/steer", { method: "POST", body: JSON.stringify({ text: "hi" }) }); expect(contentType).toContain("application/json"); });