// Clicks through a running forge with nav.js live and fails on any page error, or when a link or a // form button does nothing. Catches what the HTTP-only e2e tests cannot: a broken nav.js. // Usage: bun smoke.mjs [base-url] (default http://127.0.0.1:17670) import { chromium } from 'playwright-core'; const base = process.argv[2] || 'http://127.0.0.1:17670'; const errors = []; const fail = (msg) => { console.error('[smoke] FAIL ' + msg); process.exitCode = 1; }; const browser = await chromium.launch({ headless: true }); try { const page = await browser.newPage(); page.on('pageerror', (e) => errors.push(e.message)); await page.goto(base + '/', { waitUntil: 'networkidle' }); if (!(await page.evaluate(() => document.documentElement.classList.contains('js')))) { fail('nav.js did not run (no html.js)'); } // A form button: the theme toggle posts and the page comes back in the other theme. const before = await page.evaluate(() => document.documentElement.dataset.theme); await page.click('.theme-form button'); await page.waitForFunction((t) => document.documentElement.dataset.theme !== t, before, { timeout: 5000 }) .catch(() => fail('theme button did nothing')); // A link: a soft navigation lands on the explore page. await page.click('a.topbar-link[href="/explore"]'); await page.waitForURL(base + '/explore', { timeout: 5000 }).catch(() => fail('explore link did nothing')); } finally { await browser.close(); } for (const e of errors) { fail('page error: ' + e); } if (!process.exitCode) { console.log('[smoke] ok'); }