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

27 lines
1.1 KiB
TypeScript

import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import path from "node:path";
import { describe, expect, it } from "vitest";
const healthcheckSourcePath = path.join(path.dirname(fileURLToPath(import.meta.url)), "./healthcheck.tsx");
const healthcheckSource = () => readFileSync(healthcheckSourcePath, "utf8");
describe("web healthcheck route diagnostics", () => {
it("keeps the legacy healthcheck route as cheap liveness only", () => {
const source = healthcheckSource();
expect(source).toContain('new Response("OK")');
expect(source).not.toContain("~/utils/db.server");
expect(source).not.toContain("db.appConfiguration.count");
expect(source).not.toContain("fetch(");
expect(source).not.toContain("X-Forwarded-Host");
});
it("does not leave active console diagnostics in the healthcheck route", () => {
const source = healthcheckSource();
const withoutLineComments = source.replaceAll(/\/\/.*$/gm, "");
expect(withoutLineComments).not.toMatch(/\bconsole\.(?:log|error|warn|info)\s*\(/);
});
});