Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/apps/web/app/routes/healthz.test.ts
T

51 lines
1.6 KiB
TypeScript

import { afterEach, describe, expect, it, vi } from "vitest";
vi.mock("~/utils/db.server", () => ({
db: {
appConfiguration: {
count: vi.fn(),
},
},
}));
describe("web healthz route", () => {
afterEach(() => vi.unstubAllEnvs());
it("returns liveness without touching the database", async () => {
const { db } = await import("~/utils/db.server");
const { loader } = await import("./healthz");
const response = await loader();
const body = await response.json();
expect(response.status).toBe(200);
expect(body).toEqual({ status: "ok", service: "hivegrid-web", surface: "core", revision: "unknown" });
expect(db.appConfiguration.count).not.toHaveBeenCalled();
});
it("reports the injected app revision when present", async () => {
vi.stubEnv("APP_REVISION", "abc1234");
const { loader } = await import("./healthz");
const response = await loader();
await expect(response.json()).resolves.toMatchObject({ revision: "abc1234" });
});
it("reports the isolated portal surface identity", async () => {
vi.stubEnv("WEB_RUNTIME_SURFACE", "portal");
vi.stubEnv("APP_REVISION", "0123456789abcdef0123456789abcdef01234567");
const { loader } = await import("./healthz");
const response = await loader({ request: new Request("https://kunden.example.com/healthz") });
await expect(response.json()).resolves.toEqual({
status: "ok",
service: "hivegrid-portal",
surface: "portal",
revision: "0123456789abcdef0123456789abcdef01234567",
host: "kunden.example.com",
});
});
});