import { chromium } from 'playwright-core'; import fs from 'fs'; import { PAGE, HAND } from './paths.mjs'; const d = JSON.parse(fs.readFileSync(HAND('cable_latency_survey_data.json'), 'utf8')); const b = await chromium.launch({ executablePath: process.env.CH }); const errs = [], blocked = []; for (const [w, h] of [[1440, 900], [390, 844]]) { const p = await b.newPage({ viewport: { width: w, height: h } }); await p.route('**/*', r => { const u = r.request().url(); if (u.startsWith('file:')) return r.continue(); blocked.push(u); return r.abort(); }); p.on('pageerror', e => errs.push(`${w}: ${e.message}`)); p.on('console', m => { if (m.type() === 'error' && !/ERR_FAILED|net::/.test(m.text())) errs.push(`${w}: ${m.text()}`) }); await p.goto(PAGE('site/index.html'), { waitUntil: 'load' }); await p.waitForTimeout(2500); const r = await p.evaluate(() => ({ d3: typeof d3, drawn: hits.length, routes: LP.length, ae: [liveBad('ae'), liveVac('ae')], sw: document.documentElement.scrollWidth, doctype: document.doctype && document.doctype.name, title: document.title })); const f = d.summary.all_live.cable_route.ae; console.log(w, JSON.stringify(r), r.routes === d.summary.all_live.routes && r.ae[0] === f.impossible_total && r.ae[1] === f.beats_vacuum ? 'matches data file' : 'MISMATCH'); for (const src of ['ours', 'gp', 'home']) { await p.selectOption('#srcsel', src); await p.waitForTimeout(200); } await p.selectOption('#srcsel', 'all'); await p.waitForTimeout(300); await p.screenshot({ path: `out/offline_${w}.png` }); await p.close(); } console.log('blocked external requests:', [...new Set(blocked.map(u => new URL(u).host))]); console.log('ERRORS', JSON.stringify(errs)); await b.close();