|
| 1 | +import { describe, test, expect } from "bun:test" |
| 2 | + |
| 3 | +import { server } from "../src/server" |
| 4 | + |
| 5 | +describe("POST /v1/responses stub", () => { |
| 6 | + test("returns 501 with structured error body", async () => { |
| 7 | + const res = await server.request("/v1/responses", { |
| 8 | + method: "POST", |
| 9 | + headers: { "Content-Type": "application/json" }, |
| 10 | + body: JSON.stringify({ model: "gpt-4o", input: [] }), |
| 11 | + }) |
| 12 | + expect(res.status).toBe(501) |
| 13 | + const body = (await res.json()) as { |
| 14 | + error: { type: string; code: string; message: string } |
| 15 | + } |
| 16 | + expect(body.error.type).toBe("not_implemented") |
| 17 | + expect(body.error.code).toBe("responses_not_implemented") |
| 18 | + expect(typeof body.error.message).toBe("string") |
| 19 | + }) |
| 20 | + |
| 21 | + test("bare /responses path also returns 501", async () => { |
| 22 | + const res = await server.request("/responses", { |
| 23 | + method: "POST", |
| 24 | + headers: { "Content-Type": "application/json" }, |
| 25 | + body: JSON.stringify({ model: "gpt-4o", input: [] }), |
| 26 | + }) |
| 27 | + expect(res.status).toBe(501) |
| 28 | + const body = (await res.json()) as { error: { code: string } } |
| 29 | + expect(body.error.code).toBe("responses_not_implemented") |
| 30 | + }) |
| 31 | + |
| 32 | + test("empty body returns 501 (not 500)", async () => { |
| 33 | + const res = await server.request("/v1/responses", { |
| 34 | + method: "POST", |
| 35 | + // no body |
| 36 | + }) |
| 37 | + expect(res.status).toBe(501) |
| 38 | + }) |
| 39 | +}) |
0 commit comments