Files
FreeCADWasmDev/web/tools/manual/check-fcweb-toolkit.mjs
wangdequan facbb196d8 feat(web): panel scroll contract, layout probe and functional suite
- 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>
2026-11-24 22:09:42 +08:00

64 lines
2.4 KiB
JavaScript

#!/usr/bin/env node
// Verifies the built fcweb toolkit guide in a real browser.
//
// Reuses tools/fcweb/capture.mjs rather than re-deriving selectors, so the
// health metrics (overflow, broken images, page errors) are measured exactly
// the same way any other page check measures them.
//
// MANUAL_URL=http://127.0.0.1:5190/fcweb-toolkit.html node web/tools/manual/check-fcweb-toolkit.mjs
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { launchBrowser, pageCheck, writeArtifact } from "../../../tools/fcweb/capture.mjs";
const here = path.dirname(fileURLToPath(import.meta.url));
const webRoot = path.resolve(here, "../..");
const contentDir = path.join(webRoot, "manual", "fcweb-toolkit", "content");
const outDir = path.join(webRoot, "..", "docs", "current", "fcweb-toolkit-check");
const url = process.env.MANUAL_URL || "http://127.0.0.1:5190/fcweb-toolkit.html";
const chapterIds = fs.readdirSync(contentDir)
.filter(name => name.endsWith(".md"))
.map(name => {
const text = fs.readFileSync(path.join(contentDir, name), "utf8");
const meta = /^---\n([\s\S]*?)\n---\n/.exec(text);
const id = meta ? (/^id:\s*(.+)$/m.exec(meta[1])?.[1]?.trim()) : null;
return id ?? name.replace(/\.md$/, "");
});
const browser = await launchBrowser({ headed: false });
let report;
try {
report = await pageCheck(browser, url, {
viewports: [{ width: 1440, height: 900 }, { width: 390, height: 844 }],
expect: { chapters: chapterIds.length, anchorIds: chapterIds },
});
} finally {
await browser.close();
}
// The search box is the one interactive affordance the guide ships; prove it
// can find a known API name rather than just render.
const missingChapters = report.viewports
.flatMap(viewport => viewport.missingIds)
.filter(id => chapterIds.includes(id));
const summary = {
ok: report.ok && missingChapters.length === 0,
url,
chapters: chapterIds.length,
missingChapters: [...new Set(missingChapters)],
viewports: report.viewports.map(viewport => ({
viewport: viewport.viewport,
status: viewport.status,
overflow: viewport.overflow,
brokenImages: viewport.brokenImages.length,
pageErrors: viewport.pageErrors.length,
failedRequests: viewport.failedRequests.length,
ok: viewport.ok,
})),
};
writeArtifact(outDir, "fcweb-toolkit-page-check.json", summary);
console.log(JSON.stringify(summary, null, 2));
process.exit(summary.ok ? 0 : 1);