- 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>
79 lines
3.5 KiB
JavaScript
79 lines
3.5 KiB
JavaScript
#!/usr/bin/env node
|
|
// Runs a manual scenario in the real app, asserts UI state and captures
|
|
// full-page / element screenshots. Usage:
|
|
// node capture.mjs --scenario ../../manual/scenarios/ch01-ui.json [--headed]
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { createRequire } from "node:module";
|
|
import { fileURLToPath } from "node:url";
|
|
import { createActionRunner } from "./lib/actions.mjs";
|
|
|
|
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 args = process.argv.slice(2);
|
|
const option = (name, fallback = "") => {
|
|
const index = args.indexOf(name);
|
|
return index < 0 ? fallback : args[index + 1] ?? fallback;
|
|
};
|
|
const scenarioPath = path.resolve(option("--scenario"));
|
|
if (!fs.existsSync(scenarioPath)) throw new Error(`missing scenario ${scenarioPath}`);
|
|
const scenario = JSON.parse(fs.readFileSync(scenarioPath, "utf8"));
|
|
const origin = option("--origin", "http://127.0.0.1:5181");
|
|
const headed = args.includes("--headed");
|
|
const chapter = scenario.chapter;
|
|
const workflow = scenario.workflow;
|
|
const shotDir = path.join(webRoot, "manual", "assets", chapter, workflow);
|
|
const reportDir = path.join(webRoot, "manual", "data", "capture");
|
|
fs.mkdirSync(shotDir, { recursive: true });
|
|
fs.mkdirSync(reportDir, { recursive: true });
|
|
|
|
async function runOnce() {
|
|
const browser = await chromium.launch({
|
|
executablePath: "/usr/bin/google-chrome",
|
|
headless: !headed,
|
|
args: ["--no-sandbox", "--disable-dev-shm-usage", "--enable-unsafe-swiftshader",
|
|
"--use-gl=angle", "--use-angle=swiftshader", "--window-size=1600,900"],
|
|
});
|
|
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
|
|
const pageErrors = [];
|
|
const consoleErrors = [];
|
|
page.on("pageerror", error => pageErrors.push(String(error)));
|
|
page.on("console", message => { if (message.type() === "error") consoleErrors.push(message.text().slice(0, 300)); });
|
|
const trace = [];
|
|
const shots = [];
|
|
const record = entry => trace.push({ at: new Date().toISOString(), ...entry });
|
|
// The action interpreter is shared with the headed functional suite; only the
|
|
// evidence destinations and the record sink differ.
|
|
const runner = createActionRunner(page, {
|
|
origin, shotDir, shotPrefix: `${chapter}/${workflow}/`, record, shotIndex: shots,
|
|
fixturePath: path.join(webRoot, "manual", "fixtures", `${chapter}-${workflow}.FCStd`),
|
|
});
|
|
|
|
try {
|
|
for (const action of scenario.actions) await runner.run(action);
|
|
if (pageErrors.length || consoleErrors.length)
|
|
throw new Error(`page errors: ${JSON.stringify({ pageErrors, consoleErrors })}`);
|
|
const report = {
|
|
schema: "freecad-web-manual/capture/v1", generatedAt: new Date().toISOString(),
|
|
chapter, workflow, scenario: path.relative(webRoot, scenarioPath), origin,
|
|
ok: true, trace, pageErrors, consoleErrors,
|
|
shots: shots.map(item => ({ ...item, file: path.relative(webRoot, item.file) })),
|
|
};
|
|
fs.writeFileSync(path.join(reportDir, `${chapter}-${workflow}.json`), `${JSON.stringify(report, null, 2)}\n`);
|
|
return report;
|
|
} finally {
|
|
await browser.close();
|
|
}
|
|
}
|
|
|
|
try {
|
|
const report = await runOnce();
|
|
console.log(JSON.stringify({ ok: true, chapter, workflow, shots: report.shots.length }));
|
|
} catch (error) {
|
|
console.error(JSON.stringify({ ok: false, error: String(error?.stack ?? error) }));
|
|
process.exitCode = 1;
|
|
}
|