boot-init now sets data-sx-ready on <html> and dispatches an sx:ready CustomEvent after all islands are hydrated. Playwright tests use this instead of networkidle + hard-coded sleeps (50+ seconds eliminated). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
23 lines
737 B
JavaScript
23 lines
737 B
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);
|
|
}
|
|
|
|
module.exports = { BASE_URL, waitForSxReady, loadPage };
|