// New sections: no errors; flat panels at zero correction equal the page's straight-line counts for every source; // the last slider stop leaves nothing inconsistent; screenshots of each section. import { chromium } from 'playwright-core'; import { PAGE, HAND } from './paths.mjs'; const b = await chromium.launch({ executablePath: process.env.CH }); const errs = [], fails = []; for (const [w, h] of [[1440, 900], [390, 844]]) { const p = await b.newPage({ viewport: { width: w, height: h } }); p.on('pageerror', e => errs.push(`${w}: ${e.message}`)); p.on('console', m => { if (m.type() === 'error' && !/net::|ERR_/.test(m.text())) errs.push(`${w}: ${m.text()}`) }); await p.goto(PAGE('site/index.html')); await p.waitForTimeout(1500); for (const src of ['all', 'ours', 'gp', 'home']) { await p.selectOption('#srcsel', src); await p.waitForTimeout(150); const r = await p.evaluate(() => { const out = {}; for (const [m, , k] of FFM) { const f = D.flat.fits[S.src][k]; out[m] = [f.budgets[0].inconsistent.length, liveBad(m, 'line'), f.budgets[f.budgets.length - 1].inconsistent.length, f.routes, LP.length] } return out }); for (const [m, [b0, page, last, nr, lp]] of Object.entries(r)) if (b0 !== page || last !== 0 || nr !== lp) fails.push(`${w} ${src} ${m}: fit ${b0} page ${page} last ${last} routes ${nr}/${lp}`); } await p.selectOption('#srcsel', 'all'); await p.waitForTimeout(200); for (const [sec, name] of [['Networks on the measured paths', 'net'], ['Best attainable flat arrangements', 'ff'], ['Code and data', 'code']]) { const el = p.locator('h2.sec', { hasText: sec }).locator('xpath=..'); if (name === 'ff') for (const v of [0, 4, 6]) { await p.fill('#ffb', String(v)); await p.dispatchEvent('#ffb', 'input'); await p.waitForTimeout(250); await el.screenshot({ path: `out/sec_${name}${v}_${w}.png` }) } else await el.screenshot({ path: `out/sec_${name}_${w}.png` }); } const sw = await p.evaluate(() => document.documentElement.scrollWidth); if (sw !== w) fails.push(`${w}: page scrollWidth ${sw}`); const links = await p.evaluate(() => [...document.querySelectorAll('main a')].map(a => a.href)); console.log(w, 'links', links.length, [...new Set(links.map(u => new URL(u).host))]); await p.close(); } console.log('FAILS', JSON.stringify(fails)); console.log('ERRORS', JSON.stringify(errs)); await b.close();