b60ad6d98f
Keep the probe suite on the Material composition so browser fixtures and capture drivers no longer render or select Cupertino hosts. Record the final residual legacy arguments and implementation checks for the delivery gate.
647 lines
28 KiB
JavaScript
647 lines
28 KiB
JavaScript
// Real-browser evidence for Search result-target selection.
|
|
//
|
|
// Usage (from app/):
|
|
// flutter build web --target tool/search_selection_probe_entry.dart \
|
|
// --output build/probe-search-selection
|
|
// node tool/search_selection_probe.mjs --root build/probe-search-selection \
|
|
// --out build/search-selection-probe
|
|
//
|
|
// Serves the fixture build over loopback (extension-less paths fall back to
|
|
// index.html so the app's real `/runs/7` and `/search` locations load), drives
|
|
// headless Chrome through the Chrome DevTools Protocol, enables Flutter
|
|
// semantics, types a query into the real search field, clicks result rows by
|
|
// their exact row title and asserts the run detail state the hit selects:
|
|
//
|
|
// field hit -> run Summary with the matched Output section expanded
|
|
// artifact hit -> the recorded visit pane (`build · visit 2`)
|
|
// retired field -> the plain Summary, no section expanded
|
|
// unknown visit -> the plain Summary, no visit pane
|
|
//
|
|
// Every reply comes from the in-app fixture channel in
|
|
// tool/search_selection_probe_entry.dart; no server is contacted.
|
|
import { createServer } from 'node:http';
|
|
import { mkdir, mkdtemp, readFile, rm, stat, writeFile } from 'node:fs/promises';
|
|
import { spawn } from 'node:child_process';
|
|
import { once } from 'node:events';
|
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
import { extname, join, resolve, sep } from 'node:path';
|
|
import { tmpdir } from 'node:os';
|
|
|
|
const args = new Map();
|
|
for (let i = 2; i < process.argv.length; i++) {
|
|
const value = process.argv[i];
|
|
if (value.startsWith('--')) args.set(value.slice(2), process.argv[++i]);
|
|
}
|
|
const root = resolve(args.get('root') ?? 'build/probe-search-selection');
|
|
const out = resolve(args.get('out') ?? 'build/search-selection-probe');
|
|
const chromePath =
|
|
process.env.CHROME_PATH ?? '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
|
|
await mkdir(out, { recursive: true });
|
|
|
|
const mime = {
|
|
'.html': 'text/html; charset=utf-8',
|
|
'.js': 'text/javascript; charset=utf-8',
|
|
'.mjs': 'text/javascript; charset=utf-8',
|
|
'.json': 'application/json; charset=utf-8',
|
|
'.wasm': 'application/wasm',
|
|
'.png': 'image/png',
|
|
'.svg': 'image/svg+xml',
|
|
'.ico': 'image/x-icon',
|
|
'.ttf': 'font/ttf',
|
|
'.otf': 'font/otf',
|
|
'.woff': 'font/woff',
|
|
'.woff2': 'font/woff2',
|
|
'.bin': 'application/octet-stream',
|
|
'.frag': 'application/octet-stream',
|
|
};
|
|
|
|
const server = createServer(async (req, res) => {
|
|
try {
|
|
const pathname = decodeURIComponent(new URL(req.url, 'http://localhost').pathname);
|
|
let filePath = resolve(root, '.' + pathname);
|
|
if (filePath !== root && !filePath.startsWith(root + sep)) {
|
|
res.writeHead(403).end();
|
|
return;
|
|
}
|
|
// The app uses path URLs (`/runs/7`, `/search`); any route path without a
|
|
// file extension is the single page, as the Pipelines proxy serves it.
|
|
try {
|
|
if ((await stat(filePath)).isDirectory()) filePath = join(filePath, 'index.html');
|
|
} catch {
|
|
if (!extname(pathname)) filePath = join(root, 'index.html');
|
|
}
|
|
const file = await readFile(filePath);
|
|
const type = mime[extname(filePath)] ?? 'application/octet-stream';
|
|
res.writeHead(200, { 'content-type': type, 'cache-control': 'no-store' }).end(file);
|
|
} catch {
|
|
res.writeHead(404).end('not found');
|
|
}
|
|
});
|
|
server.listen(0, '127.0.0.1');
|
|
await once(server, 'listening');
|
|
const port = server.address().port;
|
|
const origin = `http://127.0.0.1:${port}`;
|
|
|
|
const profile = await mkdtemp(join(tmpdir(), 'x1-search-selection-chrome-'));
|
|
const chrome = spawn(
|
|
chromePath,
|
|
[
|
|
'--headless=new',
|
|
'--no-first-run',
|
|
'--no-default-browser-check',
|
|
'--disable-gpu',
|
|
'--remote-debugging-port=0',
|
|
`--user-data-dir=${profile}`,
|
|
'about:blank',
|
|
],
|
|
{ stdio: ['ignore', 'ignore', 'pipe'] },
|
|
);
|
|
let stderr = '';
|
|
chrome.stderr.on('data', (data) => {
|
|
stderr += data;
|
|
});
|
|
|
|
const waitFor = async (fn, what, attempts = 120) => {
|
|
for (let i = 0; i < attempts; i++) {
|
|
const value = await fn();
|
|
if (value) return value;
|
|
await delay(100);
|
|
}
|
|
throw new Error(`Timed out waiting for ${what}: ${stderr.slice(-1500)}`);
|
|
};
|
|
|
|
// The exact row titles the fixture's six `release` hits render, one per kind,
|
|
// and the row meta each one announces (tool/search_selection_probe_entry.dart).
|
|
const RELEASE_ROWS = [
|
|
{ title: 'Release train', meta: 'Pipeline' },
|
|
{ title: 'pipeline 22 · v6', meta: 'Pipeline version' },
|
|
{ title: 'run #7 · Release train', meta: 'Run' },
|
|
{ title: 'run #7 · plan visit 2', meta: 'Step' },
|
|
{ title: 'run #7 · step 5 · output', meta: 'Field' },
|
|
{ title: 'release-report.txt', meta: 'Artifact' },
|
|
];
|
|
const RELEASE_BOUNDS = '6 results · cap 50 · scanned 3 steps · 2.0 KiB scanned · scan limit 1.0 MiB';
|
|
const BUILD_VISIT = 'build · visit 2';
|
|
// Flutter web renders a read-only SelectableText as a <textarea> whose value
|
|
// stays empty, so the section's JSON is pixels only; the section state itself
|
|
// is announced on the tile ("Expanded …" / "Collapsed …" aria-description).
|
|
const EXPANDED = 'Expanded';
|
|
const COLLAPSED = 'Collapsed';
|
|
|
|
let ws;
|
|
let send;
|
|
let session;
|
|
const evidence = { origin, captures: [], checks: [], defects: [] };
|
|
try {
|
|
const endpoint = await waitFor(
|
|
() => stderr.match(/DevTools listening on (ws:\/\/[^\s]+)/)?.[1],
|
|
'Chrome DevTools',
|
|
);
|
|
ws = new WebSocket(endpoint);
|
|
await once(ws, 'open');
|
|
let id = 0;
|
|
const pending = new Map();
|
|
const pageErrors = [];
|
|
ws.addEventListener('message', (event) => {
|
|
const message = JSON.parse(event.data);
|
|
if (message.method === 'Runtime.exceptionThrown') {
|
|
pageErrors.push(JSON.stringify(message.params?.exceptionDetails?.exception?.description ?? message.params));
|
|
}
|
|
if (message.id && pending.has(message.id)) {
|
|
pending.get(message.id)(message);
|
|
pending.delete(message.id);
|
|
}
|
|
});
|
|
send = (method, params = {}, sessionId) =>
|
|
new Promise((resolveCall) => {
|
|
const callId = ++id;
|
|
pending.set(callId, resolveCall);
|
|
ws.send(JSON.stringify({ id: callId, method, params, ...(sessionId ? { sessionId } : {}) }));
|
|
});
|
|
|
|
const created = await send('Target.createTarget', { url: 'about:blank' });
|
|
if (!created.result) throw new Error(`Target creation failed: ${JSON.stringify(created)}`);
|
|
const target = created.result.targetId;
|
|
session = (await send('Target.attachToTarget', { targetId: target, flatten: true })).result
|
|
.sessionId;
|
|
await send('Page.enable', {}, session);
|
|
await send('Runtime.enable', {}, session);
|
|
// A headless target can stay unfocused, which makes the browser refuse the
|
|
// search field's autofocus rather than testing the app.
|
|
await send('Page.bringToFront', {}, session);
|
|
|
|
const evaluate = async (expression) => {
|
|
const response = await send(
|
|
'Runtime.evaluate',
|
|
{ expression, returnByValue: true, awaitPromise: true },
|
|
session,
|
|
);
|
|
if (response.error) throw new Error(`Runtime.evaluate failed: ${JSON.stringify(response)}`);
|
|
if (response.result?.exceptionDetails) {
|
|
throw new Error(JSON.stringify(response.result.exceptionDetails));
|
|
}
|
|
return response.result?.result?.value;
|
|
};
|
|
const labels = () =>
|
|
evaluate(
|
|
"[...document.querySelectorAll('flt-semantics')].map(x => x.getAttribute('aria-label') || (x.innerText || '').trim()).filter(Boolean)",
|
|
);
|
|
// Everything the semantics tree announces: labels, leaf text, and the value
|
|
// of read-only text controls (the Material Summary sections render their
|
|
// JSON in a read-only MaterialTextField, which is an <input>/<textarea>).
|
|
const text = () =>
|
|
evaluate(`(() => {
|
|
const chunks = [];
|
|
for (const el of document.querySelectorAll('flt-semantics, [aria-label], input, textarea')) {
|
|
const label = el.getAttribute('aria-label');
|
|
if (label) chunks.push(label);
|
|
if (!el.children.length && el.innerText) chunks.push(el.innerText);
|
|
if ((el.tagName === 'INPUT' || el.tagName === 'TEXTAREA') && el.value) chunks.push(el.value);
|
|
}
|
|
if (document.body?.innerText) chunks.push(document.body.innerText);
|
|
return [...new Set(chunks)].join('\\n');
|
|
})()`);
|
|
const path = () => evaluate('location.pathname');
|
|
const hasText = async (needle) => (await text()).includes(needle);
|
|
const assertText = async (needle, what = needle) => {
|
|
try {
|
|
await waitFor(async () => hasText(needle), `${what} (${JSON.stringify(needle)})`);
|
|
} catch (error) {
|
|
throw new Error(`${error.message}\n--- page text ---\n${await text()}`);
|
|
}
|
|
};
|
|
const assertNoText = async (needle, what = needle) => {
|
|
if (await hasText(needle)) {
|
|
throw new Error(`${what} unexpectedly present: ${JSON.stringify(needle)}`);
|
|
}
|
|
};
|
|
// Rows announce their title, then their meta and snippet lines; click the
|
|
// most specific (shortest) tappable node whose text starts with the title.
|
|
const clickPrefix = async (prefix) => {
|
|
const clicked = await evaluate(`(() => {
|
|
const wanted = ${JSON.stringify(prefix)};
|
|
const nodes = [...document.querySelectorAll('flt-semantics')];
|
|
const candidates = nodes.filter((x) =>
|
|
(x.getAttribute('aria-label') || '').startsWith(wanted)
|
|
|| (x.innerText || '').trim().startsWith(wanted));
|
|
if (candidates.length === 0) return false;
|
|
candidates.sort((a, b) => (a.innerText || a.getAttribute('aria-label') || '').length
|
|
- (b.innerText || b.getAttribute('aria-label') || '').length);
|
|
candidates[0].click();
|
|
return true;
|
|
})()`);
|
|
if (!clicked) throw new Error(`No semantics label starting ${JSON.stringify(prefix)}: ${JSON.stringify(await labels())}`);
|
|
await delay(450);
|
|
};
|
|
// The shell's Search action is a real button; a pointer event keeps user
|
|
// activation so the page may then focus the search field.
|
|
const tapExact = async (label) => {
|
|
const point = await evaluate(`(() => {
|
|
const wanted = ${JSON.stringify(label)};
|
|
const nodes = [...document.querySelectorAll('flt-semantics')];
|
|
const node = nodes.find(x => x.getAttribute('aria-label') === wanted)
|
|
|| nodes.find(x => (x.innerText || '').trim() === wanted);
|
|
if (!node) return null;
|
|
const rect = node.getBoundingClientRect();
|
|
return { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 };
|
|
})()`);
|
|
if (!point) throw new Error(`No semantics node for ${JSON.stringify(label)}: ${JSON.stringify(await labels())}`);
|
|
for (const type of ['mousePressed', 'mouseReleased']) {
|
|
await send('Input.dispatchMouseEvent', { type, x: point.x, y: point.y, button: 'left', clickCount: 1 }, session);
|
|
}
|
|
await delay(450);
|
|
};
|
|
const activate = async () => {
|
|
await waitFor(
|
|
() => evaluate("Boolean(document.querySelector('flt-semantics-placeholder'))"),
|
|
'Flutter semantics placeholder',
|
|
);
|
|
await evaluate("document.querySelector('flt-semantics-placeholder')?.click()");
|
|
await delay(900);
|
|
};
|
|
let viewport = { width: 390, height: 844 };
|
|
const setSize = async (width, height, scale = 1) => {
|
|
viewport = { width, height };
|
|
await send('Emulation.setDeviceMetricsOverride', {
|
|
width,
|
|
height,
|
|
deviceScaleFactor: scale,
|
|
mobile: width < 600,
|
|
}, session);
|
|
await delay(500);
|
|
};
|
|
const navigate = async (url, width, height) => {
|
|
await setSize(width, height);
|
|
const navigation = await send('Page.navigate', { url }, session);
|
|
if (navigation.error || navigation.result?.errorText) throw new Error(JSON.stringify(navigation));
|
|
await activate();
|
|
};
|
|
const capture = async (name) => {
|
|
await delay(350);
|
|
const data = (await send('Page.captureScreenshot', { format: 'png' }, session)).result.data;
|
|
const file = join(out, `${name}.png`);
|
|
await writeFile(file, Buffer.from(data, 'base64'));
|
|
evidence.captures.push(file);
|
|
return file;
|
|
};
|
|
|
|
// The Summary's Input/Output tiles: Material's ExpansionTile and the
|
|
// Material expansion tile both announce their state as the first line of
|
|
// aria-description ("Expanded" / "Collapsed"); an expanded Material tile
|
|
// merges with its read-only text child into one <textarea> node.
|
|
const tileState = (title) =>
|
|
evaluate(`(() => {
|
|
const wanted = ${JSON.stringify(title)};
|
|
const nodes = [...document.querySelectorAll('flt-semantics, textarea, input')];
|
|
const node = nodes.find((x) =>
|
|
(x.getAttribute('aria-label') || '').trim() === wanted
|
|
|| (x.children.length === 0 && (x.innerText || '').trim() === wanted));
|
|
if (!node) return null;
|
|
const description = node.getAttribute('aria-description') || '';
|
|
return description.split('\\n')[0].trim() || 'unknown';
|
|
})()`);
|
|
const waitForTile = async (title, state) => {
|
|
try {
|
|
await waitFor(async () => (await tileState(title)) === state, `the ${title} section to be ${state}`, 40);
|
|
} catch (error) {
|
|
throw new Error(`${error.message}\n--- tiles ---\nInput: ${await tileState('Input')}\nOutput: ${await tileState('Output')}\n--- page text ---\n${await text()}`);
|
|
}
|
|
};
|
|
// Scrolls the detail body to its end so an expanded section below the phone
|
|
// fold is inside the captured frame.
|
|
const scrollBodyToEnd = async () => {
|
|
for (let i = 0; i < 2; i++) {
|
|
await send('Input.dispatchMouseEvent', {
|
|
type: 'mouseWheel',
|
|
x: viewport.width / 2,
|
|
y: viewport.height * 0.6,
|
|
deltaX: 0,
|
|
deltaY: 3000,
|
|
}, session);
|
|
await delay(400);
|
|
}
|
|
};
|
|
|
|
const fieldFocused = () =>
|
|
evaluate(`(() => {
|
|
const active = document.activeElement;
|
|
return Boolean(active && (active.tagName === 'INPUT' || active.tagName === 'TEXTAREA'));
|
|
})()`);
|
|
const typeQuery = async (value) => {
|
|
if (!(await fieldFocused())) {
|
|
const focused = await evaluate(`(() => {
|
|
const nodes = [...document.querySelectorAll('input.flt-text-editing, textarea.flt-text-editing, input, textarea')];
|
|
const node = nodes.find((el) => el.checkVisibility?.() ?? true) || nodes.at(-1);
|
|
if (!node) return false; node.focus(); return true;
|
|
})()`);
|
|
if (!focused) throw new Error('Search field not exposed as a semantics input');
|
|
await delay(300);
|
|
}
|
|
const inserted = await send('Input.insertText', { text: value }, session);
|
|
if (inserted.error) throw new Error(JSON.stringify(inserted));
|
|
// 250ms debounce plus the fixture channel's 120ms reply.
|
|
await delay(900);
|
|
};
|
|
// Search is a transient page above the shell: the action opens /search and
|
|
// the Material host mounts the field after its page transition.
|
|
const openSearch = async () => {
|
|
await tapExact('Search');
|
|
await waitFor(async () => (await path()) === '/search', 'the /search route');
|
|
await waitFor(fieldFocused, 'the focused search field', 60).catch(() => {});
|
|
};
|
|
const searchFor = async (query, expectRow) => {
|
|
await openSearch();
|
|
await typeQuery(query);
|
|
await assertText(expectRow, `the ${JSON.stringify(query)} result row`);
|
|
};
|
|
|
|
const assertReleaseResults = async (host) => {
|
|
const body = await text();
|
|
const missing = [];
|
|
for (const row of RELEASE_ROWS) {
|
|
if (!body.includes(row.title)) missing.push(row.title);
|
|
if (!body.includes(row.meta)) missing.push(`meta ${row.meta}`);
|
|
}
|
|
if (!body.includes(RELEASE_BOUNDS)) missing.push(RELEASE_BOUNDS);
|
|
if (!body.includes('ship the release')) missing.push('field snippet "ship the release"');
|
|
if (!body.includes('Kind')) missing.push('Kind control');
|
|
evidence.checks.push({
|
|
check: `${host}: the search panel lists one hit per kind for "release"`,
|
|
rows: RELEASE_ROWS.map((row) => row.title),
|
|
bounds: RELEASE_BOUNDS,
|
|
missing,
|
|
});
|
|
if (missing.length) throw new Error(`Search results missing ${JSON.stringify(missing)}`);
|
|
};
|
|
const assertRun7 = async () => {
|
|
await waitFor(async () => (await path()) === '/runs/7', 'the /runs/7 route from search');
|
|
await assertText('Release train run', 'the run detail title');
|
|
if (await hasText('Kind: All kinds') || await hasText('Search pipelines, runs and artifacts')) {
|
|
throw new Error('Search stayed open above the run detail');
|
|
}
|
|
};
|
|
const assertFieldSummary = async (host) => {
|
|
await assertRun7();
|
|
await waitForTile('Output', EXPANDED);
|
|
await waitForTile('Input', COLLAPSED);
|
|
await assertNoText('Back to timeline', 'a visit pane');
|
|
await assertNoText(BUILD_VISIT, 'a visit pane');
|
|
evidence.checks.push({
|
|
check: `${host}: a field hit opens the Summary with only Output expanded`,
|
|
path: await path(),
|
|
output: await tileState('Output'),
|
|
input: await tileState('Input'),
|
|
visitPane: false,
|
|
});
|
|
await scrollBodyToEnd();
|
|
};
|
|
const assertArtifactVisit = async (host) => {
|
|
await assertRun7();
|
|
await assertText(BUILD_VISIT, 'the recorded build visit');
|
|
await assertText('Back to timeline', 'the visit pane');
|
|
// The visit pane has its own Input/Output section strip; the Summary's
|
|
// prompt block is the text that only the Summary tab shows.
|
|
await assertNoText('Original prompt', 'the Summary tab');
|
|
evidence.checks.push({
|
|
check: `${host}: an artifact hit opens the visit that recorded it`,
|
|
path: await path(),
|
|
visit: BUILD_VISIT,
|
|
summaryShown: false,
|
|
});
|
|
};
|
|
const assertPlainSummary = async (host, what) => {
|
|
await assertRun7();
|
|
await assertText('Original prompt', 'the plain Summary');
|
|
await waitForTile('Input', COLLAPSED);
|
|
await waitForTile('Output', COLLAPSED);
|
|
await assertNoText(BUILD_VISIT, 'a visit pane');
|
|
await assertNoText('Back to timeline', 'a visit pane');
|
|
evidence.checks.push({
|
|
check: `${host}: ${what} selects the plain Summary`,
|
|
path: await path(),
|
|
input: await tileState('Input'),
|
|
output: await tileState('Output'),
|
|
});
|
|
await scrollBodyToEnd();
|
|
};
|
|
|
|
// A retired field selects the plain Summary; after an earlier field hit on
|
|
// the same mounted run, a section that hit expanded must not stay open, or
|
|
// the "plain" Summary still shows the previous match's section. The state
|
|
// is recorded rather than asserted so the probe can still capture every
|
|
// required state; a carried-over section is reported as a defect.
|
|
const recordRetiredAfterField = async (host) => {
|
|
await assertRun7();
|
|
await assertText('Original prompt', 'the Summary');
|
|
await assertNoText('Back to timeline', 'a visit pane');
|
|
const state = { input: await tileState('Input'), output: await tileState('Output') };
|
|
const check = {
|
|
check: `${host}: a retired field hit after an output field hit selects the plain Summary`,
|
|
path: await path(),
|
|
...state,
|
|
expected: { input: COLLAPSED, output: COLLAPSED },
|
|
};
|
|
evidence.checks.push(check);
|
|
if (state.input !== COLLAPSED || state.output !== COLLAPSED) {
|
|
evidence.defects.push({
|
|
...check,
|
|
note: 'The earlier field hit\'s expanded section is kept when the retired hit resolves to the plain Summary on the same mounted detail.',
|
|
});
|
|
}
|
|
await scrollBodyToEnd();
|
|
};
|
|
|
|
// The app follows the system colour scheme; pin it so captures are
|
|
// deterministic (light first, one dark pass below).
|
|
const emulateScheme = (value) => send('Emulation.setEmulatedMedia', {
|
|
features: [{ name: 'prefers-color-scheme', value }],
|
|
}, session);
|
|
await emulateScheme('light');
|
|
|
|
await navigate(`${origin}/`, 390, 844);
|
|
const contentType = await evaluate("fetch('/').then(r => r.headers.get('content-type'))");
|
|
evidence.checks.push({ check: 'index content-type is text/html', value: contentType });
|
|
if (!String(contentType).toLowerCase().startsWith('text/html')) {
|
|
throw new Error(`Root index is not text/html: ${contentType}`);
|
|
}
|
|
const routeType = await evaluate("fetch('/runs/7').then(r => r.headers.get('content-type'))");
|
|
if (!String(routeType).toLowerCase().startsWith('text/html')) {
|
|
throw new Error(`Route path is not served as the page: ${routeType}`);
|
|
}
|
|
|
|
// ---- Material host, phone ------------------------------------------------
|
|
await navigate(`${origin}/runs`, 390, 844);
|
|
await assertText('Release train run', 'the Runs list');
|
|
await searchFor('release', 'run #7 · step 5 · output');
|
|
await assertReleaseResults('material phone');
|
|
await capture('search-selection-material-phone-results');
|
|
|
|
// An artifact hit opens the visit that recorded it.
|
|
await clickPrefix('release-report.txt');
|
|
await assertArtifactVisit('material phone');
|
|
await capture('search-selection-material-phone-artifact-visit');
|
|
|
|
// The retired field replaces the open visit with the plain Summary.
|
|
await searchFor('retired', 'run #7 · step 5 · evidence');
|
|
await clickPrefix('run #7 · step 5 · evidence');
|
|
await assertPlainSummary('material phone', 'a retired field hit');
|
|
await capture('search-selection-material-phone-retired-summary');
|
|
|
|
// An artifact whose recorded visit the run never recorded (sequence 9).
|
|
await searchFor('release', 'release-report.txt');
|
|
await clickPrefix('release-report.txt');
|
|
await assertArtifactVisit('material phone (reopened)');
|
|
await searchFor('missing', 'missing.log');
|
|
await clickPrefix('missing.log');
|
|
await assertPlainSummary('material phone', 'an unknown-visit artifact hit');
|
|
await capture('search-selection-material-phone-unknown-visit-summary');
|
|
|
|
// A field hit opens the Summary at its matched section.
|
|
await searchFor('release', 'run #7 · step 5 · output');
|
|
await clickPrefix('run #7 · step 5 · output');
|
|
await assertFieldSummary('material phone');
|
|
await capture('search-selection-material-phone-field-summary');
|
|
|
|
// A retired hit after that field hit, on the same mounted detail.
|
|
await searchFor('retired', 'run #7 · step 5 · evidence');
|
|
await clickPrefix('run #7 · step 5 · evidence');
|
|
await recordRetiredAfterField('material phone');
|
|
await capture('search-selection-material-phone-retired-after-field-summary');
|
|
|
|
// Reopening the run from its list is an ordinary visit: nothing replays.
|
|
await searchFor('release', 'release-report.txt');
|
|
await clickPrefix('release-report.txt');
|
|
await assertArtifactVisit('material phone (before reopen)');
|
|
await tapExact('Back to list');
|
|
await waitFor(async () => (await path()) === '/runs', 'the Runs list');
|
|
await clickPrefix('Release train run');
|
|
await waitFor(async () => (await path()) === '/runs/7', 'the reopened run');
|
|
await assertText('Original prompt', 'the reopened Summary');
|
|
await assertNoText(BUILD_VISIT, 'a replayed visit pane');
|
|
evidence.checks.push({ check: 'material phone: a consumed selection does not replay on reopen', path: await path() });
|
|
|
|
// A step hit names the run's recorded visit by stage and server visit
|
|
// number. plan visit 1 is sequence 1; the pane must say `plan · visit 1`.
|
|
await searchFor('first', 'run #7 · plan visit 1');
|
|
await clickPrefix('run #7 · plan visit 1');
|
|
await waitFor(async () => (await path()).startsWith('/runs/7'), 'the step route');
|
|
await delay(600);
|
|
const stepPath = await path();
|
|
const stepSearch = await evaluate('location.search');
|
|
const stepBody = await text();
|
|
const stepVisit = stepBody.match(/plan · visit (\d+)/)?.[0] ?? null;
|
|
const stepCheck = {
|
|
check: 'material phone: a step hit for plan visit 1 opens plan · visit 1',
|
|
route: `${stepPath}${stepSearch}`,
|
|
opened: stepVisit,
|
|
expected: 'plan · visit 1',
|
|
};
|
|
evidence.checks.push(stepCheck);
|
|
if (stepVisit !== 'plan · visit 1') {
|
|
evidence.defects.push({
|
|
...stepCheck,
|
|
note: 'The hit carries the server visit number (1-based); the route query is zero-based.',
|
|
});
|
|
}
|
|
await capture('search-selection-material-phone-step-visit');
|
|
|
|
// ---- Material host, desktop ----------------------------------------------
|
|
await navigate(`${origin}/runs`, 1280, 800);
|
|
await assertText('Release train run', 'the Runs list');
|
|
await searchFor('release', 'run #7 · step 5 · output');
|
|
await assertReleaseResults('material desktop');
|
|
await capture('search-selection-material-desktop-results');
|
|
await clickPrefix('release-report.txt');
|
|
await assertArtifactVisit('material desktop');
|
|
await capture('search-selection-material-desktop-artifact-visit');
|
|
await searchFor('retired', 'run #7 · step 5 · evidence');
|
|
await clickPrefix('run #7 · step 5 · evidence');
|
|
await assertPlainSummary('material desktop', 'a retired field hit');
|
|
await capture('search-selection-material-desktop-retired-summary');
|
|
await searchFor('release', 'run #7 · step 5 · output');
|
|
await clickPrefix('run #7 · step 5 · output');
|
|
await assertFieldSummary('material desktop');
|
|
await capture('search-selection-material-desktop-field-summary');
|
|
|
|
// Dark scheme is the host theme, not a fixture flag: the app follows the
|
|
// system scheme, so emulate it for one results and one selection capture.
|
|
await emulateScheme('dark');
|
|
await navigate(`${origin}/runs`, 390, 844);
|
|
await assertText('Release train run', 'the Runs list');
|
|
await searchFor('release', 'run #7 · step 5 · output');
|
|
await capture('search-selection-material-phone-dark-results');
|
|
await clickPrefix('run #7 · step 5 · output');
|
|
await assertFieldSummary('material phone dark');
|
|
await capture('search-selection-material-phone-dark-field-summary');
|
|
await emulateScheme('light');
|
|
|
|
// ---- Material host, phone -----------------------------------------------
|
|
await navigate(`${origin}/runs`, 390, 844);
|
|
await assertText('Release train run', 'the Runs list');
|
|
await searchFor('release', 'run #7 · step 5 · output');
|
|
await assertReleaseResults('material phone');
|
|
await assertText('Kind: All kinds', 'the Material kind control');
|
|
await capture('search-selection-material-phone-results');
|
|
|
|
await clickPrefix('release-report.txt');
|
|
await assertArtifactVisit('material phone');
|
|
await capture('search-selection-material-phone-artifact-visit');
|
|
|
|
await searchFor('retired', 'run #7 · step 5 · evidence');
|
|
await clickPrefix('run #7 · step 5 · evidence');
|
|
await assertPlainSummary('material phone', 'a retired field hit');
|
|
await capture('search-selection-material-phone-retired-summary');
|
|
|
|
await searchFor('release', 'release-report.txt');
|
|
await clickPrefix('release-report.txt');
|
|
await assertArtifactVisit('material phone (reopened)');
|
|
await searchFor('missing', 'missing.log');
|
|
await clickPrefix('missing.log');
|
|
await assertPlainSummary('material phone', 'an unknown-visit artifact hit');
|
|
await capture('search-selection-material-phone-unknown-visit-summary');
|
|
|
|
await searchFor('release', 'run #7 · step 5 · output');
|
|
await clickPrefix('run #7 · step 5 · output');
|
|
await assertFieldSummary('material phone');
|
|
await capture('search-selection-material-phone-field-summary');
|
|
|
|
await searchFor('retired', 'run #7 · step 5 · evidence');
|
|
await clickPrefix('run #7 · step 5 · evidence');
|
|
await recordRetiredAfterField('material phone');
|
|
await capture('search-selection-material-phone-retired-after-field-summary');
|
|
|
|
// ---- Material host, desktop ---------------------------------------------
|
|
await navigate(`${origin}/runs`, 1280, 800);
|
|
await assertText('Release train run', 'the Runs list');
|
|
await searchFor('release', 'run #7 · step 5 · output');
|
|
await assertReleaseResults('material desktop');
|
|
await capture('search-selection-material-desktop-results');
|
|
await clickPrefix('release-report.txt');
|
|
await assertArtifactVisit('material desktop');
|
|
await capture('search-selection-material-desktop-artifact-visit');
|
|
await searchFor('release', 'run #7 · step 5 · output');
|
|
await clickPrefix('run #7 · step 5 · output');
|
|
await assertFieldSummary('material desktop');
|
|
await capture('search-selection-material-desktop-field-summary');
|
|
|
|
evidence.pageErrors = pageErrors;
|
|
console.log(JSON.stringify(evidence, null, 2));
|
|
if (evidence.defects.length) process.exitCode = 2;
|
|
} catch (error) {
|
|
// Keep the failing frame beside the captures so the failure is inspectable.
|
|
try {
|
|
const data = (await send('Page.captureScreenshot', { format: 'png' }, session)).result.data;
|
|
await writeFile(join(out, 'failure.png'), Buffer.from(data, 'base64'));
|
|
} catch {
|
|
/* The failure is reported below either way. */
|
|
}
|
|
console.log(JSON.stringify({ ...evidence, failure: String(error.message) }, null, 2));
|
|
throw error;
|
|
} finally {
|
|
ws?.close();
|
|
chrome.kill('SIGTERM');
|
|
await Promise.race([once(chrome, 'exit'), delay(3000)]);
|
|
server.close();
|
|
await rm(profile, { recursive: true, force: true });
|
|
}
|