Add ABB120 demo suite and docs
This commit is contained in:
@@ -52,13 +52,18 @@ async function verifyViewport(viewport) {
|
||||
await client.send("Page.navigate", { url: pathToFileURL(appHtml).href });
|
||||
await waitForLoad(client);
|
||||
|
||||
const initial = await evaluate(client, pageProbeSource());
|
||||
const initial = await waitForProbe(
|
||||
client,
|
||||
(probe) => probe.parserProgress === 1 && !probe.parser.includes("parsing"),
|
||||
"initial parse",
|
||||
4000
|
||||
);
|
||||
assertProbe(initial, viewport.name, "initial");
|
||||
|
||||
await evaluate(client, clickCommandSource("load"));
|
||||
await evaluate(client, clickCommandSource("run"));
|
||||
await evaluate(client, clickIoSource());
|
||||
const afterRun = await evaluate(client, pageProbeSource());
|
||||
const afterRun = await waitForProbe(client, (probe) => probe.state === "running", "run", 1200);
|
||||
assertProbe(afterRun, viewport.name, "after run");
|
||||
if (afterRun.state !== "running") {
|
||||
throw new Error(`${viewport.name}: expected state running, got ${afterRun.state}`);
|
||||
@@ -91,6 +96,7 @@ async function verifyViewport(viewport) {
|
||||
screenshot: viewport.screenshotPath,
|
||||
screenshotBytes: pngBytes,
|
||||
state: afterRun.state,
|
||||
parser: afterRun.parser,
|
||||
wait: afterRun.wait,
|
||||
trace: afterRun.trace,
|
||||
visiblePanels: afterRun.visiblePanels
|
||||
@@ -257,6 +263,17 @@ function waitForLoad(client) {
|
||||
});
|
||||
}
|
||||
|
||||
async function waitForProbe(client, predicate, label, timeoutMs) {
|
||||
const started = Date.now();
|
||||
let lastProbe;
|
||||
while (Date.now() - started < timeoutMs) {
|
||||
lastProbe = await evaluate(client, pageProbeSource());
|
||||
if (predicate(lastProbe)) return lastProbe;
|
||||
await new Promise((resolveRetry) => setTimeout(resolveRetry, 100));
|
||||
}
|
||||
throw new Error(`${label} timed out. Last probe: ${JSON.stringify(lastProbe)}`);
|
||||
}
|
||||
|
||||
async function evaluate(client, expression) {
|
||||
const result = await client.send("Runtime.evaluate", {
|
||||
expression: `(${expression})()`,
|
||||
@@ -288,7 +305,12 @@ function pageProbeSource() {
|
||||
wait: field("wait"),
|
||||
queue: field("queue"),
|
||||
trace: field("trace"),
|
||||
parser: field("parser"),
|
||||
parserProgress: Number(document.querySelector("[data-parser-progress]")?.value ?? 0),
|
||||
editor: field("editor"),
|
||||
stepRows: document.querySelectorAll("[data-step-table] tr").length,
|
||||
activeStepRows: document.querySelectorAll("[data-step-table] tr[data-step-state='active']").length,
|
||||
stepStatus: field("step-status"),
|
||||
running: document.querySelector(".workbench")?.dataset.running === "true",
|
||||
visiblePanels,
|
||||
viewport: box(".viewport"),
|
||||
@@ -325,6 +347,9 @@ function assertProbe(probe, viewportName, phase) {
|
||||
if (!probe.editor.includes("proc main") && !probe.editor.includes("MoveJ") && !probe.editor.includes("PTP")) {
|
||||
throw new Error(`${viewportName}/${phase}: editor source did not render`);
|
||||
}
|
||||
if (probe.stepRows < 1 || probe.activeStepRows !== 1 || !probe.stepStatus.includes("line")) {
|
||||
throw new Error(`${viewportName}/${phase}: program steps did not render correctly`);
|
||||
}
|
||||
if (!probe.viewport || probe.viewport.width < 100 || probe.viewport.height < 100) {
|
||||
throw new Error(`${viewportName}/${phase}: viewport is too small`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user