Packages

A real-browser external-app verifier for patch-safe Phoenix LiveView interactions, with secondary unstyled reference components.

Current section

Files

Jump to
live_interaction_contracts priv combobox-spike probe.mjs
Raw

priv/combobox-spike/probe.mjs

import { chromium } from 'playwright';
const b = await chromium.launch(); const p = await (await b.newContext()).newPage();
p.on('pageerror', e => console.log('PAGEERR', String(e).slice(0,200)));
await p.goto('http://127.0.0.1:4127/');
await p.waitForFunction(()=>document.querySelector('[data-phx-main]')?.classList.contains('phx-connected'),null,{timeout:8000});
await p.waitForTimeout(200);
// type "a" via real typing to trigger Channel input
await p.click('#cb-input'); await p.type('#cb-input','a');
await p.waitForFunction(()=>document.getElementById('dbg-count').textContent!=='0',null,{timeout:5000}).catch(()=>{});
await p.waitForTimeout(150);
console.log('results:', await p.evaluate(()=>[...document.querySelectorAll('#cb-list [data-item]')].map(n=>n.getAttribute('data-item'))));
console.log('list data-version:', await p.evaluate(()=>document.getElementById('cb-list').getAttribute('data-version')));
console.log('lastV:', await p.evaluate(()=>window.__cb.lastV));
console.log('focus stays on input:', await p.evaluate(()=>document.activeElement?.id));
// arrow down twice
await p.keyboard.press('ArrowDown'); await p.keyboard.press('ArrowDown');
await p.waitForTimeout(100);
console.log('active:', await p.evaluate(()=>window.__cb.active), 'aria:', await p.evaluate(()=>document.getElementById('cb-input').getAttribute('aria-activedescendant')), 'focusStill:', await p.evaluate(()=>document.activeElement?.id));
await b.close();