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); await page.locator('.room', { hasText: 'quarry' }).click(); await page.waitForTimeout(600); const sectionCount = await page.locator('.section').count(); const notesBefore = await page.locator('.section-notes').allTextContents(); await page.locator('.section').nth(1).click(); await page.waitForTimeout(350); const active = await page.locator('.section.is-on .section-letter').textContent(); await page.locator('.pattern .step').first().click(); await page.waitForTimeout(500); const notesAfter = await page.locator('.section-notes').allTextContents(); await page.locator('.room', { hasText: 'nave' }).click(); await page.waitForTimeout(600); if (!(await page.locator('.play.is-playing').count())) await page.locator('.play').click(); await page.waitForTimeout(1800); await page.screenshot({ path: '../preview-p2-arrangement.png' }); const report = await page.evaluate(() => ({ sections: document.querySelectorAll('.section').length, active: document.querySelector('.section.is-on .section-letter')?.textContent, notes: [...document.querySelectorAll('.section-notes')].map((el) => el.textContent?.trim()), wire: [...document.querySelectorAll('.wire-label')].map((el) => el.textContent).slice(-6), bar: document.querySelector('.clock-bar')?.textContent ?? document.querySelector('.transport')?.textContent?.slice(0, 40), master: document.querySelector('.master-db')?.textContent })); console.log(JSON.stringify({ sectionCount, notesBefore, active, notesAfter, report, errors }, null, 2)); const failures = []; if (sectionCount !== 4) failures.push('expected four sections'); if (active !== 'B') failures.push('section B was not selected'); if (notesAfter[0] === notesBefore[0] && notesAfter[1] === notesBefore[1]) failures.push('section notes did not change'); if (!report.wire.some((label) => label?.startsWith('step'))) failures.push('no step command on the wire'); if (errors.length) failures.push('console errors'); await browser.close(); if (failures.length) { console.error('ARRANGEMENT SMOKE FAILED: ' + failures.join('; ')); process.exit(1); } console.log('arrangement smoke passed');