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 // 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('fit.sample opens as form', await page.locator('.sample-editor h2', { hasText: 'fit.sample' }).count() === 1);
24 check('form: stan file selected', await page.locator('.sample-editor select').first().inputValue() === 'linear.stan');
26 // Stan LSP diagnostics on the live bundle
27 await page.locator('.mw-explorer-item-label').filter({ hasText: /^linear\.stan$/ }).click();
28 await page.waitForTimeout(3000);
29 await page.locator('.view-lines').first().click();
30 await page.keyboard.press('Control+End');
31 await page.keyboard.type('\nbroken');
32 let sawMarker = false;
33 for (let i = 0; i < 60 && !sawMarker; i++) {
34 await page.waitForTimeout(250);
35 sawMarker = await page.locator('.squiggly-error').count() > 0;
36 }
37 check('LSP diagnostics live', sawMarker);
38 await page.screenshot({ path: out + '/live-ide.png' });
40 // the status bar should show the compile server as offline (localhost
41 // default doesn't apply to the Pages origin)
42 const statusText = (await page.locator('.mw-statusbar').innerText()).replace(/\u00a0/g, ' ');
43 check('server status item present', statusText.includes('Stan server:'));
45 console.log(errors.length ? 'page errors:\n ' + errors.slice(0, 8).join('\n ') : 'no page errors');
46} finally {
47 await browser.close();
48}