import { renderToString } from "react-dom/server";
import { describe, expect, test } from "vitest";
import { Button } from "./Button";
import { DashboardFrame } from "./DashboardFrame";
import { FooterCell } from "./FooterCell";
import { IconButton } from "./IconButton";
import { ServiceRow } from "./ServiceRow";
import { TelemetryCard } from "./TelemetryCard";
import { dashboardPreviewFixtures } from "../fixtures";
describe("dashboard UI components", () => {
test("renders the primary generic dashboard fixture", () => {
const body = renderToString(
,
);
expect(body).toContain("Operations Console");
expect(body).toContain("Core Throughput");
expect(body).toContain("Queue Workers");
expect(body).toContain("data-icon-name=\"mdi:server-network\"");
expect(body).toContain("data-severity=\"warning\"");
expect(body).not.toContain("dashboard-title");
});
test("renders another generic dashboard fixture through the same component", () => {
const body = renderToString(
,
);
expect(body).toContain("Support Desk");
expect(body).toContain("Response Window");
expect(body).toContain("Regional Nodes");
expect(body).toContain("data-icon-name=\"mdi:headset\"");
expect(body).toContain("data-severity=\"loading\"");
});
test("renders optional service and status links as focusable anchors", () => {
const service = renderToString(
,
);
const footer = renderToString(
,
);
expect(service).toContain(" {
const body = renderToString(
,
);
expect(body).toContain("data-model-id=\"queue-workers\"");
expect(body).toContain("data-model-id=\"dashboard-status\"");
});
test("does not render progress bars for non-percent metrics without explicit progress", () => {
const withoutProgress = renderToString(
,
);
const withProgress = renderToString(
,
);
expect(withoutProgress).not.toContain("telemetry-card__bar");
expect(withProgress).toContain("--metric-progress:42%");
});
test("renders telemetry trends through the uPlot chart surface", () => {
const body = renderToString(
,
);
expect(body).toContain('data-chart-library="uplot"');
});
test("base button controls forward native attributes", () => {
const button = renderToString(
,
);
const iconButton = renderToString(
,
);
expect(button).toContain("id=\"refresh-action\"");
expect(button).toContain("class=\"ui-button custom-action ");
expect(button).toContain("aria-controls=\"refresh-target\"");
expect(iconButton).toContain("id=\"refresh-icon-action\"");
expect(iconButton).toContain("class=\"icon-button custom-icon-action ");
expect(iconButton).toContain("aria-expanded=\"false\"");
});
});