import { chromium } from 'playwright-core'; import { PAGE, HAND } from './paths.mjs'; const b = await chromium.launch({ executablePath: process.env.CH }); const p = await b.newPage({ viewport: { width: 1440, height: 900 } }); const errs = []; p.on('pageerror', e => errs.push(e.message)); p.on('console', m => { if (m.type() === 'error') errs.push(m.text()) }); await p.goto(PAGE('web/index.html'), { waitUntil: 'load' }); await p.waitForTimeout(2500); const fails = []; for (const src of ['ours', 'gp', 'home', 'all']) { await p.selectOption('#srcsel', src); await p.waitForTimeout(1000); const r = await p.evaluate(() => ({ n: LP.length, ae: [liveBad('ae'), liveVac('ae')], big: document.getElementById('rbig').textContent, lab: document.getElementById('rlab').innerText.replace(/\s+/g,' '), sel: `${LS[LP[S.sel].a].name}-${LS[LP[S.sel].b].name}`, by: document.querySelector('#card .meas span')?.innerText, score: document.querySelector('#score tbody tr:nth-child(2) td:nth-child(2)').innerText.replace(/\s+/g,' '), vultrOnly: LP.every(q => q.cells.every(c => /Vultr/.test(c.net))), gpOnly: LP.every(q => q.cells.every(c => !/Vultr|^home/.test(c.net))), homeOnly: LP.every(q => q.cells.every(c => /^home/.test(c.net))), drawn: hits.length })); await p.waitForTimeout(800); if (+r.big !== r.ae[0]) fails.push(`${src}: counter ${r.big} != ${r.ae[0]}`); if (src === 'ours' && !r.vultrOnly) fails.push('ours: non-Vultr cells present'); if (src === 'gp' && !r.gpOnly) fails.push('gp: other sources present'); if (src === 'home' && !r.homeOnly) fails.push('home: other sources present'); console.log(src, JSON.stringify(r)); await p.screenshot({ path: `out/src_${src}.png` }); } console.log('FAILS', JSON.stringify(fails), 'ERRORS', JSON.stringify(errs)); await b.close();