feat(app): add native pipelines list and detail screen

Read-only Pipelines screen for the Flutter client:

- list_pipelines and list_runs with a last-run join, plus get_pipeline
  with an explicit version (0 = latest); no mutation requests.
- Name, run-presence, last-run-status and schedule filters; six sort
  orders; clear filters; truthful loading, empty and error states.
- Detail Summary, selectable Source and version history with selection
  and return to latest.
- Sequenced list/detail requests so stale replies cannot replace a newer
  selection or open a cleared one; refresh keeps the selected pipeline
  and version.
- Material controls on Android/desktop and Cupertino on iOS; a
  per-label segmented tab row at narrow widths and scaled text, with the
  native control kept wherever an equal share fits.
- Fixture probe entry and Chrome scripts for the rendered evidence;
  widget tests cover filters, sorting, formatting, sequencing, layout
  and the tab row.

Graph rendering remains P2: the Graph tab states that it is pending and
exposes a host hook. PipelinesScreen is not yet registered in the shell.

Evidence and limits: app/notes/P1.md.
This commit is contained in:
2026-10-21 19:09:29 +01:00
parent 718442d73d
commit a44f31b989
38 changed files with 5583 additions and 0 deletions
+132
View File
@@ -0,0 +1,132 @@
// Real-Chrome fixture probe for the Pipelines P1 screen.
//
// It serves a prebuilt Flutter web bundle, drives it through Chrome DevTools
// (accessibility tree + real mouse events), and writes PNGs and a JSON log.
// No live server, socket or operator data is involved.
//
// Usage: node tool/pipelines_probe_cdp.mjs <build-dir> <capture-dir>
import { mkdir, writeFile } from "node:fs/promises";
import { join, resolve } from "node:path";
import { tmpdir } from "node:os";
import {
connect,
launchChrome,
sleep,
startServer,
waitForPage,
waitForPort,
} from "./pipelines_probe_cdp_lib.mjs";
import {
assertName,
axNodes,
capture,
click,
clickAt,
dragSelect,
enableSemantics,
waitFor,
} from "./pipelines_probe_cdp_input.mjs";
const CHROME =
process.env.CHROME_PATH ??
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome";
const buildDir = resolve(process.argv[2] ?? "build/web");
const captureDir = resolve(process.argv[3] ?? "p1-captures");
const { server, url } = await startServer(buildDir);
await mkdir(captureDir, { recursive: true });
const profile = join(tmpdir(), `pipelines-p1-chrome-${process.pid}`);
const chrome = launchChrome(CHROME, profile, url);
let connection;
const log = { url, captures: [], checks: [], axSamples: [] };
try {
const devtoolsPort = await waitForPort(join(profile, "DevToolsActivePort"));
const target = await waitForPage(devtoolsPort);
connection = await connect(target.webSocketDebuggerUrl);
await connection.send("Page.enable");
await connection.send("Runtime.enable");
await connection.send("DOM.enable");
await connection.send("Accessibility.enable");
await connection.send("Emulation.setDeviceMetricsOverride", {
width: 1200,
height: 900,
deviceScaleFactor: 1,
mobile: false,
});
await waitFor(
() => connection.evaluate("document.querySelector('flutter-view') !== null"),
20000,
);
await sleep(1200);
await enableSemantics(connection);
const nodes = await axNodes(connection);
log.axSamples = nodes
.filter((node) => node.name?.value)
.slice(0, 40)
.map((node) => `${node.role?.value}: ${node.name.value}`);
await assertName(connection, "Release verification", "list row", log);
await capture(connection, captureDir, log, "01-list-desktop");
await click(connection, "Release verification");
await assertName(connection, "Content hash", "summary detail", log);
await capture(connection, captureDir, log, "02-detail-summary");
await click(connection, "Source");
await capture(connection, captureDir, log, "03-source-latest");
// Select the first source line with a real drag. The capture shows the
// browser's text selection, proving the source is selectable.
await dragSelect(connection, 500, 194, 880, 194);
await capture(connection, captureDir, log, "04-source-selection");
log.checks.push("source drag selection");
await click(connection, "Summary");
// The detail body is drawn on the canvas and Flutter's semantics tree omits
// its list rows in this build, so the v1 row is clicked at the fixture layout
// position for the fixed 1200x900 viewport.
await clickAt(connection, 620, 489);
await sleep(800);
await capture(connection, captureDir, log, "05-version-v1");
await click(connection, "Source");
await capture(connection, captureDir, log, "06-source-v1");
await connection.send("Emulation.setDeviceMetricsOverride", {
width: 390,
height: 844,
deviceScaleFactor: 1,
mobile: true,
});
await sleep(500);
await click(connection, "Back to pipelines");
await assertName(connection, "Release verification", "mobile list", log);
await capture(connection, captureDir, log, "07-list-390");
await click(connection, "Hotfix triage");
await assertName(connection, "Content hash", "mobile detail", log);
await capture(connection, captureDir, log, "08-detail-390");
await click(connection, "Back to pipelines");
await assertName(connection, "Release verification", "mobile list again", log);
await click(connection, "Filter");
await assertName(connection, "Filter pipelines", "mobile filter", log);
await capture(connection, captureDir, log, "09-filter-390");
} catch (error) {
log.error = String(error?.stack ?? error);
try {
const nodes = await axNodes(connection);
log.failureAx = nodes
.filter((node) => node.name?.value)
.map((node) => `${node.role?.value}: ${node.name.value}`)
.slice(0, 120);
} catch {
// The browser may already be gone; the error itself is still recorded.
}
process.exitCode = 1;
} finally {
await writeFile(join(captureDir, "probe.json"), JSON.stringify(log, null, 2));
connection?.close();
chrome.kill("SIGTERM");
server.close();
}
+155
View File
@@ -0,0 +1,155 @@
// Chrome DevTools input, accessibility and capture helpers for the Pipelines
// P1 fixture probe.
import { writeFile } from "node:fs/promises";
import { join } from "node:path";
import { sleep } from "./pipelines_probe_cdp_lib.mjs";
const ENABLE_SEMANTICS = `(() => {
const visit = (root) => {
const placeholder = root.querySelector?.('flt-semantics-placeholder');
if (placeholder) { placeholder.click(); return true; }
for (const element of root.querySelectorAll?.('*') ?? []) {
if (element.shadowRoot && visit(element.shadowRoot)) return true;
}
return false;
};
return visit(document);
})()`;
export async function enableSemantics(connection) {
await connection.evaluate(ENABLE_SEMANTICS);
await sleep(1000);
}
function axLabel(node) {
return [node?.name?.value, node?.value?.value]
.filter((value) => typeof value === "string" && value !== "")
.join("\n");
}
export async function axNodes(connection) {
const { nodes } = await connection.send("Accessibility.getFullAXTree", {
depth: -1,
});
return nodes;
}
export async function waitFor(probe, timeout) {
const deadline = Date.now() + timeout;
while (Date.now() < deadline) {
const value = await probe();
if (value) return value;
await sleep(120);
}
return null;
}
export async function assertName(connection, text, label, log) {
const nodes = await waitFor(async () => {
const current = await axNodes(connection);
return current.some((node) => axLabel(node).includes(text))
? current
: false;
}, 12000);
if (!nodes) throw new Error(`Missing ${label}: ${text}`);
log.checks.push(label);
}
export async function capture(connection, directory, log, name) {
const shot = await connection.send("Page.captureScreenshot", {
format: "png",
captureBeyondViewport: false,
});
const file = join(directory, `${name}.png`);
await writeFile(file, Buffer.from(shot.data, "base64"));
log.captures.push(file);
}
export async function click(connection, text) {
const nodes = await axNodes(connection);
const interactive = new Set([
"button",
"link",
"tab",
"radio",
"checkbox",
"menuitem",
"option",
"switch",
"toggleButton",
"listitem",
]);
const byId = new Map(nodes.map((node) => [node.nodeId, node]));
const clickable = (node) => {
let current = node;
while (current) {
if (interactive.has(current.role?.value) && current.backendDOMNodeId) {
return current;
}
current = byId.get(current.parentId);
}
return null;
};
const matches = nodes.filter((node) => {
const name = axLabel(node);
return (
name.includes(text) &&
(node.role?.value === "button" ||
node.role?.value === "StaticText" ||
interactive.has(node.role?.value))
);
});
const target = matches.map(clickable).find(Boolean);
if (!target) throw new Error(`No clickable semantics node for ${text}`);
const { model } = await connection.send("DOM.getBoxModel", {
backendNodeId: target.backendDOMNodeId,
});
const [x1, y1, , , x3, y3] = model.content;
await clickAt(connection, (x1 + x3) / 2, (y1 + y3) / 2);
}
export async function clickAt(connection, x, y) {
await connection.send("Input.dispatchMouseEvent", {
type: "mousePressed",
x,
y,
button: "left",
clickCount: 1,
});
await connection.send("Input.dispatchMouseEvent", {
type: "mouseReleased",
x,
y,
button: "left",
clickCount: 1,
});
await sleep(500);
}
export async function dragSelect(connection, x1, y1, x2, y2) {
await connection.send("Input.dispatchMouseEvent", {
type: "mousePressed",
x: x1,
y: y1,
button: "left",
clickCount: 1,
});
for (let step = 1; step <= 8; step++) {
await connection.send("Input.dispatchMouseEvent", {
type: "mouseMoved",
x: x1 + ((x2 - x1) * step) / 8,
y: y1 + ((y2 - y1) * step) / 8,
button: "left",
buttons: 1,
});
await sleep(30);
}
await connection.send("Input.dispatchMouseEvent", {
type: "mouseReleased",
x: x2,
y: y2,
button: "left",
clickCount: 1,
});
await sleep(400);
}
+127
View File
@@ -0,0 +1,127 @@
// Chrome DevTools connection and fixture-server helpers for the Pipelines P1
// probe. No live server or operator data is involved.
import { spawn } from "node:child_process";
import { createServer } from "node:http";
import { readFile, stat } from "node:fs/promises";
import { extname, join, normalize } from "node:path";
export const sleep = (ms) =>
new Promise((resolve) => setTimeout(resolve, ms));
const MIME = {
".html": "text/html; charset=utf-8",
".js": "text/javascript; charset=utf-8",
".mjs": "text/javascript; charset=utf-8",
".css": "text/css; charset=utf-8",
".json": "application/json",
".png": "image/png",
".jpg": "image/jpeg",
".svg": "image/svg+xml",
".ttf": "font/ttf",
".otf": "font/otf",
".wasm": "application/wasm",
".map": "application/json",
};
export async function startServer(buildDir) {
const root = normalize(buildDir);
const server = createServer(async (request, response) => {
try {
const url = new URL(request.url ?? "/", "http://127.0.0.1");
let file = normalize(join(root, decodeURIComponent(url.pathname)));
if (!file.startsWith(root)) throw new Error("outside build");
let info = await stat(file).catch(() => null);
if (!info || info.isDirectory()) {
file = join(root, "index.html");
info = await stat(file);
}
response.writeHead(200, {
"content-type": MIME[extname(file)] ?? "application/octet-stream",
"cache-control": "no-store",
});
response.end(await readFile(file));
} catch {
response.writeHead(404).end("not found");
}
});
await new Promise((done) => server.listen(0, "127.0.0.1", done));
return { server, url: `http://127.0.0.1:${server.address().port}/` };
}
export function launchChrome(chromePath, profile, url) {
return spawn(
chromePath,
[
"--headless=new",
"--remote-debugging-port=0",
`--user-data-dir=${profile}`,
"--no-first-run",
"--no-default-browser-check",
"--disable-background-networking",
"--disable-sync",
"--hide-scrollbars",
"--force-device-scale-factor=1",
"--window-size=1200,900",
url,
],
{ stdio: "ignore" },
);
}
export async function waitForPort(file) {
for (let attempt = 0; attempt < 200; attempt++) {
const text = await readFile(file, "utf8").catch(() => "");
if (text) return text.split("\n")[0].trim();
await sleep(100);
}
throw new Error("Chrome DevTools did not start");
}
export async function waitForPage(devtoolsPort) {
for (let attempt = 0; attempt < 100; attempt++) {
const targets = await fetch(
`http://127.0.0.1:${devtoolsPort}/json/list`,
).then((response) => response.json());
const page = targets.find((target) => target.type === "page");
if (page) return page;
await sleep(100);
}
throw new Error("No page target");
}
export async function connect(webSocketUrl) {
const socket = new WebSocket(webSocketUrl);
await new Promise((done, fail) => {
socket.addEventListener("open", done, { once: true });
socket.addEventListener("error", fail, { once: true });
});
let nextId = 1;
const pending = new Map();
socket.addEventListener("message", (event) => {
const message = JSON.parse(event.data);
if (!message.id) return;
const entry = pending.get(message.id);
if (!entry) return;
pending.delete(message.id);
if (message.error) entry.reject(new Error(message.error.message));
else entry.resolve(message.result);
});
const send = (method, params = {}) =>
new Promise((resolve, reject) => {
const id = nextId++;
pending.set(id, { resolve, reject });
socket.send(JSON.stringify({ id, method, params }));
});
return {
send,
close: () => socket.close(),
evaluate: async (expression) => {
const result = await send("Runtime.evaluate", {
expression,
awaitPromise: true,
returnByValue: true,
});
return result.result?.value;
},
};
}
+26
View File
@@ -0,0 +1,26 @@
import 'package:flutter/material.dart';
import 'package:pipelines_app/features/pipelines/screen.dart';
import 'pipelines_probe_fixture.dart';
/// Browser fixture preview for the Pipelines item. It is a separate entry
/// point, so the app's main/shell stay untouched. All replies come from
/// [PipelinesProbeGateway]; no server or live data is involved.
void main() {
runApp(const PipelinesProbeApp());
}
class PipelinesProbeApp extends StatelessWidget {
const PipelinesProbeApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Pipelines P1 probe',
debugShowCheckedModeBanner: false,
theme: ThemeData(),
darkTheme: ThemeData(brightness: Brightness.dark),
home: PipelinesScreen(gateway: PipelinesProbeGateway()),
);
}
}
+242
View File
@@ -0,0 +1,242 @@
import 'dart:async';
import 'package:pipelines_app/core/api_gateway.dart';
/// Deterministic in-memory data for the browser fixture preview. This is not a
/// live connection and is used only by `tool/pipelines_probe_entry.dart`.
class PipelinesProbeGateway implements ApiGateway {
PipelinesProbeGateway({this.delay = const Duration(milliseconds: 120)});
final Duration delay;
static const _pipelines = <Map<String, dynamic>>[
{
'id': 3,
'name': 'Release verification',
'version': 3,
'stages': 4,
'created_at': '2026-09-28T10:12:00',
'updated_at': '2026-10-21T09:40:00',
'scheduled': true,
'schedule_count': 2,
'enabled_schedule_count': 1,
},
{
'id': 7,
'name': 'Nightly documentation',
'version': 1,
'stages': 2,
'created_at': '2026-10-02T18:20:00',
'updated_at': '2026-10-20T22:05:00',
'scheduled': true,
'schedule_count': 1,
'enabled_schedule_count': 1,
},
{
'id': 11,
'name': 'Hotfix triage',
'version': 2,
'stages': 3,
'created_at': '2026-10-11T08:00:00',
'updated_at': '2026-10-19T16:32:00',
'scheduled': false,
'schedule_count': 0,
'enabled_schedule_count': 0,
},
{
'id': 14,
'name': 'Legacy import (no schedule metadata)',
'version': 1,
'stages': 1,
'created_at': '2026-08-04T11:45:00',
'updated_at': '2026-10-14T12:10:00',
'scheduled': null,
'schedule_count': null,
'enabled_schedule_count': null,
},
];
static const _runs = <Map<String, dynamic>>[
{
'id': 488,
'pipeline_id': 3,
'status': 'succeeded',
'created_at': '2026-10-21T09:30:00',
'finished_at': '2026-10-21T09:34:12',
'executing': false,
},
{
'id': 487,
'pipeline_id': 7,
'status': 'running',
'created_at': '2026-10-21T09:20:00',
'finished_at': '',
'executing': true,
},
{
'id': 486,
'pipeline_id': 11,
'status': 'failed',
'created_at': '2026-10-19T16:20:00',
'finished_at': '2026-10-19T16:28:40',
'executing': false,
},
{
'id': 480,
'pipeline_id': 3,
'status': 'waiting',
'created_at': '2026-10-18T13:00:00',
'finished_at': '',
'executing': false,
},
];
static const _versionRows = <int, List<Map<String, dynamic>>>{
3: [
{'version': 1, 'stages': 2, 'created_at': '2026-09-28T10:12:00'},
{'version': 2, 'stages': 3, 'created_at': '2026-10-08T15:44:00'},
{'version': 3, 'stages': 4, 'created_at': '2026-10-21T09:12:00'},
],
7: [
{'version': 1, 'stages': 2, 'created_at': '2026-10-02T18:20:00'},
],
11: [
{'version': 1, 'stages': 2, 'created_at': '2026-10-11T08:00:00'},
{'version': 2, 'stages': 3, 'created_at': '2026-10-18T09:30:00'},
],
14: [
{'version': 1, 'stages': 1, 'created_at': '2026-08-04T11:45:00'},
],
};
static const _sources = <int, String>{
3: '''
name: Release verification
stages:
inspect:
type: model
output: report
edges:
pass: verify
fail: '#failure'
verify:
type: model
output: verdict
edges:
pass: package
fail: '#failure'
package:
type: human
output: approval
edges:
approve: publish
hold: '#success'
publish:
type: model
output: release
edges:
done: '#success'
''',
7: '''
name: Nightly documentation
stages:
collect:
type: model
output: notes
edges:
done: write
write:
type: model
output: report
edges:
done: '#success'
''',
11: '''
name: Hotfix triage
stages:
classify:
type: model
output: severity
edges:
urgent: patch
normal: document
patch:
type: model
output: change
edges:
done: '#success'
document:
type: human
output: note
edges:
done: '#success'
''',
14: '''
name: Legacy import
stages:
import:
type: model
output: summary
edges:
done: '#success'
''',
};
@override
Stream<JsonMap> get frames => const Stream<JsonMap>.empty();
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) async {
if (delay > Duration.zero) await Future<void>.delayed(delay);
switch (type) {
case 'list_pipelines':
return {'type': 'pipelines', 'pipelines': _pipelines};
case 'list_runs':
return {'type': 'runs', 'runs': _runs};
case 'get_pipeline':
return _detail(
fields['pipeline_id'] as int? ?? 0,
fields['version'] as int? ?? 0,
);
}
return {'type': 'error', 'error': 'The fixture does not answer $type.'};
}
JsonMap _detail(int id, int requestedVersion) {
final summary = _pipelines.where((pipeline) => pipeline['id'] == id).first;
final versions = _versionRows[id] ?? const <Map<String, dynamic>>[];
final latest = versions.isEmpty
? summary['version'] as int
: versions.last['version'] as int;
final resolved = requestedVersion > 0 ? requestedVersion : latest;
final version = versions.firstWhere(
(row) => row['version'] == resolved,
orElse: () => versions.isEmpty ? summary : versions.last,
);
return {
'type': 'pipeline',
'detail': {
...summary,
'version': resolved,
'stages': version['stages'] as int,
'latest_version': latest,
'version_created_at': _versionCreatedAt(versions, resolved),
'content_hash': 'sha256:fixture-$id-v$resolved',
'source': '${_sources[id]}\n# selected version $resolved\n',
'versions': versions,
},
};
}
static String _versionCreatedAt(
List<Map<String, dynamic>> versions,
int resolved,
) {
for (final version in versions) {
if (version['version'] == resolved) {
return version['created_at'] as String;
}
}
return versions.isEmpty ? '' : versions.last['created_at'] as String;
}
}
+403
View File
@@ -0,0 +1,403 @@
// Real-Chrome probe for the detail tab labels under narrow widths and scaled
// text. It serves a prebuilt Flutter web bundle, drives it through Chrome
// DevTools and writes PNGs plus a JSON log. No live server or operator data is
// involved.
//
// Usage: node tool/pipelines_probe_tabs_scale.mjs <build-dir> <capture-dir>
import { mkdir, writeFile } from "node:fs/promises";
import { join, resolve } from "node:path";
import { tmpdir } from "node:os";
import {
connect,
launchChrome,
sleep,
startServer,
waitForPage,
waitForPort,
} from "./pipelines_probe_cdp_lib.mjs";
import {
assertName,
axNodes,
capture,
click,
enableSemantics,
waitFor,
} from "./pipelines_probe_cdp_input.mjs";
const CHROME =
process.env.CHROME_PATH ??
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome";
const buildDir = resolve(process.argv[2] ?? "build/web");
const captureDir = resolve(process.argv[3] ?? "p1-tabs-fix");
const { server, url } = await startServer(buildDir);
await mkdir(captureDir, { recursive: true });
const profile = join(tmpdir(), `pipelines-tabs-chrome-${process.pid}`);
const chrome = launchChrome(CHROME, profile, url);
let connection;
const log = { url, captures: [], checks: [], states: [] };
const LABELS = ["Summary", "Graph", "Source"];
// The tab row sits inside the detail pane's 16 px horizontal padding.
const PANE_INSET = 16;
function paneRight(width) {
return width - PANE_INSET;
}
// At rest, every label must be fully inside the pane, except in the one state
// the acceptance allows to scroll: 320 px at 200 % still has to show a
// recognisable share of the last label instead of an empty cell.
function checkAtRest(name, boxes, width, { partialLast = false } = {}) {
const right = paneRight(width);
for (const label of LABELS) {
const box = boxes[label];
if (box.x + box.width <= PANE_INSET - 0.5) {
throw new Error(`${name}: ${label} starts outside the pane`);
}
if (box.width < 24) {
throw new Error(`${name}: ${label} has only ${box.width}px visible`);
}
if (!partialLast || label !== "Source") {
if (box.x + box.width > right + 0.5) {
throw new Error(
`${name}: ${label} is cut by the pane edge ` +
`(${box.x} + ${box.width} > ${right})`,
);
}
}
}
if (partialLast) {
const source = boxes.Source;
if (source.x >= right) {
throw new Error(`${name}: Source is an empty cell`);
}
if (source.width < 40) {
throw new Error(
`${name}: only ${source.width}px of Source is readable at rest`,
);
}
log.checks.push(
`${name}: Source is partly visible at rest (${source.width}px, ` +
'scrolling still allowed)',
);
} else {
log.checks.push(`${name}: all three labels fully visible at rest`);
}
}
async function setViewport(width, height) {
await connection.send("Emulation.setDeviceMetricsOverride", {
width,
height,
deviceScaleFactor: 1,
mobile: width < 720,
});
await sleep(800);
}
async function setTextScale(fontPx) {
await connection.evaluate(
`document.documentElement.style.fontSize = '${fontPx}px'; true`,
);
await sleep(1300);
}
async function setTheme(value) {
await connection.send("Emulation.setEmulatedMedia", {
features: [{ name: "prefers-color-scheme", value }],
});
await sleep(600);
}
// The accessibility tree reports the whole label even when the paragraph wraps
// inside a word, so the actual painted boxes are measured through the DOM.
async function tabBoxes() {
const nodes = await axNodes(connection);
const boxes = {};
for (const name of LABELS) {
const node = nodes.find(
(candidate) =>
candidate.role?.value === "button" && candidate.name?.value === name,
);
if (!node?.backendDOMNodeId) {
throw new Error(`No accessibility button named ${name}`);
}
const { model } = await connection.send("DOM.getBoxModel", {
backendNodeId: node.backendDOMNodeId,
});
const [x1, y1, , , x3, y3] = model.content;
boxes[name] = {
x: Math.round(x1 * 10) / 10,
y: Math.round(y1 * 10) / 10,
width: Math.round((x3 - x1) * 10) / 10,
height: Math.round((y3 - y1) * 10) / 10,
};
}
return boxes;
}
async function axHas(text) {
const nodes = await axNodes(connection);
return nodes.some(
(node) =>
node.name?.value?.includes(text) || node.value?.value?.includes(text),
);
}
async function pressTab() {
for (const type of ["keyDown", "keyUp"]) {
await connection.send("Input.dispatchKeyEvent", {
type,
key: "Tab",
code: "Tab",
windowsVirtualKeyCode: 9,
nativeVirtualKeyCode: 9,
});
}
await sleep(400);
}
async function dragRow(x, y, deltaX) {
await connection.send("Input.dispatchMouseEvent", {
type: "mousePressed",
x,
y,
button: "left",
clickCount: 1,
});
for (let step = 1; step <= 10; step++) {
await connection.send("Input.dispatchMouseEvent", {
type: "mouseMoved",
x: x + (deltaX * step) / 10,
y,
button: "left",
buttons: 1,
});
await sleep(25);
}
await connection.send("Input.dispatchMouseEvent", {
type: "mouseReleased",
x: x + deltaX,
y,
button: "left",
clickCount: 1,
});
await sleep(700);
}
async function openDetail() {
await connection.send("Page.reload");
await waitFor(
() => connection.evaluate("document.querySelector('flutter-view') !== null"),
20000,
);
await sleep(1500);
await enableSemantics(connection);
await setViewport(1200, 900);
await click(connection, "Release verification");
await assertName(connection, "Content hash", "detail selected", log);
}
async function state({ name, width, height, fontPx, partialLast = false, theme }) {
await openDetail();
if (theme) await setTheme(theme);
await setViewport(width, height);
await setTextScale(fontPx);
const boxes = await tabBoxes();
for (const label of LABELS) {
if (!boxes[label]) throw new Error(`Tab ${label} missing at ${name}`);
}
checkAtRest(name, boxes, width, { partialLast });
await capture(connection, captureDir, log, name);
if (!partialLast) {
// A box clipped by the scroll viewport still reports a right edge inside
// the pane, so scrolling the row to its limit must not uncover any extra
// label width. If it does, a label was cut at rest.
await dragRow(
boxes.Summary.x + boxes.Summary.width / 2,
boxes.Summary.y + boxes.Summary.height / 2,
-240,
);
const scrolled = await tabBoxes();
for (const label of LABELS) {
if (scrolled[label].width > boxes[label].width + 1) {
throw new Error(
`${name}: ${label} was clipped at rest ` +
`(${boxes[label].width} of ${scrolled[label].width}px visible)`,
);
}
}
log.checks.push(`${name}: scrolling exposes no hidden label width`);
}
const heights = LABELS.map((label) => boxes[label].height);
log.states.push({
name,
width,
height,
fontPx,
boxes,
equalRowHeight: heights.every((value) => value === heights[0]),
});
return boxes;
}
try {
const devtoolsPort = await waitForPort(join(profile, "DevToolsActivePort"));
const target = await waitForPage(devtoolsPort);
connection = await connect(target.webSocketDebuggerUrl);
await connection.send("Page.enable");
await connection.send("Runtime.enable");
await connection.send("DOM.enable");
await connection.send("Accessibility.enable");
await setTheme("light");
// Single-line height references at each scale, measured in the wide pane
// where every label fits on one line.
await openDetail();
await setTextScale(24);
const wide150 = await tabBoxes();
await setTextScale(32);
const wide200 = await tabBoxes();
log.states.push({ name: "wide-baseline", wide150, wide200 });
await sleep(200);
const text150 = await state({
name: "01-320-text150-atrest",
width: 320,
height: 640,
fontPx: 24,
});
const text200 = await state({
name: "02-320-text200-atrest",
width: 320,
height: 640,
fontPx: 32,
partialLast: true,
});
const text390 = await state({
name: "03-390-text200-atrest",
width: 390,
height: 844,
fontPx: 32,
});
const text720 = await state({
name: "04-720-text200-atrest",
width: 720,
height: 900,
fontPx: 32,
});
await state({
name: "05-320-text150-atrest-dark",
width: 320,
height: 640,
fontPx: 24,
theme: "dark",
});
await state({
name: "06-390-text200-atrest-dark",
width: 390,
height: 844,
fontPx: 32,
theme: "dark",
});
await setTheme("light");
for (const [label, boxes, reference] of [
["320x640 @150%", text150, wide150],
["320x640 @200%", text200, wide200],
["390x844 @200%", text390, wide200],
["720x900 @200%", text720, wide200],
]) {
const heights = LABELS.map((name) => boxes[name].height);
const singleLine = heights.every(
(value) => Math.abs(value - reference.Summary.height) <= 1,
);
if (!singleLine) {
throw new Error(
`${label}: tab row is ${heights.join("/")} high, single-line ` +
`reference is ${reference.Summary.height}`,
);
}
log.checks.push(`${label}: all three tab labels on one line`);
}
// The third tab must stay reachable when the row is wider than the pane.
await openDetail();
await setViewport(320, 640);
await setTextScale(32);
const before = await tabBoxes();
await dragRow(
before.Summary.x + before.Summary.width / 2,
before.Summary.y + before.Summary.height / 2,
-320,
);
const after = await tabBoxes();
log.states.push({ name: "drag", before, after });
if (!(after.Source.x + after.Source.width <= paneRight(320) + 0.5)) {
throw new Error(
`Source is not fully visible after dragging: ` +
`${after.Source.x} + ${after.Source.width}`,
);
}
log.checks.push("320x640 @200%: mouse drag reveals the Source tab");
await capture(connection, captureDir, log, "07-320-text200-scrolled");
await click(connection, "Source");
// The source text is canvas-drawn and absent from the accessibility tree, so
// selection is confirmed by the Summary body leaving the tree and the source
// content by inspecting the PNG.
if (!(await waitFor(async () => !(await axHas("Content hash")), 6000))) {
throw new Error("Source tab did not replace the Summary body");
}
log.checks.push("320x640 @200%: Source tab selects after scrolling");
await sleep(600);
await capture(connection, captureDir, log, "08-320-text200-source");
// Keyboard traversal must reach the third tab and scroll it into view.
await openDetail();
await setViewport(320, 640);
await setTextScale(32);
await click(connection, "Summary");
await pressTab();
await pressTab();
const keyboard = await tabBoxes();
log.states.push({ name: "keyboard-320-text200", boxes: keyboard });
if (!(keyboard.Source.x + keyboard.Source.width <= paneRight(320) + 0.5)) {
throw new Error(
`Keyboard traversal did not reveal Source: ` +
`${keyboard.Source.x} + ${keyboard.Source.width}`,
);
}
log.checks.push("320x640 @200%: keyboard traversal reveals the Source tab");
await capture(connection, captureDir, log, "09-320-text200-keyboard");
// A fitting row still spans the pane at 100% (no regression from scrolling).
await openDetail();
await setViewport(1200, 900);
await setTextScale(16);
const full = await tabBoxes();
const rowWidth = full.Source.x + full.Source.width - full.Summary.x;
log.states.push({ name: "wide-100", full, rowWidth });
if (Math.abs(rowWidth - 687.4) > 8) {
throw new Error(`Wide row width changed: ${rowWidth}`);
}
log.checks.push("1200x900 @100%: tab row still fills the detail pane");
await capture(connection, captureDir, log, "10-1200-text100-detail");
} catch (error) {
log.error = String(error?.stack ?? error);
try {
const nodes = await axNodes(connection);
log.failureAx = nodes
.filter((node) => node.name?.value)
.map((node) => `${node.role?.value}: ${node.name.value}`)
.slice(0, 160);
} catch {
// The browser may already be gone; the error itself is still recorded.
}
process.exitCode = 1;
} finally {
await writeFile(join(captureDir, "probe.json"), JSON.stringify(log, null, 2));
connection?.close();
chrome.kill("SIGTERM");
server.close();
}