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

@@ -1,23 +1,13 @@
// @ts-check
/**
* Geography demos — comprehensive page load + interaction tests.
* Each test does a fresh page.goto() for isolation, but cached server
* responses (pre-warmed) keep these fast (~0.5s each vs ~2s uncached).
*/
const { test, expect } = require('playwright/test');
const BASE_URL = process.env.SX_TEST_URL || 'http://localhost:8013';
const { loadPage } = require('./helpers');
// ---------------------------------------------------------------------------
// Helpers
// ---------------------------------------------------------------------------
async function loadPage(page, path) {
await page.goto(BASE_URL + '/sx/' + path, { waitUntil: 'networkidle', timeout: 15000 });
await page.waitForTimeout(500);
const root = page.locator('#sx-root');
await expect(root).toBeVisible({ timeout: 10000 });
return root;
}
async function expectIsland(page, pattern) {
const island = page.locator(`[data-sx-island*="${pattern}"]`);
await expect(island).toBeVisible({ timeout: 8000 });
@@ -44,7 +34,8 @@ test.describe('Geography sections', () => {
for (const [path, text] of sections) {
test(`${path} loads`, async ({ page }) => {
const root = await loadPage(page, path);
await loadPage(page, path);
const root = page.locator('#sx-root');
expect(await root.textContent()).toContain(text);
});
}
@@ -153,7 +144,6 @@ test('counter → temperature → counter: all stay reactive', async ({ page })
const tempLink = page.locator('a[href*="temperature"]').first();
if (await tempLink.count() > 0) {
await tempLink.click();
await page.waitForTimeout(2000);
el = await expectIsland(page, 'temperature');
buttons = el.locator('button');
if (await buttons.count() >= 2) {
@@ -168,7 +158,6 @@ test('counter → temperature → counter: all stay reactive', async ({ page })
const counterLink = page.locator('a[href*="counter"]').first();
if (await counterLink.count() > 0) {
await counterLink.click();
await page.waitForTimeout(2000);
el = await expectIsland(page, 'counter');
buttons = el.locator('button');
before = await el.textContent();