Add sx:ready hydration signal, eliminate test sleeps

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>
This commit is contained in:
2026-03-30 12:47:52 +00:00
parent fffb5ab0b5
commit e14947cedc
12 changed files with 131 additions and 137 deletions

View File

@@ -0,0 +1,22 @@
// 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 };