import { expect, it, vi } from "vitest"; import { createInteractionRequestApi, interactionRequestSchema } from "./interaction-requests"; it("rejects malformed host requests and scopes escaped URLs with no-store reads", async () => { expect(interactionRequestSchema.safeParse({ version: "agent-interaction-request@1", questions: [] }).success).toBe(false); const request = vi.fn(async () => new Response(JSON.stringify({ items: [] }), { status: 200 })); const api = createInteractionRequestApi(request); await expect(api.listInteractionRequests("session/other")).resolves.toEqual({ items: [] }); expect(request).toHaveBeenCalledWith("/session/session%2Fother/interactions", { cache: "no-store" }); }); it("keeps denied status available to purge the scope even with an empty response", async () => { const api = createInteractionRequestApi(async () => new Response(null, { status: 403 })); await expect(api.listInteractionRequests("session")).rejects.toMatchObject({ status: 403 }); });