test(app): find the composer field instead of a fixed point

This commit is contained in:
2026-10-22 11:48:04 +01:00
parent 81b2805cdd
commit dd890a93a3
+15 -4
View File
@@ -532,12 +532,23 @@ try {
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.
// The empty composer exposes a hint, not an accessible label. Locate the
// semantics text field and click its centre: a fixed point misses once an
// attachment strip grows the composer, and JS focus alone is not Flutter's
// editing connection.
const composerPoint = await evaluate(`(() => {
const fields = [...document.querySelectorAll('flt-semantics[role="textbox"], input, textarea')];
const rects = fields
.map((el) => el.getBoundingClientRect())
.filter((r) => r.width > 40 && r.height > 10);
if (!rects.length) return null;
const lowest = rects.sort((a, b) => b.bottom - a.bottom)[0];
return { x: lowest.left + lowest.width / 2, y: lowest.top + lowest.height / 2 };
})()`);
if (!composerPoint) throw new Error('The composer text field is not exposed');
for (const type of ['mousePressed', 'mouseReleased']) {
await send('Input.dispatchMouseEvent', {
type, x: 150, y: 700, button: 'left', clickCount: 1,
type, x: composerPoint.x, y: composerPoint.y, button: 'left', clickCount: 1,
}, session);
}
await delay(400);