import { chromium } from 'playwright-core'; const targets = ['https://novalon.cn/', 'https://novalon.cn/products/erp', 'https://novalon.cn/contact']; const browser = await chromium.launch(); const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }); let bad = 0; for (const url of targets) { const page = await ctx.newPage(); const failed = []; const consoleErrs = []; page.on('response', (r) => { if (r.status() >= 400 && r.request().method() === 'GET') failed.push(`${r.status()} ${r.url()}`); }); page.on('console', (m) => { if (m.type() === 'error') consoleErrs.push(m.text().slice(0, 120)); }); await page.goto(url, { waitUntil: 'networkidle', timeout: 60000 }); const probe = await page.evaluate(() => { const h1 = document.querySelector('h1'); const cs = h1 ? getComputedStyle(h1) : null; const brand = [...document.querySelectorAll('*')].find((e) => { const c = getComputedStyle(e).color; return c === 'rgb(196, 30, 58)'; }); return { sheets: document.styleSheets.length, h1: h1 ? h1.textContent.trim().slice(0, 24) : null, h1Font: cs ? cs.fontFamily.slice(0, 24) : null, h1Size: cs ? cs.fontSize : null, brandRedNodes: !!brand, hydrated: !!document.querySelector('[data-reactroot], [data-reactid]') || !!window.nextVersion || typeof window.__next_f !== 'undefined', }; }); const uniqFailed = [...new Set(failed)]; console.log(`\n### ${url}`); console.log(` stylesheets=${probe.sheets} h1="${probe.h1}" font=${probe.h1Font}/${probe.h1Size} brandRed=${probe.brandRedNodes} nextData=${probe.hydrated}`); console.log(` 4xx/5xx GET = ${uniqFailed.length}`); uniqFailed.slice(0, 6).forEach((f) => console.log(` ${f}`)); console.log(` console errors = ${consoleErrs.length}`); [...new Set(consoleErrs)].slice(0, 4).forEach((e) => console.log(` ${e}`)); bad += uniqFailed.filter((f) => !/\/(api\/)?healthz/.test(f)).length; await page.close(); } await browser.close(); console.log(`\nTOTAL_FAILED_GETS=${bad}`);