milestone 30: overview as a dashboard, explicit health contract, period aggregations

This commit is contained in:
2026-08-22 16:45:15 +02:00
parent 0e83477d80
commit 623667e475
89 changed files with 7222 additions and 4239 deletions
+38
View File
@@ -0,0 +1,38 @@
import { health } from "@/lib/healthFixture";
import { diagnosticsBadge } from "./diagnosticsBadge";
test("a healthy box with nothing open wears no badge", () => {
expect(diagnosticsBadge(health(), false)).toBeNull();
});
test("open episodes are the count, warnings and errors together", () => {
const badge = diagnosticsBadge(
health({ diagnostics: { state: "recording", active_warnings: 2, active_errors: 1 } }),
false,
);
expect(badge).toEqual({ text: "3", label: "3 active diagnostic events" });
});
test("one open episode is counted in the singular", () => {
const badge = diagnosticsBadge(
health({ diagnostics: { state: "recording", active_warnings: 0, active_errors: 1 } }),
false,
);
expect(badge).toEqual({ text: "1", label: "1 active diagnostic event" });
});
test("a degraded rollup with no open episode still shows, so no degraded state is invisible", () => {
const badge = diagnosticsBadge(health({ status: "degraded" }), false);
expect(badge).toEqual({ text: "!", label: "Health degraded" });
});
test("a failed poll is not evidence of health, badge and all", () => {
// Cached body says everything is fine; the poll that would have confirmed it
// never landed. An unbadged item here claims health on no evidence.
expect(diagnosticsBadge(health(), true)).toEqual({ text: "!", label: "Health unavailable" });
expect(diagnosticsBadge(undefined, true)).toEqual({ text: "!", label: "Health unavailable" });
});
test("the first poll being in flight is the one unknown that hides", () => {
expect(diagnosticsBadge(undefined, false)).toBeNull();
});