Files
FreeCADWasmDev/tools/functional-suite/cases/handwritten.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

97 lines
5.7 KiB
JavaScript

// Hand-written chapter cases for the chapters that ship no scenario JSON.
import fs from "node:fs";
import path from "node:path";
import { dismissStartWorkspace, openRoute, root } from "../runtime.mjs";
import { runCommand, selectModule } from "./modules.mjs";
const COURSE = path.join(root, "web", "tools", "line-course");
const MEDIA = path.join(root, "web", "teaching", "media", "line-course");
export const handwrittenCases = [
{
id: "CH-ch14-production-line",
title: "生产线课程:规格表、收口证据与媒体资产",
priority: "P1",
executor: "assets",
source: "web/manual/content/ch14-production-line.md",
timeoutMs: 60000,
async run({ step }) {
await step("line-spec 规格表可解析", "27 个模型 / 88 个部件 / 三角面 > 0 / 6 分量包围盒", async () => {
const spec = JSON.parse(fs.readFileSync(path.join(COURSE, "line-spec.json"), "utf8"));
const bbox = spec.sceneBBox;
if (spec.modelCount !== 27) throw new Error(`modelCount ${spec.modelCount} != 27`);
if (spec.partCount !== 88) throw new Error(`partCount ${spec.partCount} != 88`);
if (!(spec.triangleCount > 0)) throw new Error(`triangleCount ${spec.triangleCount} is not positive`);
if (!Array.isArray(bbox) || bbox.length !== 6 || !bbox.every(value => typeof value === "number" && Number.isFinite(value))) throw new Error(`sceneBBox is not 6 finite numbers: ${JSON.stringify(bbox)}`);
return { modelCount: spec.modelCount, partCount: spec.partCount, triangleCount: spec.triangleCount, bbox };
});
await step("收口证据可解析", "final-status.json 含 state 与 knownBoundaries", async () => {
const status = JSON.parse(fs.readFileSync(path.join(COURSE, "evidence", "final-status.json"), "utf8"));
if (!status.state) throw new Error("final-status.json has no state");
if (!("knownBoundaries" in status)) throw new Error("final-status.json has no knownBoundaries");
return { state: status.state, keys: Object.keys(status).length };
});
await step("媒体目录非空", "至少一集视频或截图", async () => {
const count = fs.readdirSync(MEDIA).length;
if (count < 1) throw new Error("media directory is empty");
return { files: count };
});
},
},
{
id: "CH-ch15-help-start",
title: "帮助、命令面板、偏好与快捷键(第 15 章)",
priority: "P1",
executor: "functional",
source: "web/manual/content/ch15-help-start.md",
timeoutMs: 240000,
async run({ page, origin, step }) {
await step("Help 工作台源码清点可执行", "help.inspectSourceInventory 返回 kind=result", async () => {
await openRoute(page, { origin }, "/workbench.html?module=Help");
await dismissStartWorkspace(page);
await selectModule(page, "Help");
const response = await runCommand(page, "help.inspectSourceInventory");
if (response?.kind !== "result") throw new Error(`help.inspectSourceInventory: ${JSON.stringify(response?.error ?? response).slice(0, 240)}`);
return { kind: response.kind };
});
await step("Ctrl+K 打开命令面板并检索到命令", "面板可见且 Part_Box 出现在结果中", async () => {
await openRoute(page, { origin }, "/project.html", { dismissStart: true });
await page.keyboard.press("Control+k");
const palette = page.locator('[role="dialog"][aria-label="Command palette"]');
await palette.waitFor({ state: "visible", timeout: 15000 });
await palette.getByLabel("Search commands").fill("Part_Box");
const hit = palette.locator("button", { has: page.locator("code", { hasText: "Part_Box" }) }).first();
await hit.waitFor({ state: "visible", timeout: 15000 });
await palette.getByLabel("Close command palette").click();
await palette.waitFor({ state: "detached", timeout: 10000 });
return { palette: "opened", match: (await hit.count()) > 0 };
});
await step("偏好对话框可从 Tools 菜单打开", "Preferences 对话框含单位/主题控件", async () => {
await page.locator(".utility-menus > button", { hasText: "Tools" }).first().click();
await page.locator('[role="menu"][aria-label="Tools"] button', { hasText: "Preferences…" }).click();
const dialog = page.locator('[role="dialog"][aria-label="Preferences"]');
await dialog.waitFor({ state: "visible", timeout: 15000 });
const units = await dialog.getByLabel("Unit system").count();
const theme = await dialog.getByLabel("Theme").count();
if (!units || !theme) throw new Error(`preferences controls missing: units=${units} theme=${theme}`);
await dialog.getByLabel("Close preferences").click();
await dialog.waitFor({ state: "detached", timeout: 10000 });
return { units, theme };
});
await step("快捷键管理器可从 Tools 菜单打开", "Customize shortcuts 对话框可搜索命令", async () => {
await page.locator(".utility-menus > button", { hasText: "Tools" }).first().click();
await page.locator('[role="menu"][aria-label="Tools"] button', { hasText: "Customize shortcuts…" }).click();
const dialog = page.locator('[role="dialog"][aria-label="Customize shortcuts"]');
await dialog.waitFor({ state: "visible", timeout: 15000 });
await dialog.getByLabel("Search shortcuts").fill("Part_Box");
await page.waitForTimeout(300);
const rows = await dialog.locator("tbody tr").count();
if (!rows) throw new Error("shortcut search returned no rows for Part_Box");
await dialog.getByLabel("Close shortcut editor").click();
await dialog.waitFor({ state: "detached", timeout: 10000 });
return { rows };
});
},
},
];