concept-collection / numbl-web-ide
Test scripts: use explicit \u00a0 escape for monaco space normalization
Jeremy Magland <jmagland@flatironinstitute.org> committed commit dfd6ab5caaeb parent caef63a Browse files
2 changed files+16−2
scripts/live-check.mjsmodified+15−1View file
@@ -25,13 +25,27 @@ try {
2525 let ran = false;
2626 for (let i = 0; i < 60 && !ran; i++) {
2727 await page.waitForTimeout(500);
28- ran = ((await page.locator('.mw-output').innerText()).replace(/ /g, ' ')).includes('peak amplitude');
28+ ran = ((await page.locator('.mw-output').innerText()).replace(/\u00a0/g, ' ')).includes('peak amplitude');
2929 }
3030 check('run output streamed', ran);
3131 await page.waitForTimeout(2000);
3232 check('figure view appears', await page.locator('.mw-auxbar .mw-panel-tab', { hasText: 'Figure 1' }).count() === 1);
3333 await page.screenshot({ path: out + '/live-run.png' });
3434
35+ // mip: install + run the package demo
36+ await page.getByText('scripts', { exact: true }).click();
37+ await page.waitForTimeout(400);
38+ await page.getByText('mip_demo.m', { exact: true }).click();
39+ await page.waitForTimeout(600);
40+ await page.locator('.mw-tab-action[title="numbl"]').click();
41+ let mipRan = false;
42+ for (let i = 0; i < 180 && !mipRan; i++) {
43+ await page.waitForTimeout(500);
44+ mipRan = ((await page.locator('.mw-output').innerText()).replace(/\u00a0/g, ' ')).includes('points inside: 201 / 2000');
45+ }
46+ check('mip demo runs live', mipRan);
47+ await page.screenshot({ path: out + '/live-mip.png' });
48+
3549 console.log(errors.length ? 'page errors:\n ' + errors.slice(0, 8).join('\n ') : 'no page errors');
3650 } finally {
3751 await browser.close();
scripts/smoke.mjsmodified+1−1View file
@@ -16,7 +16,7 @@ page.on('pageerror', (e) => errors.push(e.message));
1616 page.on('console', (m) => { if (m.type() === 'error') errors.push(m.text()); });
1717 const check = (name, ok) => console.log(`${ok ? 'OK ' : 'FAIL'} ${name}`);
1818 // monaco renders spaces as U+00A0 — normalize before matching
19-const outputText = async () => (await page.locator('.mw-output').innerText()).replace(/ /g, ' ');
19+const outputText = async () => (await page.locator('.mw-output').innerText()).replace(/\u00a0/g, ' ');
2020 const waitForOutput = async (needle, timeout = 20000) => {
2121 const start = Date.now();
2222 while (Date.now() - start < timeout) {