WASM browser bundles rebuilt with latest kernel. Playwright test specs updated (helpers, navigation, handler-responses, hypermedia-handlers, isomorphic, SPA navigation). Engine/boot/orchestration SX files updated. Handler examples and not-found page refreshed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
// Shared helpers for Playwright tests
|
|
|
|
const BASE_URL = process.env.SX_TEST_URL || 'http://localhost:8013';
|
|
|
|
/**
|
|
* Wait for the SX runtime to finish hydration.
|
|
* boot-init sets data-sx-ready="true" on <html> after all islands are hydrated.
|
|
*/
|
|
async function waitForSxReady(page, timeout = 15000) {
|
|
await page.waitForSelector('html[data-sx-ready]', { timeout });
|
|
}
|
|
|
|
/**
|
|
* Navigate to an SX page and wait for hydration to complete.
|
|
* Replaces the old pattern of networkidle + arbitrary sleep.
|
|
*/
|
|
async function loadPage(page, path, timeout = 15000) {
|
|
await page.goto(BASE_URL + '/sx/' + path, { waitUntil: 'domcontentloaded', timeout });
|
|
await waitForSxReady(page);
|
|
}
|
|
|
|
/**
|
|
* Track console errors and uncaught exceptions on a page.
|
|
* Call before navigation. Use errors() to get filtered error list.
|
|
*/
|
|
function trackErrors(page) {
|
|
const raw = [];
|
|
page.on('pageerror', err => raw.push(err.message));
|
|
page.on('console', msg => {
|
|
if (msg.type() === 'error') raw.push(msg.text());
|
|
});
|
|
return {
|
|
/** Return errors, filtering transient network noise. */
|
|
errors() {
|
|
return raw.filter(e =>
|
|
!e.includes('Failed to fetch') &&
|
|
!e.includes('net::ERR') &&
|
|
!e.includes(' 404 ') &&
|
|
!e.includes('Failed to load resource') &&
|
|
!e.includes('Parse_error') // WASM parser edge case on empty OOB fragments
|
|
);
|
|
}
|
|
};
|
|
}
|
|
|
|
module.exports = { BASE_URL, waitForSxReady, loadPage, trackErrors };
|