import { describe, expect, it } from "vitest"; import { json, testApp } from "./helpers"; describe("GET /api/v1/health", () => { it("免鉴权返回 ok 信封", async () => { const { app } = testApp(); const res = await app.request("/api/v1/health"); expect(res.status).toBe(200); const body = await json(res); expect(body.ok).toBe(true); expect(body.data.status).toBe("ok"); expect(body.data.db).toBe("unknown"); expect(body.data.role).toBe("all"); }); it("未知路由返回 not_found 信封", async () => { const { app } = testApp(); const res = await app.request("/nope"); expect(res.status).toBe(404); expect((await json(res)).error.code).toBe("not_found"); }); it("OpenAPI 文档包含 health", async () => { const { app } = testApp(); const doc = await json(await app.request("/api/openapi.json")); expect(doc.paths["/api/v1/health"]).toBeDefined(); }); });