test(app): verify real browser shell navigation and capture states
This commit is contained in:
@@ -1,5 +1,17 @@
|
||||
# F2 — Adaptive shell
|
||||
|
||||
## Manager browser acceptance
|
||||
The initial capture attempt failed because the fixture served its index with
|
||||
binary MIME. Corrected the fixture MIME and navigation assertions; the real
|
||||
Chrome run now passes actual Pipelines → Runs → Chat → Settings → Pipelines
|
||||
navigation, checking the selected destination body (not only navigation labels).
|
||||
Captured and inspected at 390×844 and 1280×800:
|
||||
`/private/var/folders/jp/q0qvjyg54fl_c5vhhk1ylz2m0000gn/T/opencode/f2-shell-{phone,phone-runs,phone-settings,desktop}.png`.
|
||||
These show the native Cupertino shell on a macOS browser with explicitly labelled
|
||||
unimplemented feature bodies. They do not prove feature parity or mobile behavior.
|
||||
Reproduce from app/ using `OPENCODE_ARTIFACT_DIR=<directory> node tool/shell_probe.mjs`
|
||||
after `flutter build web`. Earlier missing-capture statements below are historical.
|
||||
|
||||
Implemented standard adaptive navigation for Pipelines, Runs, Chat and Settings.
|
||||
Material uses a bottom `NavigationBar` below 600 logical pixels and a labeled
|
||||
`NavigationRail` at wider widths. Cupertino uses the native navigation bar and
|
||||
|
||||
@@ -3,7 +3,7 @@ import { readFile } from 'node:fs/promises';
|
||||
import { spawn } from 'node:child_process';
|
||||
import { once } from 'node:events';
|
||||
import { setTimeout as delay } from 'node:timers/promises';
|
||||
import { join, extname } from 'node:path';
|
||||
import { join, extname, resolve, sep } from 'node:path';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { mkdtemp, rm } from 'node:fs/promises';
|
||||
|
||||
@@ -11,9 +11,11 @@ const root = join(process.cwd(), 'build/web');
|
||||
const mime = { '.html': 'text/html', '.js': 'text/javascript', '.json': 'application/json', '.wasm': 'application/wasm', '.png': 'image/png', '.ico': 'image/x-icon' };
|
||||
const server = createServer(async (req, res) => {
|
||||
try {
|
||||
const path = join(root, decodeURIComponent(new URL(req.url, 'http://localhost').pathname));
|
||||
const file = await readFile(path.endsWith('/') ? join(path, 'index.html') : path);
|
||||
res.writeHead(200, { 'content-type': mime[extname(path)] ?? 'application/octet-stream' }).end(file);
|
||||
const path = resolve(root, '.' + decodeURIComponent(new URL(req.url, 'http://localhost').pathname));
|
||||
if (path !== root && !path.startsWith(root + sep)) return res.writeHead(403).end();
|
||||
const filePath = path.endsWith('/') ? join(path, 'index.html') : path;
|
||||
const file = await readFile(filePath);
|
||||
res.writeHead(200, { 'content-type': mime[extname(filePath)] ?? 'application/octet-stream' }).end(file);
|
||||
} catch { res.writeHead(404).end('not found'); }
|
||||
});
|
||||
server.listen(0, '127.0.0.1');
|
||||
@@ -39,18 +41,21 @@ try {
|
||||
const pending = new Map();
|
||||
ws.addEventListener('message', event => {
|
||||
const msg = JSON.parse(event.data);
|
||||
if (msg.method?.includes('detached') || msg.method?.includes('crashed')) console.error('CDP event', JSON.stringify(msg));
|
||||
if (msg.id && pending.has(msg.id)) { pending.get(msg.id)(msg); pending.delete(msg.id); }
|
||||
});
|
||||
const send = (method, params = {}, sessionId) => new Promise(resolve => {
|
||||
const callId = ++id; pending.set(callId, resolve);
|
||||
ws.send(JSON.stringify({ id: callId, method, params, ...(sessionId ? { sessionId } : {}) }));
|
||||
});
|
||||
const created = await send('Target.createTarget', { url: `http://127.0.0.1:${port}/` });
|
||||
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;
|
||||
const session = (await send('Target.attachToTarget', { targetId: target, flatten: true })).result.sessionId;
|
||||
await send('Page.enable', {}, session);
|
||||
await send('Runtime.enable', {}, session);
|
||||
const navigation = await send('Page.navigate', { url: `http://127.0.0.1:${port}/` }, session);
|
||||
if (navigation.error || navigation.result?.errorText) throw new Error(JSON.stringify(navigation));
|
||||
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)}`);
|
||||
@@ -61,7 +66,7 @@ try {
|
||||
if (!loaded?.url.includes(`127.0.0.1:${port}`)) throw new Error(`Fixture did not load: ${JSON.stringify(loaded)}`);
|
||||
await evaluate("document.querySelector('flt-semantics-placeholder')?.click()");
|
||||
await delay(900);
|
||||
const clickLabel = async label => evaluate(`(() => { const e=[...document.querySelectorAll('flt-semantics')].find(x => (x.getAttribute('aria-label') || x.innerText || '').includes(${JSON.stringify(label)})); if (!e) return false; e.click(); return true; })()`);
|
||||
const clickLabel = async label => evaluate(`(() => { const e=[...document.querySelectorAll('flt-semantics')].find(x => (x.getAttribute('aria-label') || x.innerText || '') === ${JSON.stringify(label)}); if (!e) return false; e.click(); return true; })()`);
|
||||
const labels = await evaluate("[...document.querySelectorAll('flt-semantics')].map(x=>x.getAttribute('aria-label')||x.innerText).filter(Boolean)");
|
||||
if (!labels?.some(x => x.includes('Pipelines'))) throw new Error(`Flutter semantics unavailable: ${JSON.stringify(labels)}`);
|
||||
const capture = async (name, width, height) => {
|
||||
@@ -75,10 +80,11 @@ try {
|
||||
if (!await clickLabel(label)) throw new Error(`Could not interact with ${label} navigation`);
|
||||
await delay(250);
|
||||
const current = await evaluate("[...document.querySelectorAll('flt-semantics')].map(x=>x.getAttribute('aria-label')||x.innerText).filter(Boolean)");
|
||||
if (!current?.some(x => x.includes(label))) throw new Error(`${label} missing after navigation`);
|
||||
if (!current?.some(x => x.includes(label + ' — Not implemented'))) throw new Error(`${label} body missing after navigation: ${JSON.stringify(current)}`);
|
||||
if (label === 'Runs' || label === 'Settings') await capture(`f2-shell-phone-${label.toLowerCase()}`, 390, 844);
|
||||
}
|
||||
await capture('f2-shell-desktop', 1280, 800);
|
||||
console.log(JSON.stringify({ labels, captures: ['f2-shell-phone.png', 'f2-shell-desktop.png'], navigated: ['Runs', 'Chat', 'Settings', 'Pipelines'] }, null, 2));
|
||||
console.log(JSON.stringify({ labels, captures: ['f2-shell-phone.png', 'f2-shell-phone-runs.png', 'f2-shell-phone-settings.png', 'f2-shell-desktop.png'], navigated: ['Runs', 'Chat', 'Settings', 'Pipelines'] }, null, 2));
|
||||
} finally {
|
||||
ws?.close();
|
||||
chrome.kill('SIGTERM');
|
||||
|
||||
Reference in New Issue
Block a user