/ concept-collection / numbl-web-ide
Sign in
concept-collection / numbl-web-ide
numbl-web-ide / scripts / live-check.mjs
38 lines · 1.8 KBCodeBlameHistory
6d654f3Add live-check script for the deployed siteJeremy Magland 1// Quick verification against the deployed GitHub Pages site.
2import { chromium } from 'playwright';
4const base = 'https://concept-collection.github.io/numbl-web-ide/';
5const out = process.argv[2] ?? '.';
6const browser = await chromium.launch({ channel: 'chrome', headless: true });
7const page = await browser.newPage({ viewport: { width: 1500, height: 900 } });
8const errors = [];
9page.on('pageerror', (e) => errors.push(e.message));
10page.on('console', (m) => { if (m.type() === 'error') errors.push(m.text()); });
11const check = (name, ok) => console.log(`${ok ? 'OK ' : 'FAIL'} ${name}`);
13try {
14 await page.goto(base, { waitUntil: 'networkidle' });
15 // the coi-serviceworker registers and reloads once on first visit
16 await page.waitForTimeout(3500);
17 check('cross-origin isolated', await page.evaluate(() => window.crossOriginIsolated));
18 check('landing renders', await page.locator('.landing-header').count() === 1);
19 await page.screenshot({ path: out + '/live-landing.png' });
21 await page.getByRole('button', { name: 'New sample project' }).click();
22 await page.waitForTimeout(2500);
23 check('IDE opened with waves.m', await page.locator('.mw-tab-label', { hasText: 'waves.m' }).count() === 1);
24 await page.locator('.mw-tab-action[title="numbl"]').click();
25 let ran = false;
26 for (let i = 0; i < 60 && !ran; i++) {
27 await page.waitForTimeout(500);
28 ran = ((await page.locator('.mw-output').innerText()).replace(/ /g, ' ')).includes('peak amplitude');
29 }
30 check('run output streamed', ran);
31 await page.waitForTimeout(2000);
32 check('figure view appears', await page.locator('.mw-auxbar .mw-panel-tab', { hasText: 'Figure 1' }).count() === 1);
33 await page.screenshot({ path: out + '/live-run.png' });
35 console.log(errors.length ? 'page errors:\n ' + errors.slice(0, 8).join('\n ') : 'no page errors');
36} finally {
37 await browser.close();
moveopenescclose