Complete all manual chapters with screenshots and command index

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
2026-11-13 12:45:40 +08:00
parent 15a365022f
commit 158e9ddfdc
72 changed files with 3088 additions and 53 deletions

View File

@@ -7,7 +7,7 @@ import path from "node:path";
import { createHash } from "node:crypto";
import { createRequire } from "node:module";
import { fileURLToPath } from "node:url";
import { listOpfsFiles, readOpfsFile } from "../carrier-course/lib/opfs.mjs";
import { listOpfsFiles, readOpfsFile, seedOpfsFromBytes } from "../carrier-course/lib/opfs.mjs";
const here = path.dirname(fileURLToPath(import.meta.url));
const webRoot = path.resolve(here, "../..");
@@ -124,6 +124,10 @@ async function runOnce() {
await page.locator(action.selector).first().selectOption(action.label ? { label: action.label } : action.value);
record({ action: "select", selector: action.selector, label: action.label ?? action.value });
break;
case "selectIndex":
await page.locator(action.selector).first().selectOption({ index: action.index });
record({ action: "selectIndex", selector: action.selector, index: action.index });
break;
case "press": await page.keyboard.press(action.key); record({ action: "press", key: action.key }); break;
case "clickCanvas": {
const target = page.locator(action.selector).first();
@@ -157,6 +161,13 @@ async function runOnce() {
await page.evaluate(action.script);
record({ action: "eval" });
break;
case "seed": {
const file = path.resolve(action.file);
if (!fs.existsSync(file)) throw new Error(`seed fixture missing: ${file}`);
await seedOpfsFromBytes(page, action.name ?? path.basename(file), fs.readFileSync(file));
record({ action: "seed", file, name: action.name ?? path.basename(file) });
break;
}
case "shot": await shot(action); break;
case "save": await save(action); break;
case "assertText": {
@@ -169,6 +180,18 @@ async function runOnce() {
await page.locator(action.selector).first().waitFor({ state: "visible", timeout: 30000 });
record({ action: "assertVisible", selector: action.selector });
break;
case "waitOptions": {
const locator = page.locator(action.selector).first();
let count = 0;
for (let attempt = 0; attempt < 80; attempt++) {
count = await locator.locator("option").count();
if (count >= (action.min ?? 1)) break;
await page.waitForTimeout(500);
}
if (count < (action.min ?? 1)) throw new Error(`waitOptions failed: ${action.selector} ${count}`);
record({ action: "waitOptions", selector: action.selector, count });
break;
}
case "assertValue": {
const value = await page.locator(action.selector).first().inputValue();
if (String(value) !== String(action.value)) throw new Error(`assertValue failed: ${action.selector} ${value} != ${action.value}`);