// Load the public site in a browser at desktop and phone size: no errors, counts equal the hand-off data file. import { chromium } from 'playwright-core'; import fs from 'fs'; import { PAGE, HAND } from './paths.mjs'; const URL_ = process.env.SITE || 'https://pingstats.aethercosmology.com/'; const d = JSON.parse(fs.readFileSync(HAND('cable_latency_survey_data_v2.json'), 'utf8')); const b = await chromium.launch({ executablePath: process.env.CH }); const errs = []; 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') errs.push(`${w}: ${m.text()}`) }); const res = await p.goto(URL_, { waitUntil: 'networkidle' }); await p.waitForTimeout(1500); const r = await p.evaluate(() => ({ routes: LP.length, ae: [liveBad('ae'), liveVac('ae')], sw: document.documentElement.scrollWidth, fonts: [...document.fonts].filter(f => f.status === 'loaded').map(f => f.family).filter((x, i, a) => a.indexOf(x) === i) })); const f = d.summary.all_live.cable_route.ae; const out = {}; for (const [src, key] of [['ours', 'vultr'], ['gp', 'globalping'], ['home', 'home']]) { await p.selectOption('#srcsel', src); await p.waitForTimeout(150); out[src] = await p.evaluate(() => [LP.length, liveBad('ae'), liveVac('ae')]); const s = d.summary[key]; if (out[src][0] !== s.routes || out[src][1] !== s.cable_route.ae.impossible_total || out[src][2] !== s.cable_route.ae.beats_vacuum) errs.push(`${w} ${src} mismatch ${out[src]}`) } await p.selectOption('#srcsel', 'all'); await p.waitForTimeout(400); await p.screenshot({ path: `out/live_${w}.png` }); console.log(w, res.status(), JSON.stringify(r), JSON.stringify(out), r.routes === d.summary.all_live.routes && r.ae[0] === f.impossible_total && r.ae[1] === f.beats_vacuum && r.sw === w ? 'ok' : 'MISMATCH'); await p.close(); } console.log('ERRORS', JSON.stringify(errs)); await b.close();