Fix streaming: resolve scripts inside </body>, live server tests
The shell HTML included closing </body></html> tags. Resolve script chunks arrived AFTER the document end — browser ignored them (ERR_INCOMPLETE_CHUNKED_ENCODING). Now strips </body></html> from shell, sends resolve scripts inside the body, closes document last. Added live server Playwright tests that hit the actual streaming endpoint and verify suspense slots resolve with content. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -386,3 +386,46 @@ test.describe('Streaming sandbox', () => {
|
||||
await expect(page.locator('[data-suspense="stream-slow"]')).toContainText('~5s');
|
||||
});
|
||||
});
|
||||
|
||||
// =========================================================================
|
||||
// Live server tests — verify the actual chunked response works end-to-end
|
||||
// =========================================================================
|
||||
const BASE_URL = process.env.SX_TEST_URL || 'http://localhost:8013';
|
||||
|
||||
test.describe('Streaming live server', () => {
|
||||
test.describe.configure({ timeout: 30000 });
|
||||
|
||||
test('streaming page resolves suspense slots from server', async ({ page }) => {
|
||||
// Load the streaming page from the actual server
|
||||
await page.goto(BASE_URL + '/sx/(geography.(isomorphism.streaming))', {
|
||||
waitUntil: 'networkidle',
|
||||
timeout: 20000,
|
||||
});
|
||||
|
||||
// Should have 3 suspense slots
|
||||
await expect(page.locator('[data-suspense]')).toHaveCount(3);
|
||||
|
||||
// All 3 slots should have resolved content (not empty, not just skeletons)
|
||||
await expect(page.locator('[data-suspense="stream-fast"]')).toContainText('Fast source', { timeout: 15000 });
|
||||
await expect(page.locator('[data-suspense="stream-medium"]')).toContainText('Medium source', { timeout: 15000 });
|
||||
await expect(page.locator('[data-suspense="stream-slow"]')).toContainText('Slow source', { timeout: 15000 });
|
||||
});
|
||||
|
||||
test('no chunked encoding errors in console', async ({ page }) => {
|
||||
const errors = [];
|
||||
page.on('pageerror', e => errors.push(e.message));
|
||||
page.on('console', msg => {
|
||||
if (msg.type() === 'error') errors.push(msg.text());
|
||||
});
|
||||
|
||||
await page.goto(BASE_URL + '/sx/(geography.(isomorphism.streaming))', {
|
||||
waitUntil: 'networkidle',
|
||||
timeout: 20000,
|
||||
});
|
||||
|
||||
// Filter for chunked encoding errors specifically
|
||||
const chunkErrors = errors.filter(e =>
|
||||
e.includes('CHUNKED') || e.includes('INCOMPLETE') || e.includes('ERR_EMPTY'));
|
||||
expect(chunkErrors).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user