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(2200); const projectName = (await page.locator('.project').textContent())?.trim(); const undoInitially = await page.locator('.history-button[aria-label="undo"]').isDisabled(); await page.locator('.room', { hasText: 'quarry' }).click(); await page.waitForTimeout(400); await page.locator('input[type=file]').setInputFiles('../fixtures/clicks-01.wav'); await page.waitForFunction(() => document.querySelector('.core-name')?.textContent?.includes('clicks-01'), null, { timeout: 20000 }); await page.waitForTimeout(700); await page.locator('.face').nth(10).click(); await page.waitForTimeout(200); await page.locator('.assign').click(); await page.waitForTimeout(500); const assigned = (await page.locator('.pattern-row .pattern-face').first().textContent())?.trim(); const undoEnabled = !(await page.locator('.history-button[aria-label="undo"]').isDisabled()); await page.locator('.history-button[aria-label="undo"]').click(); await page.waitForTimeout(400); const undone = (await page.locator('.pattern-row .pattern-face').first().textContent())?.trim(); await page.locator('.history-button[aria-label="redo"]').click(); await page.waitForTimeout(400); const redone = (await page.locator('.pattern-row .pattern-face').first().textContent())?.trim(); if (!(await page.locator('.play.is-playing').count())) await page.locator('.play').click(); await page.waitForTimeout(1600); await page.screenshot({ path: '../preview-p1b-quarry.png' }); const report = await page.evaluate(() => ({ project: document.querySelector('.project')?.textContent?.trim(), cores: [...document.querySelectorAll('.core-name')].map((el) => el.textContent), faces: document.querySelectorAll('.face').length, patternFace: document.querySelector('.pattern-row .pattern-face')?.textContent?.trim(), undoDisabled: document.querySelector('.history-button[aria-label="undo"]')?.hasAttribute('disabled'), redoDisabled: document.querySelector('.history-button[aria-label="redo"]')?.hasAttribute('disabled'), wire: [...document.querySelectorAll('.wire-label')].map((el) => el.textContent).slice(-6), master: document.querySelector('.master-db')?.textContent })); console.log(JSON.stringify({ projectName, undoInitially, assigned, undoEnabled, undone, redone, report }, null, 2)); const failures = []; if (!projectName) failures.push('no project name'); if (!undoInitially) failures.push('undo was enabled on a fresh project'); if (!report.cores.length) failures.push('no core imported'); if (report.faces !== 16) failures.push('expected 16 faces'); if (!assigned || assigned.startsWith('procedural')) failures.push('face was not assigned'); if (!undoEnabled) failures.push('undo did not enable'); if (!undone || !undone.startsWith('procedural')) failures.push('undo did not revert the face'); if (!redone || redone.startsWith('procedural')) failures.push('redo did not restore the face'); if (errors.length) failures.push('console errors'); await browser.close(); if (failures.length) { console.error('PROJECT SMOKE FAILED: ' + failures.join('; ')); process.exit(1); } console.log('project smoke passed');