Merge branch 'main' into web-run-polish

This commit is contained in:
2026-10-19 20:11:08 +01:00
33 changed files with 3249 additions and 831 deletions
+9
View File
@@ -186,6 +186,15 @@ export async function launchChrome({ width = 1440, height = 900, chromePath } =
const api = {
targetId,
/** Resize the emulated viewport at the driver's fixed device scale. */
async resize(width, height) {
await session("Emulation.setDeviceMetricsOverride", {
width,
height,
deviceScaleFactor: 1,
mobile: false,
});
},
async evaluate(expression) {
const result = await session("Runtime.evaluate", {
expression,
+96
View File
@@ -0,0 +1,96 @@
import test from "node:test";
import assert from "node:assert/strict";
import {
DESTINATIONS,
destinationForView,
destinationIndex,
rovingTabindex,
sectionModel,
shellStatus,
tabIndexForKey,
} from "../src/shell.js";
test("the shell has exactly four destinations in order", () => {
assert.deepEqual(
DESTINATIONS.map((item) => item.key),
["pipelines", "runs", "chat", "settings"],
);
for (const item of DESTINATIONS) {
assert.equal(typeof item.label, "string");
assert.ok(item.label.length > 0);
assert.equal(item.path, `/${item.key}`);
}
});
test("views map onto the destination that owns them", () => {
assert.equal(destinationForView("pipelines"), "pipelines");
assert.equal(destinationForView("runs"), "runs");
assert.equal(destinationForView("chat"), "chat");
assert.equal(destinationForView("settings"), "settings");
// Templates is reached from Settings; it is a route but not a destination.
assert.equal(destinationForView("templates"), "settings");
assert.equal(destinationIndex("chat"), 2);
assert.equal(destinationIndex("missing"), 0);
});
test("roving tabindex keeps exactly one tab in the tab order", () => {
assert.equal(rovingTabindex(0, 0), "0");
assert.equal(rovingTabindex(0, 1), "-1");
assert.deepEqual(
[0, 1, 2, 3].map((index) => rovingTabindex(2, index)),
["-1", "-1", "0", "-1"],
);
});
test("tab keys move, wrap and jump to the ends", () => {
assert.equal(tabIndexForKey("ArrowRight", 0, 4), 1);
assert.equal(tabIndexForKey("ArrowRight", 3, 4), 0);
assert.equal(tabIndexForKey("ArrowLeft", 0, 4), 3);
assert.equal(tabIndexForKey("ArrowLeft", 2, 4), 1);
assert.equal(tabIndexForKey("Home", 2, 4), 0);
assert.equal(tabIndexForKey("End", 2, 4), 3);
// Vertical tablists accept Up/Down as well; horizontal ones ignore them.
assert.equal(tabIndexForKey("ArrowDown", 1, 4, { vertical: true }), 2);
assert.equal(tabIndexForKey("ArrowUp", 0, 4, { vertical: true }), 3);
assert.equal(tabIndexForKey("ArrowDown", 1, 4), -1);
assert.equal(tabIndexForKey("Enter", 1, 4), -1);
// A non-key or an impossible list never moves focus.
assert.equal(tabIndexForKey("ArrowRight", 0, 0), -1);
assert.equal(tabIndexForKey("ArrowRight", -1, 4), -1);
});
test("the shell status names every connection state without colour", () => {
assert.deepEqual(shellStatus({ kind: "connected" }), {
text: "Connected",
tone: "ok",
state: "connected",
});
assert.equal(shellStatus({ kind: "connecting", attempt: 2 }).text, "Connecting\u2026");
assert.equal(shellStatus({ kind: "disconnected", reason: "closed" }).text, "Disconnected");
assert.deepEqual(shellStatus({ kind: "idle" }, { hasEndpoint: true }), {
text: "Not connected",
tone: "idle",
state: "idle",
});
assert.deepEqual(shellStatus({ kind: "idle" }, { hasEndpoint: false }), {
text: "Not configured",
tone: "idle",
state: "unconfigured",
});
});
test("sectionModel keeps one active tab and no tablist without a detail", () => {
const model = {
tabs: [
{ key: "summary", label: "Summary" },
{ key: "graph", label: "Graph" },
],
active: "graph",
};
assert.deepEqual(sectionModel(model), { tabs: model.tabs, active: 1 });
assert.deepEqual(sectionModel({ tabs: [], active: "summary" }), { tabs: [], active: -1 });
assert.deepEqual(sectionModel({ tabs: model.tabs, active: "missing" }), {
tabs: model.tabs,
active: 0,
});
});
+781 -275
View File
File diff suppressed because it is too large Load Diff