// Quick verification against the deployed GitHub Pages site. import { chromium } from 'playwright'; const base = 'https://concept-collection.github.io/numbl-web-ide/'; const out = process.argv[2] ?? '.'; const browser = await chromium.launch({ channel: 'chrome', headless: true }); const page = await browser.newPage({ viewport: { width: 1500, height: 900 } }); const errors = []; page.on('pageerror', (e) => errors.push(e.message)); page.on('console', (m) => { if (m.type() === 'error') errors.push(m.text()); }); const check = (name, ok) => console.log(`${ok ? 'OK ' : 'FAIL'} ${name}`); try { await page.goto(base, { waitUntil: 'networkidle' }); // the coi-serviceworker registers and reloads once on first visit await page.waitForTimeout(3500); check('cross-origin isolated', await page.evaluate(() => window.crossOriginIsolated)); check('landing renders', await page.locator('.landing-header').count() === 1); await page.screenshot({ path: out + '/live-landing.png' }); await page.getByRole('button', { name: 'New sample project' }).click(); await page.waitForTimeout(2500); check('IDE opened with waves.m', await page.locator('.mw-tab-label', { hasText: 'waves.m' }).count() === 1); await page.locator('.mw-tab-action[title="numbl"]').click(); let ran = false; for (let i = 0; i < 60 && !ran; i++) { await page.waitForTimeout(500); ran = ((await page.locator('.mw-output').innerText()).replace(/\u00a0/g, ' ')).includes('peak amplitude'); } check('run output streamed', ran); await page.waitForTimeout(2000); check('figure view appears', await page.locator('.mw-auxbar .mw-panel-tab', { hasText: 'Figure 1' }).count() === 1); await page.screenshot({ path: out + '/live-run.png' }); // mip: install + run the package demo await page.getByText('scripts', { exact: true }).click(); await page.waitForTimeout(400); await page.getByText('mip_demo.m', { exact: true }).click(); await page.waitForTimeout(600); await page.locator('.mw-tab-action[title="numbl"]').click(); let mipRan = false; for (let i = 0; i < 180 && !mipRan; i++) { await page.waitForTimeout(500); mipRan = ((await page.locator('.mw-output').innerText()).replace(/\u00a0/g, ' ')).includes('points inside: 201 / 2000'); } check('mip demo runs live', mipRan); await page.screenshot({ path: out + '/live-mip.png' }); console.log(errors.length ? 'page errors:\n ' + errors.slice(0, 8).join('\n ') : 'no page errors'); } finally { await browser.close(); }