merge(app): land probe-chat-create (runs 170, 174 + direct fix)

This commit is contained in:
2026-10-23 01:22:29 +01:00
2 changed files with 57 additions and 22 deletions
+50 -17
View File
@@ -98,6 +98,22 @@ try {
const click = async (label, what = label) => {
if (!await clickLabel(label)) throw new Error(`Could not click ${what}`);
};
const clickCreateConfirm = async () => {
const point = await evaluate(`(() => {
const dialog = [...document.querySelectorAll('[role="dialog"], [role="alertdialog"]')]
.find(node => node.innerText.includes('Start a chat'));
if (!dialog) return null;
const confirm = [...dialog.querySelectorAll('flt-semantics')]
.find(node => (node.getAttribute('aria-label') || node.innerText || '') === 'New chat');
if (!confirm) return null;
const rect = confirm.getBoundingClientRect();
return {x: rect.x + rect.width / 2, y: rect.y + rect.height / 2};
})()`);
if (!point) throw new Error('Could not find New chat confirm inside the Start a chat dialog');
await send('Input.dispatchMouseEvent', { type: 'mousePressed', x: point.x, y: point.y, button: 'left', clickCount: 1 }, session);
await send('Input.dispatchMouseEvent', { type: 'mouseReleased', x: point.x, y: point.y, button: 'left', clickCount: 1 }, session);
await delay(500);
};
const clickFirst = async label => {
const point = await evaluate(`(() => { const needle = ${JSON.stringify(label)}; const e=[...document.querySelectorAll('flt-semantics')].find(x => (x.getAttribute('aria-label') || x.innerText || '') === needle); if (!e) return null; e.scrollIntoView({block:'center'}); const r=e.getBoundingClientRect(); return {x:r.x+r.width/2,y:r.y+r.height/2}; })()`);
if (!point) throw new Error(`Could not find ${label}`);
@@ -176,7 +192,8 @@ try {
// Dialog chrome at the smallest size the list supports (320 CSS px, 2x DPR).
await click('New chat', 'the New chat action');
await waitText('Server directory', 'the create dialog at 320');
await waitText('Start a chat', 'the create dialog at 320');
await waitText('Where should this chat live?', 'the directory picker at 320');
await shot('create-320-2x', 320, 640, 2);
await click('Cancel', 'Cancel the create dialog');
await resize(390, 844);
@@ -192,9 +209,24 @@ try {
await load('?unseen=1');
await resize(390, 844);
await click('Refresh', 'Refresh');
await waitText('/workspace/demo · New', 'the open row New marker');
const unseenBody = await visibleText();
if (unseenBody.includes('/workspace/archive · New')) {
await waitText('Open fixture', 'the open row');
await waitText('/workspace/demo', 'the open row directory');
const unseenRows = await evaluate(`[...document.querySelectorAll('flt-semantics')].map(node => ({
text: node.getAttribute('aria-label') || node.innerText || '',
rect: (() => { const r = node.getBoundingClientRect(); return {x:r.x, y:r.y, width:r.width, height:r.height}; })(),
})).filter(node => node.text && node.rect.width && node.rect.height)`);
const openRow = unseenRows.find(node => {
const lines = node.text.split('\n');
return lines.includes('Open fixture') && lines.includes('/workspace/demo');
});
const closedRow = unseenRows.find(node => {
const lines = node.text.split('\n');
return lines.includes('Closed fixture') && lines.includes('/workspace/archive');
});
if (!openRow || !openRow.text.split('\n').includes('New')) {
throw new Error('The open row did not report New');
}
if (!closedRow || !closedRow.text.split('\n').includes('Closed') || closedRow.text.split('\n').includes('New')) {
throw new Error('The closed row reported New');
}
await shot('new-marker', 390, 844);
@@ -203,10 +235,9 @@ try {
// A create reply without `chat_session` uses the web's exact sentence.
await click('New chat', 'the New chat action');
await waitText('Server directory', 'the create dialog');
await focusInput();
await type('No session title');
await click('Create', 'the create dialog confirm');
await waitText('Start a chat', 'the create dialog');
await waitText('Where should this chat live?', 'the directory picker');
await clickCreateConfirm();
await waitText(
'The server did not return the new chat session.',
'the missing-session wording',
@@ -219,25 +250,27 @@ try {
// Create: the dialog sends once and the accepted row arrives from a list read.
await click('New chat', 'the New chat action');
await waitText('Create', 'the create dialog');
await focusInput();
await type('Probe created');
await click('Create', 'the create dialog confirm');
await waitText('Start a chat', 'the create dialog');
await waitText('Where should this chat live?', 'the directory picker');
await clickCreateConfirm();
if (process.env.PROBE_DEBUG) console.log(JSON.stringify({ afterCreate: await bodyText(), labels: await semantics() }, null, 2));
await waitText('Probe created', 'the created row');
await waitText('New chat', 'the created row');
if ((await visibleText()).includes('no chat harness')) throw new Error('Create did not reach the fixture');
await shot('created-list', 390, 844);
// Rename: seeded with the current title, then the row reads the accepted name.
await click('Chat actions for Probe created', 'the created row actions');
// Rename: the server-assigned fixed title is changed and read back.
await click('Chat actions for New chat', 'the created row actions');
await click('Rename…', 'Rename…');
await waitText('Rename chat', 'the rename dialog');
const seeded = await focusInput();
if (seeded !== 'Probe created') throw new Error(`Rename was seeded with ${JSON.stringify(seeded)}`);
if (seeded !== 'New chat') throw new Error(`Rename was seeded with ${JSON.stringify(seeded)}`);
await type('Probe renamed');
await click('Save', 'the rename Save');
await waitText('Probe renamed', 'the renamed row');
if ((await visibleText()).includes('Probe created')) throw new Error('The old title survived the accepted rename');
// The list's own `New chat` action stays on screen, so the old title is
// checked on the row's actions label, which names the row's title.
if ((await semantics()).includes('Chat actions for New chat')) throw new Error('The old title survived the accepted rename');
if (!(await semantics()).includes('Chat actions for Probe renamed')) throw new Error('The renamed row has no actions under its new title');
await shot('renamed-list', 390, 844);
// Star the renamed row (the first unstarred row in server order).
+7 -5
View File
@@ -8,9 +8,9 @@ import 'package:pipelines_app/features/chat/session_screen.dart';
/// Stateful chat-session fixture for the real-browser probe: every accepted
/// mutation changes the list the next `chat_sessions` read returns, so the
/// screen must refresh from the server rather than guess. A title of
/// `Refused title` is refused with the server's words; `No session title`
/// returns a create reply without `chat_session`; `?unseen=1` reports newer
/// recency after the first read so the `New` marker can be observed.
/// `Refused title` is refused with the server's words; the first create returns
/// a reply without `chat_session`; `?unseen=1` reports newer recency after the
/// first read so the `New` marker can be observed.
class _FixtureGateway implements ApiGateway {
_FixtureGateway({this.bumpAfterFirstRead = false});
@@ -18,6 +18,7 @@ class _FixtureGateway implements ApiGateway {
/// reads report newer activity, so the browser can prove the `New` marker.
final bool bumpAfterFirstRead;
int _reads = 0;
int _creates = 0;
final _sessions = <JsonMap>[
{
@@ -66,8 +67,9 @@ class _FixtureGateway implements ApiGateway {
};
case 'chat_create':
final body = fields['chat_create']! as JsonMap;
// The web's exact refusal for a reply without a created session.
if ('${body['title']}' == 'No session title') return const {};
// Exercise the missing-session refusal independently of the fixed
// title the create dialog now submits.
if (_creates++ == 0) return const {};
final session = {
'id': 'probe-new-${_nextId++}',
'title': body['title'],