Spaces:
Sleeping
Sleeping
File size: 2,666 Bytes
7d5735a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import test from "node:test";
function readText(relativePath) {
return readFileSync(new URL(relativePath, import.meta.url), "utf8");
}
function assertPartialMapping(indexHtml, id, url) {
const escapedUrl = url.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const pattern = new RegExp(`id:\\s*"${id}"[\\s\\S]*?url:\\s*"${escapedUrl}"`);
assert.ok(
pattern.test(indexHtml),
`Expected partial mapping ${id} -> ${url}`,
);
}
test("dashboard operation/config panels include the expected containers", () => {
const indexHtml = readText("../index.html");
const operationPanel =
indexHtml.match(
/id="dashboardTabOperationPanel"[\s\S]*?<\/section>/,
)?.[0] || "";
const configPanel =
indexHtml.match(/id="dashboardTabConfigPanel"[\s\S]*?<\/section>/)?.[0] ||
"";
assert.ok(operationPanel.includes('id="metricsHealthContainer"'));
assert.ok(operationPanel.includes('id="riskQueueContainer"'));
assert.ok(operationPanel.includes('id="autonomyRuntimeContainer"'));
assert.ok(operationPanel.includes('id="operationEventsContainer"'));
assert.ok(configPanel.includes('id="controlPlaneContainer"'));
});
test("dashboard partial loader maps new phase-2 containers correctly", () => {
const indexHtml = readText("../index.html");
assertPartialMapping(
indexHtml,
"controlPlaneContainer",
"/dashboard/partials/control_plane.html",
);
assertPartialMapping(
indexHtml,
"autonomyRuntimeContainer",
"/dashboard/partials/autonomy_runtime.html",
);
assertPartialMapping(
indexHtml,
"operationEventsContainer",
"/dashboard/partials/operational_events.html",
);
assertPartialMapping(
indexHtml,
"analyticsLogsContainer",
"/dashboard/partials/analytics_logs.html",
);
});
test("phase-2 partial split keeps IDs in the right files", () => {
const controlPlaneHtml = readText("../partials/control_plane.html");
const autonomyRuntimeHtml = readText("../partials/autonomy_runtime.html");
const analyticsLogsHtml = readText("../partials/analytics_logs.html");
const operationalEventsHtml = readText("../partials/operational_events.html");
assert.ok(controlPlaneHtml.includes('id="cpPanel"'));
assert.ok(!controlPlaneHtml.includes('id="autRunTickBtn"'));
assert.ok(autonomyRuntimeHtml.includes('id="autRunTickBtn"'));
assert.ok(autonomyRuntimeHtml.includes('id="autBudgetPctText"'));
assert.ok(!analyticsLogsHtml.includes('id="eventsList"'));
assert.ok(analyticsLogsHtml.includes('id="timelineBody"'));
assert.ok(operationalEventsHtml.includes('id="eventsList"'));
});
|