- lock the three-column height chain on workbench/PartDesign pages so each side panel scrolls independently and the centre stage keeps its size - dock module task panels above the layout with their own scrollbar instead of letting them push the stage out of the viewport - add tools/layout-probe.mjs (page scroll, aside bounds, pane scrolling, stage stability) and CLI mode for tools/static-host.mjs with relative --root support - add the P0-P4 browser functional suite, manual scenarios and capture tooling; document it under docs/current/web-functional-suite Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
107 lines
4.3 KiB
JavaScript
107 lines
4.3 KiB
JavaScript
#!/usr/bin/env node
|
|
// Verify the generated UI design document in a real browser.
|
|
//
|
|
// Reuses tools/fcweb/capture.mjs. Checks structure (chapter anchors, appendix
|
|
// row count), page health (errors, broken images, overflow) at two viewports,
|
|
// and that every screenshot the document references actually exists.
|
|
//
|
|
// node web/tools/manual/check-ui-design-doc.mjs
|
|
// DOC_URL=http://127.0.0.1:5199/evidence/current/web-freecad-ui-layout-and-functions.html \
|
|
// node web/tools/manual/check-ui-design-doc.mjs
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
import { launchBrowser, openPage, writeArtifact } from "../../../tools/fcweb/capture.mjs";
|
|
|
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
const webRoot = path.resolve(here, "../..");
|
|
const repoRoot = path.resolve(webRoot, "..");
|
|
const docPath = path.join(repoRoot, "docs/current/web-freecad-ui-layout-and-functions.html");
|
|
const inventoryPath = path.join(repoRoot, "tools/fcweb/out/ui-inventory.json");
|
|
const outDir = path.join(repoRoot, "docs/current/ui-design/data");
|
|
|
|
if (!fs.existsSync(docPath)) {
|
|
console.error(`[check-ui-design-doc] missing document: ${docPath}`);
|
|
process.exit(2);
|
|
}
|
|
const inventory = JSON.parse(fs.readFileSync(inventoryPath, "utf8"));
|
|
const expectedChapters = inventory.chapters.map(chapter => `wb-${chapter.id}`);
|
|
const expectedAppendix = inventory.appendix.length;
|
|
|
|
const url = process.env.DOC_URL || pathToFileURL(docPath).href;
|
|
const browser = await launchBrowser({ headed: false });
|
|
const viewports = [{ width: 1440, height: 900 }, { width: 390, height: 844 }];
|
|
const reports = [];
|
|
|
|
try {
|
|
for (const viewport of viewports) {
|
|
const { page, response, errors, failedRequests } = await openPage(browser, url, { viewport });
|
|
try {
|
|
// Force lazy images to load so the broken-image check is meaningful.
|
|
await page.evaluate(async () => {
|
|
for (const image of document.images) image.loading = "eager";
|
|
window.scrollTo(0, document.body.scrollHeight);
|
|
await new Promise(resolve => setTimeout(resolve, 800));
|
|
window.scrollTo(0, 0);
|
|
});
|
|
await page.waitForTimeout(600);
|
|
|
|
const dom = await page.evaluate(() => {
|
|
const brokenImages = [...document.images]
|
|
.filter(image => image.getAttribute("src"))
|
|
.filter(image => image.complete && image.naturalWidth === 0)
|
|
.map(image => image.currentSrc || image.src);
|
|
const doc = document.documentElement;
|
|
const ids = [...document.querySelectorAll("[id]")].map(node => node.id);
|
|
const duplicated = ids.filter((id, index) => ids.indexOf(id) !== index);
|
|
return {
|
|
overflow: Math.max(0, doc.scrollWidth - doc.clientWidth),
|
|
brokenImages,
|
|
ids,
|
|
duplicatedIds: [...new Set(duplicated)],
|
|
chapters: document.querySelectorAll("section.wb").length,
|
|
appendixRows: document.querySelectorAll("tr[data-appendix-row]").length,
|
|
tocLinks: document.querySelectorAll("nav.toc a").length,
|
|
images: document.images.length,
|
|
};
|
|
});
|
|
|
|
const missing = expectedChapters.filter(id => !dom.ids.includes(id));
|
|
reports.push({
|
|
viewport,
|
|
status: response?.status() ?? null,
|
|
...dom,
|
|
missingChapters: missing,
|
|
pageErrors: errors,
|
|
failedRequests: failedRequests.slice(0, 5),
|
|
ok: (response?.status() ?? 0) === 200
|
|
&& errors.length === 0
|
|
&& failedRequests.length === 0
|
|
&& dom.brokenImages.length === 0
|
|
&& dom.overflow === 0
|
|
&& missing.length === 0
|
|
&& dom.duplicatedIds.length === 0
|
|
&& dom.chapters === inventory.chapters.length
|
|
&& dom.appendixRows === expectedAppendix,
|
|
});
|
|
} finally {
|
|
await page.close();
|
|
}
|
|
}
|
|
} finally {
|
|
await browser.close();
|
|
}
|
|
|
|
const summary = {
|
|
ok: reports.every(report => report.ok),
|
|
url,
|
|
expectedChapters: expectedChapters.length,
|
|
expectedAppendixRows: expectedAppendix,
|
|
viewports: reports,
|
|
};
|
|
fs.mkdirSync(outDir, { recursive: true });
|
|
fs.writeFileSync(path.join(outDir, "doc-check.json"), `${JSON.stringify(summary, null, 2)}\n`);
|
|
console.log(JSON.stringify(summary, null, 2));
|
|
writeArtifact(outDir, "doc-check-last-run.json", summary);
|
|
process.exit(summary.ok ? 0 : 1);
|