-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathhydration-capped-assets.spec.ts
More file actions
51 lines (45 loc) · 1.77 KB
/
Copy pathhydration-capped-assets.spec.ts
File metadata and controls
51 lines (45 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { expect } from '@playwright/test'
import { test } from '@tanstack/router-e2e-utils'
import { isPrerender } from './utils/isPrerender'
import { isSpaMode } from './utils/isSpaMode'
/**
* On a direct SSR hard load, the server can intentionally cap the
* committed match list at a parent notFound/error boundary. Hydration should not
* project head/scripts for the child route that was omitted from the server
* match list, because those assets can be added with missing or stale loader
* data before the follow-up client load enforces the same boundary.
*
* This Playwright repro uses the real React Start app, a real browser page load,
* the real SSR response, and normal client hydration. The parent route throws
* notFound from beforeLoad, while its child route defines a meta tag and inline
* script; neither child asset should appear after loading the capped parent
* boundary response.
*/
test.use({
whitelistErrors: [
'Failed to load resource: the server responded with a status of 404',
],
})
test.describe('SSR hydration capped route assets', () => {
test.skip(isSpaMode || isPrerender, 'SSR hydration repro only')
test('does not project assets for a child route omitted by the server boundary', async ({
page,
}) => {
await page.goto('/hydration-capped-assets/child')
await page.waitForLoadState('networkidle')
await expect(
page.getByTestId('capped-assets-parent-not-found'),
).toBeInViewport()
await expect(
page.getByTestId('capped-assets-child-component'),
).not.toBeInViewport()
await expect(
page.locator('meta[name="capped-assets-child-head"]'),
).toHaveCount(0)
expect(
await page.evaluate(() =>
Boolean((window as any).__CAPPED_ASSETS_CHILD_SCRIPT),
),
).toBe(false)
})
})