Merge pull request #142 from pikasTech/fix/gate-diagnostics-contract
fix: add Cloud Web gate route contract
This commit is contained in:
@@ -466,7 +466,8 @@ async function serveCloudWeb() {
|
||||
return;
|
||||
}
|
||||
|
||||
const relativePath = url.pathname === "/" ? "index.html" : url.pathname.slice(1);
|
||||
const routePath = url.pathname.replace(/\/+$/, "") || "/";
|
||||
const relativePath = routePath === "/" || routePath === "/gate" || routePath === "/diagnostics/gate" ? "index.html" : url.pathname.slice(1);
|
||||
for (const root of roots) {
|
||||
const candidate = path.resolve(root, relativePath);
|
||||
if (!candidate.startsWith(root)) continue;
|
||||
|
||||
@@ -58,6 +58,8 @@ const diagnosticsRequiredTerms = Object.freeze([
|
||||
"patch-panel DO1 -> DI1"
|
||||
]);
|
||||
|
||||
const gateRouteAliases = Object.freeze(["/gate", "/diagnostics/gate"]);
|
||||
|
||||
const incompletePrimaryNavLabels = Object.freeze(["台", "证", "诊", "帮"]);
|
||||
|
||||
const requiredWiringColumns = Object.freeze([
|
||||
@@ -142,6 +144,8 @@ function runStaticSmoke() {
|
||||
const blockers = [];
|
||||
const files = readStaticFiles();
|
||||
const source = Object.values(files).join("\n");
|
||||
const artifactPublisher = readText("scripts/dev-artifact-publish.mjs");
|
||||
const buildScript = readText("web/hwlab-cloud-web/scripts/build.mjs");
|
||||
|
||||
addCheck(checks, blockers, "static-web-assets", assetsExist(), "Cloud Web source assets are present.", {
|
||||
evidence: requiredWebAssets.map((file) => `web/hwlab-cloud-web/${file}`)
|
||||
@@ -177,6 +181,11 @@ function runStaticSmoke() {
|
||||
evidence: diagnosticsRequiredTerms
|
||||
});
|
||||
|
||||
addCheck(checks, blockers, "internal-gate-route-aliases", gateRouteAliasesAreServed(files.app, artifactPublisher, buildScript), "/gate and /diagnostics/gate are direct internal diagnostic aliases, not default routes.", {
|
||||
blocker: "runtime_blocker",
|
||||
evidence: gateRouteAliases
|
||||
});
|
||||
|
||||
addCheck(checks, blockers, "feedback-120-wiring-table", wiringTableContract(files.html), "Patch-panel wiring panel is a table with source, target, status, evidence source, and trace/evidence columns.", {
|
||||
blocker: "contract_blocker",
|
||||
evidence: requiredWiringColumns
|
||||
@@ -398,6 +407,15 @@ function gateRetainsDiagnostics(html, app) {
|
||||
return diagnosticsRequiredTerms.every((term) => gateSource.includes(term));
|
||||
}
|
||||
|
||||
function gateRouteAliasesAreServed(app, artifactPublisher, buildScript) {
|
||||
return (
|
||||
/internalGatePathnames\(\)\.has/u.test(app) &&
|
||||
gateRouteAliases.every((route) => app.includes(`"${route}"`)) &&
|
||||
gateRouteAliases.every((route) => artifactPublisher.includes(`routePath === "${route}"`)) &&
|
||||
/\["gate", "diagnostics\/gate"\]/u.test(buildScript)
|
||||
);
|
||||
}
|
||||
|
||||
function wiringTableContract(html) {
|
||||
const wiringPanel = html.match(/<section\b[^>]*\bdata-side-panel=["']wiring["'][\s\S]*?<\/section>/u)?.[0] ?? "";
|
||||
return requiredWiringColumns.every((column) => wiringPanel.includes(`<th>${column}</th>`));
|
||||
|
||||
Reference in New Issue
Block a user