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

33 lines
935 B
TypeScript

import { describe, expect, it, vi } from "vitest";
vi.mock("~/utils/db.server", () => ({
db: {
appConfiguration: {
count: vi.fn(),
},
},
}));
describe("web healthz route", () => {
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: "web", 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" });
});
});