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'] }); 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(2200); await page.locator('.room', { hasText: 'quarry' }).click(); await page.waitForTimeout(600); await page.locator('.core-tab').first().click(); await page.waitForTimeout(400); const stats = page.locator('.face-stats'); const before = (await stats.textContent())?.replace(/\s+/g, ' ').trim(); const canvas = page.locator('canvas.wave'); const box = await canvas.boundingBox(); if (!box) throw new Error('no waveform'); await page.mouse.move(box.x + 3, box.y + 60); await page.mouse.down(); await page.mouse.move(box.x + 70, box.y + 60, { steps: 10 }); await page.mouse.up(); await page.waitForTimeout(900); const after = (await stats.textContent())?.replace(/\s+/g, ' ').trim(); await page.screenshot({ path: '../preview-p1d-faces.png' }); const report = await page.evaluate(() => ({ trim: document.querySelector('.face-stats')?.textContent?.replace(/\s+/g, ' ').trim(), wire: [...document.querySelectorAll('.wire-label')].map((el) => el.textContent).slice(-5), undoDisabled: document.querySelector('.history-button[aria-label="undo"]')?.hasAttribute('disabled'), face: document.querySelector('.face.is-on .face-index')?.textContent, selected: document.querySelector('.core-tab.is-on .core-name')?.textContent })); console.log(JSON.stringify({ before, after, report, errors }, null, 2)); const failures = []; if (!before || !after || before === after) failures.push('trim did not change'); if (!report.wire.some((label) => label?.startsWith('cut'))) failures.push('no cut command on the wire'); if (report.undoDisabled) failures.push('undo did not enable after the cut'); if (errors.length) failures.push('console errors'); await browser.close(); if (failures.length) { console.error('FACES SMOKE FAILED: ' + failures.join('; ')); process.exit(1); } console.log('faces smoke passed');