Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -18,7 +18,14 @@ vi.mock("@sentry/node", () => {
import * as Sentry from "@sentry/node";
import { __resetSentryServerForTests, initSentryServer, parseServerSampleRate, readServerSentryConfig, webErrorReporter } from "./sentry.server";
import {
__resetSentryServerForTests,
initSentryServer,
parseServerSampleRate,
readServerSentryConfig,
requireServerSentryService,
webErrorReporter,
} from "./sentry.server";
const mockedInit = Sentry.init as unknown as ReturnType<typeof vi.fn>;
const mockedRequestData = Sentry.requestDataIntegration as unknown as ReturnType<typeof vi.fn>;
@@ -38,7 +45,7 @@ describe("sentry.server/parseServerSampleRate", () => {
describe("sentry.server/readServerSentryConfig", () => {
it("returns undefined dsn for empty env", () => {
expect(readServerSentryConfig({} as NodeJS.ProcessEnv).dsn).toBeUndefined();
expect(readServerSentryConfig({} as NodeJS.ProcessEnv)).toMatchObject({ dsn: undefined, service: undefined });
});
it("reads SENTRY_DSN_WEB and friends", () => {
@@ -48,11 +55,34 @@ describe("sentry.server/readServerSentryConfig", () => {
SENTRY_ENVIRONMENT: "staging",
SENTRY_TRACES_SAMPLE_RATE: "0.25",
NODE_ENV: "production",
WEB_RUNTIME_SURFACE: "core",
} as unknown as NodeJS.ProcessEnv);
expect(config.dsn).toBe("https://srv@sentry.example/2");
expect(config.release).toBe("v9");
expect(config.environment).toBe("staging");
expect(config.tracesSampleRate).toBe(0.25);
expect(config.service).toBe("hivegrid-web");
});
it("falls back to the immutable image revision when SENTRY_RELEASE is empty", () => {
const config = readServerSentryConfig({
SENTRY_DSN_WEB: "https://srv@sentry.example/2",
SENTRY_RELEASE: "",
APP_REVISION: "sha-web",
WEB_RUNTIME_SURFACE: "core",
} as unknown as NodeJS.ProcessEnv);
expect(config.release).toBe("sha-web");
});
it("uses distinct Admin and Portal services and fails closed for invalid configured surfaces", () => {
expect(requireServerSentryService({ WEB_RUNTIME_SURFACE: "admin" })).toBe("hivegrid-admin");
expect(requireServerSentryService({ WEB_RUNTIME_SURFACE: "portal" })).toBe("hivegrid-portal");
expect(() =>
readServerSentryConfig({
SENTRY_DSN_WEB: "https://srv@sentry.example/2",
WEB_RUNTIME_SURFACE: "customer",
} as unknown as NodeJS.ProcessEnv)
).toThrow("WEB_RUNTIME_SURFACE must be explicitly set to core, admin, or portal");
});
});
@@ -74,11 +104,25 @@ describe("sentry.server/initSentryServer", () => {
environment: "test",
release: undefined,
tracesSampleRate: 0.1,
service: undefined,
})
).toBe(false);
expect(mockedInit).not.toHaveBeenCalled();
});
it("fails closed when a configured DSN has no surface service identity", () => {
expect(() =>
initSentryServer({
dsn: "https://srv@sentry.example/2",
environment: "test",
release: undefined,
tracesSampleRate: 0.1,
service: undefined,
})
).toThrow("Server Sentry service identity is required");
expect(mockedInit).not.toHaveBeenCalled();
});
it("initializes Sentry with PII-safe requestDataIntegration", () => {
expect(
initSentryServer({
@@ -86,6 +130,7 @@ describe("sentry.server/initSentryServer", () => {
environment: "prod",
release: "rel-1",
tracesSampleRate: 0.2,
service: "hivegrid-portal",
})
).toBe(true);
expect(mockedInit).toHaveBeenCalledTimes(1);
@@ -94,7 +139,17 @@ describe("sentry.server/initSentryServer", () => {
expect(initArgs.environment).toBe("prod");
expect(initArgs.release).toBe("rel-1");
expect(initArgs.tracesSampleRate).toBe(0.2);
expect(initArgs.initialScope).toEqual({ tags: { service: "hivegrid-portal" } });
expect(initArgs.sendDefaultPii).toBe(false);
expect(typeof initArgs.beforeSend).toBe("function");
const portalToken = "p".repeat(43);
const sanitized = (initArgs.beforeSend as (event: Record<string, unknown>) => Record<string, unknown>)({
request: { url: `https://portal.example.test/__portal/acme/verify-email/${portalToken}` },
exception: { values: [{ type: "Error", value: "Bearer raw-secret" }] },
});
expect(JSON.stringify(sanitized)).not.toContain(portalToken);
expect(JSON.stringify(sanitized)).not.toContain("raw-secret");
expect(mockedRequestData).toHaveBeenCalledTimes(1);
const rdOpts = mockedRequestData.mock.calls[0][0] as Record<string, unknown>;
@@ -111,6 +166,7 @@ describe("sentry.server/initSentryServer", () => {
environment: undefined,
release: undefined,
tracesSampleRate: 0.1,
service: "hivegrid-web" as const,
};
expect(initSentryServer(config)).toBe(true);
expect(initSentryServer(config)).toBe(true);
@@ -137,11 +193,13 @@ describe("sentry.server/webErrorReporter", () => {
environment: undefined,
release: undefined,
tracesSampleRate: 0.1,
service: "hivegrid-portal",
});
const err = new Error("boom");
await webErrorReporter.report({ component: "loader", operation: "x", error: err });
expect(mockedCaptureException).toHaveBeenCalledTimes(1);
expect(mockedCaptureException.mock.calls[0][0]).toBe(err);
expect(mockedCaptureException.mock.calls[0][1]).toMatchObject({ tags: { service: "hivegrid-portal" } });
});
it("captures messages when no error is provided", async () => {
@@ -150,6 +208,7 @@ describe("sentry.server/webErrorReporter", () => {
environment: undefined,
release: undefined,
tracesSampleRate: 0.1,
service: "hivegrid-web",
});
await webErrorReporter.report({ component: "loader", operation: "x", errorMessage: "explicit-message" });
expect(mockedCaptureMessage).toHaveBeenCalledTimes(1);