Files
UHD_Media_Tool/apps/server/test/health.test.ts
T
umtandClaude Fable 5.1 b22c440139 chore: scaffold monorepo and migrate uhd_web design system (W0-A)
- pnpm workspace: apps/{web,server}, packages/{contracts,db,domain,adapters,tasks,agent,testkit}
- server: Hono + zod-openapi, API Key auth with scopes, redacting pino logger, SSE event bus with replay, worker heartbeat
- db: Kysely + pg, file migrator, 0001_init (settings/api_key/audit_event/outbox_event)
- web: React Router 7 SPA console shell with 12 workspace placeholders, uhd_web tokens/ui/guard scripts
- docs: ADR-001 (Node over Deno), dev runbook, design system rules

Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-09-27 17:36:26 +08:00

29 lines
940 B
TypeScript

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();
});
});