Add live-check script for the deployed site
1 changed file+38−0
scripts/live-check.mjsadded+38−0View file
@@ -0,0 +1,38 @@
1+// Quick verification against the deployed GitHub Pages site.
2+import { chromium } from 'playwright';
3+
4+const base = 'https://concept-collection.github.io/numbl-web-ide/';
5+const out = process.argv[2] ?? '.';
6+const browser = await chromium.launch({ channel: 'chrome', headless: true });
7+const page = await browser.newPage({ viewport: { width: 1500, height: 900 } });
8+const errors = [];
9+page.on('pageerror', (e) => errors.push(e.message));
10+page.on('console', (m) => { if (m.type() === 'error') errors.push(m.text()); });
11+const check = (name, ok) => console.log(`${ok ? 'OK ' : 'FAIL'} ${name}`);
12+
13+try {
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' });
20+
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' });
34+
35+ console.log(errors.length ? 'page errors:\n ' + errors.slice(0, 8).join('\n ') : 'no page errors');
36+} finally {
37+ await browser.close();
38+}