Files
pikasTech-HWLAB/web/hwlab-cloud-web/scripts/check.mjs
T
Lyon 4ebb1e4aa6 feat: add HWLAB DEV console homepage
Refs #59

Merged by commander after reviewing Code Queue task codex_1779422758441_1. Source-only frontend PR; deployment/DEV verification remains as follow-up.
2026-05-22 12:25:41 +08:00

72 lines
2.8 KiB
JavaScript

import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { loadMvpGateSummary } from "../../../internal/mvp-gate/summary.mjs";
import { gateSummary } from "../gate-summary.mjs";
const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
const repoRoot = path.resolve(rootDir, "../..");
const requiredFiles = ["index.html", "styles.css", "app.mjs", "gate-summary.mjs"];
for (const file of requiredFiles) {
const filePath = path.resolve(rootDir, file);
if (!fs.existsSync(filePath)) {
throw new Error(`missing web asset: ${file}`);
}
}
const html = fs.readFileSync(path.resolve(rootDir, "index.html"), "utf8");
const app = fs.readFileSync(path.resolve(rootDir, "app.mjs"), "utf8");
const frontendSource = `${html}\n${app}`;
assert.match(html, /HWLAB DEV Console/);
assert.match(html, /DEV Control Console/);
for (const moduleName of [
"Overview",
"Topology / Patch Panel",
"Hardware Operations",
"Agent Sessions",
"Evidence / Audit",
"Gate / Diagnostics"
]) {
assert.match(html, new RegExp(moduleName.replaceAll("/", "\\/")));
}
for (const viewId of ["overview", "topology", "hardware", "agents", "evidence", "gate"]) {
assert.match(html, new RegExp(`data-view="${viewId}"`));
}
assert.match(html, /live-status/);
assert.match(html, /method-grid/);
assert.match(html, /runtime-metrics/);
assert.match(html, /operation-body/);
assert.match(html, /audit-body/);
assert.match(html, /evidence-body/);
assert.match(app, /fetchJson\("\/v1"\)/);
assert.match(app, /callRpc\("system\.health"\)/);
assert.match(app, /callRpc\("cloud\.adapter\.describe"\)/);
assert.match(app, /callRpc\("audit\.event\.query"/);
assert.match(app, /callRpc\("evidence\.record\.query"/);
assert.match(app, /degraded/);
assert.doesNotMatch(app, /callRpc\("hardware\./);
assert.doesNotMatch(frontendSource, /74\.48\.78\.17:666[67]\b|:666[67]\b/);
const sourceSummary = loadMvpGateSummary(repoRoot);
assert.equal(gateSummary.endpoint, sourceSummary.endpoint);
assert.equal(gateSummary.gateStatus, sourceSummary.gateStatus);
assert.equal(gateSummary.milestones.length, 6);
assert.deepEqual(
gateSummary.milestones.map((item) => item.id),
["M0", "M1", "M2", "M3", "M4", "M5"]
);
assert.equal(gateSummary.artifactCount, 13);
assert.equal(gateSummary.healthCount, 14);
assert.equal(gateSummary.gatewaySessionCount, 2);
assert.equal(gateSummary.boxResourceCount, 2);
assert.equal(gateSummary.topology.patchPanel.serviceId, "hwlab-patch-panel");
assert.equal(gateSummary.agent.agentServiceId, "hwlab-agent-mgr");
assert.equal(gateSummary.agent.workerServiceId, "hwlab-agent-worker");
assert.equal(gateSummary.evidenceRecords.length, 2);
assert.equal(gateSummary.safety.allowNetwork, false);
console.log("hwlab-cloud-web check ok: console modules and gate summary are present");