- 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>
75 lines
4.3 KiB
JavaScript
75 lines
4.3 KiB
JavaScript
#!/usr/bin/env node
|
|
// Checks the reducer manual on desktop and mobile: overflow, page errors,
|
|
// broken images, chapter count, search, and that the appendix's build record
|
|
// and gap list actually rendered. Writes manual/reducer/data/page-check.json.
|
|
//
|
|
// This is a separate checker from check-page.mjs because the two manuals have
|
|
// genuinely different appendices: the generic one indexes 1500+ commands, the
|
|
// reducer one records this case's build steps, gaps and acceptance numbers.
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { createRequire } from "node:module";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
const webRoot = path.resolve(here, "../..");
|
|
const require = createRequire(path.join(webRoot, "package.json"));
|
|
const { chromium } = require("playwright");
|
|
const url = process.env.MANUAL_URL || "http://127.0.0.1:5190/reducer-manual.html";
|
|
const browser = await chromium.launch({ executablePath: "/usr/bin/google-chrome", headless: true,
|
|
args: ["--no-sandbox", "--enable-unsafe-swiftshader", "--use-gl=angle", "--use-angle=swiftshader"] });
|
|
const report = { schema: "freecad-web-reducer-manual/page-check/v1", generatedAt: new Date().toISOString(), url, viewports: [] };
|
|
for (const viewport of [{ width: 1440, height: 900 }, { width: 390, height: 844 }]) {
|
|
const page = await browser.newPage({ viewport });
|
|
const errors = []; const failed = [];
|
|
page.on("pageerror", error => errors.push(String(error)));
|
|
page.on("console", message => { if (message.type() === "error") errors.push(message.text().slice(0, 200)); });
|
|
page.on("response", response => { if (response.status() >= 400) failed.push(`${response.status()} ${response.url()}`); });
|
|
const response = await page.goto(url, { waitUntil: "load", timeout: 120000 });
|
|
await page.waitForTimeout(800);
|
|
await page.evaluate(() => { for (const image of document.images) image.loading = "eager"; });
|
|
await page.waitForTimeout(1500);
|
|
const metrics = await page.evaluate(() => {
|
|
const images = [...document.images];
|
|
return {
|
|
chapters: document.querySelectorAll('nav.sidebar .chapter').length,
|
|
sections: document.querySelectorAll('main h2[id]').length,
|
|
images: images.length,
|
|
brokenImages: images.filter(image => image.src && (!image.complete || image.naturalWidth === 0)).map(image => image.src),
|
|
// Walk from each appendix heading to the next table, skipping the <p>
|
|
// that sits between them in the generated HTML.
|
|
...(() => {
|
|
const rowsAfter = id => {
|
|
const heading = document.querySelector(`h2[id^="${id}"]`);
|
|
if (!heading) return 0;
|
|
for (let node = heading.nextElementSibling; node; node = node.nextElementSibling) {
|
|
const table = node.matches(".table-scroll") ? node : node.querySelector?.(".table-scroll");
|
|
if (table) return table.querySelectorAll("tbody tr").length;
|
|
if (node.matches("h1, h2")) break;
|
|
}
|
|
return 0;
|
|
};
|
|
return { buildRows: rowsAfter("ch15-steps"), gapRows: rowsAfter("ch15-gaps"),
|
|
partRows: rowsAfter("ch15-parts"), numbersRows: rowsAfter("ch15-numbers") };
|
|
})(),
|
|
overflow: document.documentElement.scrollWidth - document.documentElement.clientWidth,
|
|
searchSize: SEARCH_INDEX.length,
|
|
};
|
|
});
|
|
await page.locator('#search').fill('轴承');
|
|
await page.waitForTimeout(300);
|
|
const searchHits = await page.locator('#search-results a').count();
|
|
if (viewport.width === 1440) await page.screenshot({ path: path.join(webRoot, "teaching", "reducer-manual.png"), fullPage: false });
|
|
report.viewports.push({ viewport, status: response?.status(), errors, failed, searchHits, ...metrics });
|
|
await page.close();
|
|
}
|
|
await browser.close();
|
|
report.ok = report.viewports.every(item => item.status === 200 && item.errors.length === 0
|
|
&& item.failed.length === 0 && item.brokenImages.length === 0 && item.overflow === 0
|
|
&& item.chapters === 13 && item.buildRows > 50 && item.gapRows >= 20
|
|
&& item.searchHits > 0);
|
|
fs.mkdirSync(path.join(webRoot, "manual", "reducer", "data"), { recursive: true });
|
|
fs.writeFileSync(path.join(webRoot, "manual", "reducer", "data", "page-check.json"), `${JSON.stringify(report, null, 2)}\n`);
|
|
console.log(JSON.stringify(report));
|
|
process.exitCode = report.ok ? 0 : 1;
|