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

@@ -0,0 +1,112 @@
// @vitest-environment node
import { beforeEach, describe, expect, it, vi } from "vitest";
const portalData = vi.hoisted(() => ({
requirePortalSessionContext: vi.fn(),
loadPortalProjectDataset: vi.fn(),
}));
const portalInteractions = vi.hoisted(() => ({
loadPortalProjectInteractionsVM: vi.fn(),
}));
vi.mock("~/components/screens/customer-portal/CustomerPortalInterimPages", () => ({
CustomerPortalProjectDetailPage: () => null,
}));
vi.mock("~/services/customer-portal/portal-data.server", () => ({
...portalData,
portalNotFound: () => new Response(null, { status: 404, headers: { "Cache-Control": "no-store" } }),
}));
vi.mock("~/services/customer-portal/portal-interactions-data.server", () => portalInteractions);
vi.mock("~/locale/i18next.server", () => ({ getTranslations: vi.fn(async () => ({ t: (key: string) => `translated:${key}` })) }));
import { loader } from "./project-detail";
const identity = {
tenantId: "tenant-1",
portalId: "portal-1",
portalUserId: "portal-user-1",
portalSessionId: "portal-session-1",
tenantSlug: "acme",
tenantFrozen: false,
portalTitle: "Acme Portal",
viewerFirstName: "Karla",
viewerLastName: "Kunde",
viewerLocale: "de",
origin: "https://portal.hivegrid.de",
createdAt: new Date("2026-07-15T10:00:00.000Z"),
lastSeenAt: new Date("2026-07-15T11:00:00.000Z"),
expiresAt: new Date("2026-07-16T12:00:00.000Z"),
} as const;
const visibleProject = {
id: "project-visible",
projectNumber: "P-1001",
name: "Sichtbares Projekt",
updatedAt: "2026-07-15T10:00:00.000Z",
currentStageOrder: 10,
hasActiveAccess: true,
stages: [{ id: "stage-1", label: "Planung", order: 10, visible: true }],
documents: [],
} as const;
function loadProject(projectId: string): Promise<Response> {
return loader({
request: new Request(`https://portal.hivegrid.de/__portal/acme/projects/${projectId}`, {
headers: { "x-hivegrid-portal-tenant": "acme" },
}),
params: { tenant: "acme", projectId },
context: {},
unstable_pattern: "/__portal?/:tenant/projects/:projectId",
}) as Promise<Response>;
}
describe("customer portal project-detail boundary", () => {
beforeEach(() => {
vi.clearAllMocks();
portalData.requirePortalSessionContext.mockResolvedValue({
identity,
origin: {
origin: "https://portal.hivegrid.de",
hostname: "portal.hivegrid.de",
tenantSlug: "acme",
customHost: false,
},
responseHeaders: new Headers({ "Cache-Control": "no-store", "Set-Cookie": "portal-session=refreshed" }),
});
portalData.loadPortalProjectDataset.mockResolvedValue({ identity, projects: [visibleProject] });
portalInteractions.loadPortalProjectInteractionsVM.mockResolvedValue({ status: "empty" });
});
it("returns byte-identical opaque 404 payloads for inaccessible and missing project ids", async () => {
// The first id represents an existing project omitted by the access-scoped
// dataset; the second does not exist. The route must not reveal which case
// occurred through status, headers, or response data.
const inaccessible = await loadProject("project-outside-access");
const missing = await loadProject("project-does-not-exist");
expect(inaccessible.status).toBe(404);
expect(missing.status).toBe(404);
expect(inaccessible.headers.get("Cache-Control")).toBe("no-store");
expect(inaccessible.headers.get("Set-Cookie")).toBe("portal-session=refreshed");
expect([...inaccessible.headers]).toEqual([...missing.headers]);
expect(await inaccessible.text()).toBe(await missing.text());
expect(portalData.loadPortalProjectDataset).toHaveBeenCalledTimes(2);
});
it("returns the detail only when it is present in the access-scoped dataset", async () => {
const response = await loadProject("project-visible");
const data = await response.json();
expect(response.status).toBe(200);
expect(response.headers.get("Set-Cookie")).toBe("portal-session=refreshed");
expect(data).toMatchObject({
tenantSlug: "acme",
vm: { status: "ready", data: { id: "project-visible", name: "Sichtbares Projekt" } },
});
expect(portalInteractions.loadPortalProjectInteractionsVM).toHaveBeenCalledWith(
expect.objectContaining({ pendingFilename: "translated:customerPortal.upload.pendingFilename" })
);
});
});