import { chromium } from 'playwright-core'; import fs from 'fs'; import path from 'path'; const loginRes = await fetch('http://127.0.0.1:8010/api/auth/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ phone: '13943441149', password: 'Test1234' }) }); const loginData = await loginRes.json(); const browser = await chromium.launch({ channel: 'chrome', headless: true, executablePath: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe' }); const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 } }); await ctx.addInitScript(([at, rt]) => { localStorage.setItem('access_token', at); localStorage.setItem('refresh_token', rt); }, [loginData.access_token, loginData.refresh_token]); const page = await ctx.newPage(); const errors = []; page.on('console', m => { if (m.type() === 'error') errors.push(m.text()); }); page.on('pageerror', e => errors.push('PAGEERROR: ' + e.message)); // Go to home and wait longer await page.goto('http://127.0.0.1:5175/home', { waitUntil: 'networkidle', timeout: 20000 }).catch(e => console.log('goto err', e.message)); await page.waitForTimeout(4000); // Diagnose const info = await page.evaluate(() => { const body = document.body; return { bodyTextLen: body.innerText.length, bodyTextHead: body.innerText.substring(0, 300), url: location.href, hasH1: !!document.querySelector('h1'), h1Text: document.querySelector('h1')?.textContent || '(none)', mainContent: document.querySelector('.home-page, .home-container, .hero, main, #app')?.innerHTML?.length || 0, childCount: document.querySelector('#app')?.children?.length || 0, }; }); console.log(JSON.stringify(info, null, 2)); await page.screenshot({ path: path.resolve('audit_shots/home2.png') }); console.log('ERRORS:', errors.length); errors.slice(0,8).forEach(e => console.log(' ', e.substring(0,160))); await browser.close();