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 cursor-spike probe.mjs
Raw

priv/cursor-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:4126/');
await p.waitForFunction(() => document.querySelector('[data-phx-main]')?.classList.contains('phx-connected'), null, {timeout:8000}).catch(()=>console.log('not connected'));
await p.waitForTimeout(300);
console.log('items:', await p.evaluate(() => [...document.querySelectorAll('[data-item]')].map(n=>({id:n.id, li:n.getAttribute('data-item'), active:n.getAttribute('data-active'), tab:n.getAttribute('tabindex')}))));
console.log('aria-activedescendant:', await p.evaluate(() => document.getElementById('clist')?.getAttribute('aria-activedescendant')));
console.log('cursorLog:', await p.evaluate(() => window.__cursorLog));
// move down twice
await p.evaluate(()=>document.getElementById('clist').focus());
await p.keyboard.press('ArrowDown'); await p.keyboard.press('ArrowDown');
await p.waitForTimeout(150);
console.log('after 2x down, active:', await p.evaluate(() => [...document.querySelectorAll('[data-item][data-active=true]')].map(n=>n.getAttribute('data-item'))));
console.log('store:', await p.evaluate(() => window.__cursorStore));
await b.close();