forge
Explore
Log in

Don't you dare go Hollow

forge

Clone
★ 0

0 watching0 forksRustAGPL-3.07.1 MiB490f099Tahinli7 hours ago322 commits

smoke.mjs34 lines, 1.5 KiBHistoryRawDownload
1// Clicks through a running forge with nav.js live and fails on any page error, or when a link or a
2// form button does nothing. Catches what the HTTP-only e2e tests cannot: a broken nav.js.
3// Usage: bun smoke.mjs [base-url] (default http://127.0.0.1:17670)
4import { chromium } from 'playwright-core';
5
6const base = process.argv[2] || 'http://127.0.0.1:17670';
7const errors = [];
8const fail = (msg) => { console.error('[smoke] FAIL ' + msg); process.exitCode = 1; };
9
10const browser = await chromium.launch({ headless: true });
11try {
12 const page = await browser.newPage();
13 page.on('pageerror', (e) => errors.push(e.message));
14
15 await page.goto(base + '/', { waitUntil: 'networkidle' });
16 if (!(await page.evaluate(() => document.documentElement.classList.contains('js')))) {
17 fail('nav.js did not run (no html.js)');
18 }
19
20 // A form button: the theme toggle posts and the page comes back in the other theme.
21 const before = await page.evaluate(() => document.documentElement.dataset.theme);
22 await page.click('.theme-form button');
23 await page.waitForFunction((t) => document.documentElement.dataset.theme !== t, before, { timeout: 5000 })
24 .catch(() => fail('theme button did nothing'));
25
26 // A link: a soft navigation lands on the explore page.
27 await page.click('a.topbar-link[href="/explore"]');
28 await page.waitForURL(base + '/explore', { timeout: 5000 }).catch(() => fail('explore link did nothing'));
29} finally {
30 await browser.close();
31}
32
33for (const e of errors) { fail('page error: ' + e); }
34if (!process.exitCode) { console.log('[smoke] ok'); }