1// Quick verification against the deployed GitHub Pages site.
2import { chromium } from 'playwright';
4const base = 'https://concept-collection.github.io/stan-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 // returning visitors unregister the old coi-serviceworker and reload once
16 await page.waitForTimeout(3500);
17 check('landing renders', await page.locator('.landing-header').count() === 1);
18 await page.screenshot({ path: out + '/live-landing.png' });
20 await page.getByRole('button', { name: 'New sample project' }).click();
21 await page.waitForTimeout(2500);
22 check('fit.sample opens as form', await page.locator('.sample-editor h2', { hasText: 'fit.sample' }).count() === 1);
23 check('form: stan file selected', await page.locator('.sample-editor select').first().inputValue() === 'linear.stan');
25 // Stan LSP diagnostics on the live bundle
26 await page.locator('.mw-explorer-item-label').filter({ hasText: /^linear\.stan$/ }).click();
27 await page.waitForTimeout(3000);
28 await page.locator('.view-lines').first().click();
29 await page.keyboard.press('Control+End');
30 await page.keyboard.type('\nbroken');
31 let sawMarker = false;
32 for (let i = 0; i < 60 && !sawMarker; i++) {
33 await page.waitForTimeout(250);
34 sawMarker = await page.locator('.squiggly-error').count() > 0;
35 }
36 check('LSP diagnostics live', sawMarker);
37 await page.screenshot({ path: out + '/live-ide.png' });
39 // the status bar shows the compile server (default: the hosted
40 // stan-wasm-wasi instance, reachable from any origin)
41 const statusText = (await page.locator('.mw-statusbar').innerText()).replace(/\u00a0/g, ' ');
42 check('server status item present', statusText.includes('Stan server:'));
44 console.log(errors.length ? 'page errors:\n ' + errors.slice(0, 8).join('\n ') : 'no page errors');
45} finally {
46 await browser.close();
47}