// @vitest-environment jsdom
import "@testing-library/jest-dom/vitest";
import { render } from "@testing-library/react";
import { createMemoryRouter, RouterProvider } from "react-router";
import { describe, expect, it, vi } from "vitest";
import {
ADMIN_TENANT_NOTE_CATEGORIES,
buildAdminBillingVM,
buildAdminConnectorListVM,
buildAdminTenantNoteListVM,
buildOperatorHealthVM,
buildQueueMonitorVM,
buildSupportConversationVM,
} from "@hivegrid/view-models";
import { AdminBillingPage } from "./AdminBillingPage";
import { AdminHealthPage } from "./AdminHealthPage";
import { AdminJobsPage } from "./AdminJobsPage";
import { AdminSupportInboxPage } from "./AdminSupportInboxPage";
import { AdminSupportTicketPage } from "./AdminSupportTicketPage";
import { AdminTenantCreatePage } from "./AdminTenantCreatePage";
import { AdminTenantOperationsPanel } from "./AdminTenantOperationsPanel";
vi.mock("react-i18next", () => ({
useTranslation: () => ({ t: (key: string) => key, i18n: { language: "de", exists: () => false } }),
}));
// Radix Select measures itself; jsdom has no ResizeObserver.
class ResizeObserverStub {
observe(): void {}
unobserve(): void {}
disconnect(): void {}
}
globalThis.ResizeObserver = globalThis.ResizeObserver ?? (ResizeObserverStub as unknown as typeof ResizeObserver);
vi.mock("~/locale/format", () => ({
// toISOString keeps the baseline timezone-independent (CI runs in UTC, dev machines in CEST).
useLocaleFormatters: () => ({ number: (value: number) => String(value), dateTime: (value: string | Date) => new Date(value).toISOString() }),
}));
describe("AK-P19 interim visual baseline", () => {
it("renders billing, queue, health and support ready states from ~/ui", () => {
const billing = buildAdminBillingVM({
rows: [
{
tenantId: "tenant-1",
tenantName: "Musterbetrieb GmbH",
tenantSlug: "musterbetrieb",
status: "active",
readOnly: false,
planCode: "starter",
seatQuantity: 5,
lagoCustomerId: "lago-1",
mollieCustomerId: "mollie-1",
lastInvoiceExternalId: "invoice-1",
lastPaymentExternalId: "payment-1",
currentPeriodStart: "2026-07-01",
currentPeriodEnd: "2026-08-01",
pastDueSince: null,
frozenAt: null,
cancelledAt: null,
entitlementCount: 4,
},
],
});
const queues = buildQueueMonitorVM({
queues: [{ queueName: "notifications", group: "notification", active: 1, waiting: 2, delayed: 0, failed: 0, completed: 40, paused: false }],
});
const health = buildOperatorHealthVM({
subsystems: [{ id: "queues", status: "ok", href: "/system/jobs" }],
deploy: { environment: "staging", release: "abc123", revision: "1", branch: "main" },
signals: { failedJobsTotal: 0, pausedQueues: 0, webhookFailures: 0, billingErrors: 0 },
links: { jobs: "/system/jobs", webhooks: "/system/webhooks", billing: "/system/billing" },
billingErrors: [],
});
const router = createMemoryRouter(
[
{
path: "*",
element: (
),
},
],
{ initialEntries: ["/system/billing"] }
);
const { container } = render();
expect(container.querySelectorAll("[data-ui-id$='.page']")).toHaveLength(4);
const stableMarkup = container.innerHTML.replace(/