From e2b1464b04ede7c05f58d333d9b194fe25635ef2 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Wed, 21 Oct 2026 23:07:31 +0100 Subject: [PATCH] test(app): verify the Chat destination in the real app flow --- app/tool/runs_probe.mjs | 22 ++++++++++++++++++++ app/tool/runs_probe_server.mjs | 37 ++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/app/tool/runs_probe.mjs b/app/tool/runs_probe.mjs index 4727a42d..e5bc3635 100644 --- a/app/tool/runs_probe.mjs +++ b/app/tool/runs_probe.mjs @@ -470,6 +470,28 @@ try { } captures.push(await capture('settings-material-registered-phone')); + // The registered Chat destination opens a real conversation over the shared + // socket: list row -> session route -> stored turn, then Back to the list. + await clickText('Chat'); + await assertBody('Probe conversation'); + captures.push(await capture('chat-material-list')); + await clickText('Probe conversation', { contains: true }); + await assertBody('User message'); + await assertBody('Assistant message'); + if ((await path()) !== '/chat/ses_probechat') { + throw new Error(`Chat selection did not update the route: ${await path()}`); + } + await delay(900); + const threadCapture = await capture('chat-material-thread'); + captures.push(threadCapture); + await assertOcr(threadCapture, 'Read-only probe question.'); + await assertOcr(threadCapture, 'Stored probe answer.'); + await clickText('Back', { contains: true }); + await assertBody('Probe conversation'); + if ((await path()) !== '/chat') { + throw new Error(`Chat Back left the route at ${await path()}`); + } + await clickText('Runs'); await clickText('Fixture cancel run', { contains: true }); await assertBody('Original prompt'); diff --git a/app/tool/runs_probe_server.mjs b/app/tool/runs_probe_server.mjs index aa7d9d55..c9fcbe61 100644 --- a/app/tool/runs_probe_server.mjs +++ b/app/tool/runs_probe_server.mjs @@ -324,6 +324,15 @@ export async function startFixture({ root }) { const cancelRequests = []; let decisionAccepted = false; const decisionRequests = []; + let chatSubscribed = 0; + let chatHistory = 0; + const CHAT_SESSION = { + id: 'ses_probechat', + title: 'Probe conversation', + kind: 'operator', + directory: '/srv/probe', + updated_at: '2026-10-21T12:00:00Z', + }; const dropConnections = () => { for (const connection of connections) connection.close(); @@ -372,6 +381,8 @@ export async function startFixture({ root }) { getRun, cancelRequests, decisionRequests, + chatSubscribed, + chatHistory, })); return; } @@ -463,6 +474,32 @@ export async function startFixture({ root }) { client.send({ id: request.id, type: 'run', run_detail: humanDetail(true) }); return; } + if (request.type === 'chat_sessions') { + client.send({ id: request.id, type: 'chat_sessions', + chat_sessions: [CHAT_SESSION] }); + return; + } + if (request.type === 'chat_subscribe') { + chatSubscribed++; + client.send({ id: request.id, type: 'chat_subscribe' }); + return; + } + if (request.type === 'chat_messages') { + chatHistory++; + client.send({ + id: request.id, type: 'chat_history', + chat_history: { + messages: [ + { id: 'm1', session_id: CHAT_SESSION.id, role: 'user', + parts: [{ type: 'text', text: 'Read-only probe question.' }] }, + { id: 'm2', session_id: CHAT_SESSION.id, role: 'assistant', + parts: [{ type: 'text', text: 'Stored probe answer.' }] }, + ], + next_cursor: '', has_more: false, + }, + }); + return; + } client.send({ id: request.id, type: 'error',