diff --git a/tools/lib/harness.mjs b/tools/lib/harness.mjs index 81086f5d..1cc45e9a 100644 --- a/tools/lib/harness.mjs +++ b/tools/lib/harness.mjs @@ -192,8 +192,20 @@ function makeTools({ cdp, projectId, baseUrl, consoleLog, check, shotPrefix }) { await sleep(ms); await keyEvent('keyUp', name); }; + /** + * Typed per character to exercise the per-keystroke paths (live preview, search filters), then + * verified: a partial type is otherwise indistinguishable from a wrong value – a run once + * committed x=3 for "300" and the check blamed the value, not the lost characters. + */ const typeText = async (text) => { for (const ch of text) await cdp.send('Input.insertText', { text: ch }); + const typed = await json( + '({ tag: document.activeElement?.tagName, value: document.activeElement?.value })', + ); + if (typed.tag !== 'INPUT' || !String(typed.value ?? '').includes(text)) + throw new Error( + `typing "${text}" did not arrive: focus is ${typed.tag}, it holds ${JSON.stringify(typed.value)}`, + ); }; const undo = async () => { await press('z', { ctrl: true });