import { chromium } from 'playwright-core'; const chrome = process.env.CHROME_PATH ?? '/home/emil/.cache/ms-playwright/chromium-1248/chrome-linux64/chrome'; const browser = await chromium.launch({ executablePath: chrome, args: ['--no-sandbox', '--autoplay-policy=no-user-gesture-required'] }); const page = await browser.newPage({ viewport: { width: 1600, height: 1000 }, deviceScaleFactor: 1 }); const errors = []; page.on('pageerror', (error) => errors.push(`pageerror: ${error.message}`)); page.on('console', (message) => { if (message.type() === 'error') errors.push(`console: ${message.text()}`); }); await page.goto('http://127.0.0.1:5173/', { waitUntil: 'load' }); await page.waitForTimeout(2800); await page.screenshot({ path: '../preview-p0.png' }); if (await page.locator('.play.is-playing').count()) { await page.click('.play'); await page.waitForTimeout(400); } await page.click('.play'); await page.waitForTimeout(3000); await page.click('.strike'); await page.waitForTimeout(1300); await page.screenshot({ path: '../preview-p0-playing.png' }); const report = await page.evaluate(() => ({ net: document.querySelector('.net b')?.textContent, status: document.querySelector('.wire-status')?.textContent?.trim(), wire: [...document.querySelectorAll('.wire-label')].slice(-8).map((el) => el.textContent), facts: [...document.querySelectorAll('.fact b')].map((el) => el.textContent), lanes: [...document.querySelectorAll('.lane')].map((el) => el.getAttribute('aria-pressed')), gains: [...document.querySelectorAll('.vein-gain')].map((el) => el.textContent), cilia: [...document.querySelectorAll('.cilium')].map((el) => Number(getComputedStyle(el).getPropertyValue('--level'))), trace: Boolean(document.querySelector('canvas.trace')), time: document.querySelector('.clock-time')?.textContent, bar: document.querySelector('.clock-bar')?.textContent, master: document.querySelector('.master-db')?.textContent, canvas: { w: document.querySelector('canvas')?.width, h: document.querySelector('canvas')?.height } })); console.log(JSON.stringify(report, null, 2)); console.log(errors.length ? errors.join('\n') : 'no console errors'); const failures = []; if (report.net !== 'live') failures.push('the engine did not report live'); if (!report.wire.includes('play')) failures.push('the wire did not record play'); if (!report.wire.includes('strike bass 0.85')) failures.push('the wire did not record the strike'); if (!report.trace) failures.push('the signal trace is missing'); if (!report.gains.length) failures.push('the vein gains are missing'); if (!report.cilia.some((level) => level > 0.001)) failures.push('no cilia level moved'); if (!(report.canvas.w > 1000)) failures.push('the descent canvas did not size to the hero'); if (errors.length) failures.push('console errors'); await browser.close(); if (failures.length) { console.error('SMOKE FAILED: ' + failures.join('; ')); process.exit(1); } console.log('smoke passed');