Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/apps/web/app/utils/logger.server.test.ts
T

30 lines
1.3 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { requireWebLogIdentity } from "./logger.server";
describe("web logger runtime identity", () => {
it.each([
["core", "hivegrid-web"],
["admin", "hivegrid-admin"],
["portal", "hivegrid-portal"],
] as const)("maps %s to service=%s", (surface, service) => {
expect(requireWebLogIdentity({ WEB_RUNTIME_SURFACE: surface })).toEqual({ service, surface });
});
it("fails closed outside tests when the runtime surface is missing or invalid", () => {
expect(() => requireWebLogIdentity({ NODE_ENV: "production", WEB_RUNTIME_SURFACE: undefined })).toThrow(
"WEB_RUNTIME_SURFACE must be explicitly set to core, admin, or portal"
);
expect(() => requireWebLogIdentity({ NODE_ENV: "production", WEB_RUNTIME_SURFACE: "customer" })).toThrow(
"WEB_RUNTIME_SURFACE must be explicitly set to core, admin, or portal"
);
});
it("uses an explicit Core fallback for test tooling only", () => {
expect(requireWebLogIdentity({ NODE_ENV: "test", WEB_RUNTIME_SURFACE: undefined })).toEqual({ service: "hivegrid-web", surface: "core" });
expect(() => requireWebLogIdentity({ NODE_ENV: "test", WEB_RUNTIME_SURFACE: "customer" })).toThrow(
"WEB_RUNTIME_SURFACE must be explicitly set to core, admin, or portal"
);
});
});