91 lines
5.5 KiB
JavaScript
91 lines
5.5 KiB
JavaScript
// Shared pane geometry and selected rows, against isolated loopback fixtures.
|
|
import assert from 'node:assert/strict';
|
|
import { mkdir, mkdtemp, writeFile } from 'node:fs/promises';
|
|
import { once } from 'node:events';
|
|
import { tmpdir } from 'node:os';
|
|
import { join, resolve } from 'node:path';
|
|
import { startFixture } from './runs_probe_server.mjs';
|
|
import { startWiringFixture } from './pipelines_wiring_probe_server.mjs';
|
|
import { launchChrome, waitForPort, waitForPage, connect, sleep } from './pipelines_probe_cdp_lib.mjs';
|
|
import { axNodes, enableSemantics, waitFor, capture, clickAt } from './pipelines_probe_cdp_input.mjs';
|
|
|
|
const platform = process.env.PROBE_PLATFORM ?? 'material';
|
|
const width = Number(process.env.PROBE_WIDTH ?? 1280);
|
|
const dark = process.env.PROBE_DARK === '1';
|
|
const output = resolve(process.argv[3] ?? `build/list-detail-${platform}`);
|
|
await mkdir(output, { recursive: true });
|
|
const root = resolve(process.argv[2]);
|
|
const runs = await startFixture({ root, chatMessages: [], chatSessions: [
|
|
{ id: 'ses_probechat', title: 'First fixture chat', backend: 'claude', model: 'claude-opus', mode: 'auto', mode_name: 'Auto' },
|
|
{ id: 'ses_secondchat', title: 'Second fixture chat', backend: 'claude', model: 'claude-opus', mode: 'auto', mode_name: 'Auto' },
|
|
] });
|
|
const pipelines = await startWiringFixture({ root });
|
|
const profile = await mkdtemp(join(tmpdir(), 'list-detail-consistency-'));
|
|
const chrome = launchChrome('/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', profile, 'about:blank');
|
|
const log = { platform, width, dark, checks: [], captures: [], panes: [] };
|
|
let c;
|
|
const geometry = () => c.evaluate(`(() => {
|
|
const box = id => { const r = document.querySelector('[flt-semantics-identifier="' + id + '"]')?.getBoundingClientRect(); return r && {x:r.x,width:r.width}; };
|
|
return {list:box('list-detail-list'),body:box('list-detail-body')};
|
|
})()`);
|
|
const selected = async titles => (await c.evaluate(`Array.from(document.querySelector('[flt-semantics-identifier="list-detail-list"]').querySelectorAll('[aria-current="true"], [aria-selected="true"]')).map(e => e.getAttribute('aria-label') || e.textContent || '')`)).filter(name => titles.some(title => name.includes(title)));
|
|
async function open(title) {
|
|
const node = await waitFor(async () => {
|
|
const nodes = await axNodes(c);
|
|
return nodes.find(n => n.name?.value === title && n.role?.value === 'StaticText' && n.backendDOMNodeId)
|
|
?? nodes.find(n => n.name?.value?.includes(title) && n.backendDOMNodeId);
|
|
}, 12000);
|
|
assert.ok(node, title);
|
|
const { model } = await c.send('DOM.getBoxModel', { backendNodeId: node.backendDOMNodeId });
|
|
const [x1,y1,,,x3,y3] = model.content;
|
|
await clickAt(c, (x1+x3)/2, (y1+y3)/2);
|
|
await c.send('Input.dispatchMouseEvent', { type: 'mouseMoved', x: width-5, y: 895 });
|
|
}
|
|
try {
|
|
c = await connect((await waitForPage(await waitForPort(join(profile, 'DevToolsActivePort')))).webSocketDebuggerUrl);
|
|
await c.send('Page.enable');
|
|
if (platform === 'material') await c.send('Emulation.setUserAgentOverride', {
|
|
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36', platform: 'Win32',
|
|
});
|
|
await c.send('Emulation.setDeviceMetricsOverride', { width, height: 900, deviceScaleFactor: 1, mobile: false });
|
|
await c.send('Emulation.setEmulatedMedia', { features: [{ name:'prefers-color-scheme',value:dark?'dark':'light' }] });
|
|
for (const [destination, fixture, titles] of [
|
|
['pipelines', pipelines, ['Release verification', 'Nightly documentation']],
|
|
['runs', runs, ['Fixture live run', 'Fixture failing run']],
|
|
['chat', runs, ['First fixture chat', 'Second fixture chat']],
|
|
]) {
|
|
await c.send('Page.navigate', { url: fixture.url + '/' + destination });
|
|
assert.ok(await waitFor(() => c.evaluate("Boolean(document.querySelector('flt-semantics-placeholder'))"),30000));
|
|
await enableSemantics(c);
|
|
assert.ok(await waitFor(async () => (await geometry()).list,30000));
|
|
const before = await geometry();
|
|
assert.ok(Math.abs(before.list.width-before.body.width)<1, 'equal panes before selection');
|
|
assert.deepEqual(await selected(titles), []);
|
|
for (let i=0;i<titles.length;i++) {
|
|
await open(titles[i]);
|
|
assert.ok(await waitFor(async () => (await selected(titles)).some(name => name.includes(titles[i])),12000), `${destination} selected ${titles[i]}`);
|
|
assert.equal((await selected(titles)).length,1,'only the active row is selected');
|
|
const bounds = await geometry();
|
|
assert.ok(Math.abs(bounds.list.width-bounds.body.width)<1,'equal flexible panes');
|
|
assert.equal(bounds.list.width,before.list.width,'selection does not resize panes');
|
|
log.panes.push({destination,title:titles[i],...bounds});
|
|
await sleep(300);
|
|
await capture(c,output,log,`${destination}-selected-${i+1}`);
|
|
}
|
|
log.checks.push(`${destination}: list remains visible, selection moves, panes remain equal`);
|
|
}
|
|
assert.ok(log.panes.every(p => Math.abs(p.list.width-log.panes[0].list.width)<1),'identical pane widths across destinations');
|
|
log.checks.push('all three destinations have identical pane widths');
|
|
console.log(JSON.stringify(log,null,2));
|
|
} catch (error) {
|
|
if(c) {
|
|
await capture(c,output,log,'failure');
|
|
await writeFile(join(output,'failure-ax.json'),JSON.stringify(await axNodes(c),null,2));
|
|
}
|
|
throw error;
|
|
} finally {
|
|
await writeFile(join(output,'result.json'),JSON.stringify(log,null,2));
|
|
c?.close();const exited=once(chrome,'exit');chrome.kill();await exited;
|
|
await Promise.all([runs.close(),pipelines.close()]);
|
|
}
|