import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; import test from "node:test"; import { metricRefreshInterval } from "../lib/systemLoadChartView.ts"; const source = readFileSync(new URL("./Overview.tsx", import.meta.url), "utf8"); const appDetailSource = readFileSync(new URL("./AppDetail.tsx", import.meta.url), "utf8"); const systemLoadChartSource = readFileSync(new URL("../lib/systemLoadChartView.ts", import.meta.url), "utf8"); test("overview uses live statistics instead of hardcoded chart data", () => { assert.doesNotMatch(source, /mockHistoryData|09:00|09:30|Last 3h/); assert.match(source, /getStatisticsSummary/); assert.match(source, /buildSystemLoadChartData/); assert.match(systemLoadChartSource, /cpuHistory/); assert.match(systemLoadChartSource, /ramHistory/); }); test("overview does not show setup-complete cards when there are no setup problems", () => { assert.doesNotMatch(source, /Coverage plan|Setup voltooid|Live setup is klaar|setup is klaar/i); assert.match(source, /setupProblems/); }); test("overview uses independent live queries so one failed source does not blank the route", () => { assert.match(source, /useQuery/); assert.match(source, /summaryQuery\.data \?\? null/); assert.match(source, /appsQuery\.data \?\? \[\]/); assert.match(source, /\.every\(query => query\.isPending\)/); }); test("overview refreshes fast metrics separately from connector-heavy intelligence", () => { assert.equal(metricRefreshInterval("visible"), 5_000); assert.equal(metricRefreshInterval("hidden"), false); assert.match(source, /system-summary[\s\S]*refetchInterval: 10_000/); assert.match(source, /safety-dashboard[\s\S]*refetchInterval: 60_000/); assert.match(source, /storage-summary[\s\S]*refetchInterval: 60_000/); assert.match(source, /getAuditLogs\(5\)/); }); test("overview only shows latest action copy when live summary has one", () => { assert.match(source, /summary\?\.lastAction \?/); assert.match(source, /Live status, acties en aandachtspunten staan klaar/); }); test("overview keeps unresolved cards explicit instead of showing false zero values", () => { assert.match(source, /appsQuery\.isPending \? "—"/); assert.match(source, /storageQuery\.isPending \? "—"/); assert.match(source, /safetyQuery\.isPending \? "—"/); }); test("app detail resource chart uses live container metrics instead of sample data", () => { assert.doesNotMatch(appDetailSource, /mockChartData|10:00|Last 30m/); assert.match(appDetailSource, /resourceChartData/); assert.match(appDetailSource, /metricPercent/); });