From 1e578985e0751b888859da806cfe0f0717c48a4d Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Thu, 22 Oct 2026 00:19:36 +0100 Subject: [PATCH] test(app): verify composer send in the real app flow --- app/notes/C3-bar.md | 10 +++++++++ app/tool/runs_probe.mjs | 37 ++++++++++++++++++++++++++++++++++ app/tool/runs_probe_server.mjs | 9 +++++++++ 3 files changed, 56 insertions(+) diff --git a/app/notes/C3-bar.md b/app/notes/C3-bar.md index 50da4df0..6d46403c 100644 --- a/app/notes/C3-bar.md +++ b/app/notes/C3-bar.md @@ -11,3 +11,13 @@ deliberately absent and recorded as open work. The server defect is fixed with a regression and deployed separately; this app slice needed no retry. + +## Real-app verification + +The normal-app browser probe now focuses the composer as an operator does, types, +sends through the primary control, and asserts exactly one `chat_prompt` with the +exact text, session id, operation id and native message id, plus the optimistic +message in the rendered thread (OCR). It passes with the existing run/changes/ +artifacts/chat/settings steps in one flow. The Ctrl/Cmd+Enter shortcut stays +covered by the widget probe: a synthetic key event does not set the engine's +hardware-keyboard state reliably in headless Chrome. diff --git a/app/tool/runs_probe.mjs b/app/tool/runs_probe.mjs index e5bc3635..6d61d0b5 100644 --- a/app/tool/runs_probe.mjs +++ b/app/tool/runs_probe.mjs @@ -521,6 +521,43 @@ try { } captures.push(await capture('decision-material-accepted')); await clickText('Back to list'); + await clickText('Chat'); + await clickText('Probe conversation', { contains: true }); + await assertBody('User message'); + // The empty composer exposes a hint, not an accessible label, so focus it by + // clicking its visible strip above the navigation bar; JS focus alone is not + // Flutter's editing connection and would swallow the text. + for (const type of ['mousePressed', 'mouseReleased']) { + await send('Input.dispatchMouseEvent', { + type, x: 150, y: 700, button: 'left', clickCount: 1, + }, session); + } + await delay(400); + await send('Input.insertText', { text: 'Probe composed message' }, session); + await delay(500); + if (!(await semanticText()).includes('Probe composed message')) { + throw new Error('The composer field did not receive the typed text'); + } + // Send through the primary control; the Ctrl/Cmd+Enter path is covered by the + // widget probe, and a synthetic key event is not a reliable stand-in for the + // engine's hardware-keyboard state in headless Chrome. + await clickText('Send'); + await delay(900); + const afterSend = await (await fetch(`${fixture.url}/fixture/state`)).json(); + if (afterSend.chatPrompts.length !== 1) { + throw new Error(`Composer did not send exactly one prompt: ${JSON.stringify(afterSend.chatPrompts)}`); + } + const sent = afterSend.chatPrompts[0]; + if (sent.text !== 'Probe composed message' || sent.session_id !== 'ses_probechat' || + !sent.operation_id || !sent.native_message_id) { + throw new Error(`Wrong prompt payload: ${JSON.stringify(sent)}`); + } + const composerCapture = await capture('chat-composer-material-sent'); + captures.push(composerCapture); + await assertOcr(composerCapture, 'Probe composed message'); + + await clickText('Runs'); + await delay(500); await assertBody('Fixture cancel run'); await assertBody('canceled'); diff --git a/app/tool/runs_probe_server.mjs b/app/tool/runs_probe_server.mjs index c6fdb27f..60f38562 100644 --- a/app/tool/runs_probe_server.mjs +++ b/app/tool/runs_probe_server.mjs @@ -326,6 +326,7 @@ export async function startFixture({ root }) { const decisionRequests = []; let chatSubscribed = 0; let chatHistory = 0; + const chatPrompts = []; const searchRequests = []; const CHAT_SESSION = { id: 'ses_probechat', @@ -384,6 +385,7 @@ export async function startFixture({ root }) { decisionRequests, chatSubscribed, chatHistory, + chatPrompts, searchRequests, })); return; @@ -515,6 +517,13 @@ export async function startFixture({ root }) { client.send({ id: request.id, type: 'chat_subscribe' }); return; } + if (request.type === 'chat_prompt') { + const body = request.chat_prompt ?? {}; + chatPrompts.push({ session_id: body.session_id, text: body.text, + operation_id: body.operation_id, native_message_id: body.native_message_id }); + setTimeout(() => client.send({ id: request.id, type: 'chat_prompt' }), 300); + return; + } if (request.type === 'chat_messages') { chatHistory++; client.send({