Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions packages/plugin-rsc/e2e/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import { expectNoReload, testNoJs, waitForHydration } from './helper'

// TODO: parallel?
// TODO: all tests don't need to be tested in all variants?

test.describe('dev-default', () => {
const f = useFixture({ root: 'examples/basic', mode: 'dev' })
Expand Down Expand Up @@ -429,7 +430,7 @@
`/* color: rgb(0, 165, 255); */`,
),
)
await expect(page.locator('.test-style-server')).toHaveCSS(

Check failure on line 433 in packages/plugin-rsc/e2e/basic.test.ts

View workflow job for this annotation

GitHub Actions / test-rsc (ubuntu-latest / chromium)

[chromium] › e2e/basic.test.ts:416:5 › dev-isolated › css hmr server

1) [chromium] › e2e/basic.test.ts:416:5 › dev-isolated › css hmr server ────────────────────────── Error: Timed out 5000ms waiting for expect(locator).toHaveCSS(expected) Locator: locator('.test-style-server') Expected string: "rgb(0, 0, 0)" Received string: "rgb(0, 165, 255)" Call log: - Expect "toHaveCSS" with timeout 5000ms - waiting for locator('.test-style-server') 9 × locator resolved to <div class="test-style-server">test-style-server</div> - unexpected value "rgb(0, 165, 255)" 431 | ), 432 | ) > 433 | await expect(page.locator('.test-style-server')).toHaveCSS( | ^ 434 | 'color', 435 | 'rgb(0, 0, 0)', 436 | ) at /home/runner/work/vite-plugin-react/vite-plugin-react/packages/plugin-rsc/e2e/basic.test.ts:433:56
'color',
'rgb(0, 0, 0)',
)
Expand Down Expand Up @@ -627,7 +628,7 @@
const res = await page.request.get(f.url('/__test_restart'))
expect(await res.text()).toBe('ok')
await new Promise((r) => setTimeout(r, 100))
await page.goto(f.url('./'))

Check failure on line 631 in packages/plugin-rsc/e2e/basic.test.ts

View workflow job for this annotation

GitHub Actions / test-rsc (macos-latest / chromium)

[chromium] › e2e/basic.test.ts:627:5 › dev-isolated › no FOUC after server restart @nojs

2) [chromium] › e2e/basic.test.ts:627:5 › dev-isolated › no FOUC after server restart @nojs ────── Error: page.goto: net::ERR_EMPTY_RESPONSE at http://localhost:5173/ Call log: - navigating to "http://localhost:5173/", waiting until "load" 629 | expect(await res.text()).toBe('ok') 630 | await new Promise((r) => setTimeout(r, 100)) > 631 | await page.goto(f.url('./')) | ^ 632 | await testCss(page) 633 | await testTailwind(page) 634 | }) at /Users/runner/work/vite-plugin-react/vite-plugin-react/packages/plugin-rsc/e2e/basic.test.ts:631:18

Check failure on line 631 in packages/plugin-rsc/e2e/basic.test.ts

View workflow job for this annotation

GitHub Actions / test-rsc (macos-latest / chromium)

[chromium] › e2e/basic.test.ts:627:5 › dev-default › no FOUC after server restart @nojs

1) [chromium] › e2e/basic.test.ts:627:5 › dev-default › no FOUC after server restart @nojs ─────── Error: page.goto: net::ERR_CONNECTION_REFUSED at http://localhost:5174/ Call log: - navigating to "http://localhost:5174/", waiting until "load" 629 | expect(await res.text()).toBe('ok') 630 | await new Promise((r) => setTimeout(r, 100)) > 631 | await page.goto(f.url('./')) | ^ 632 | await testCss(page) 633 | await testTailwind(page) 634 | }) at /Users/runner/work/vite-plugin-react/vite-plugin-react/packages/plugin-rsc/e2e/basic.test.ts:631:18

Check failure on line 631 in packages/plugin-rsc/e2e/basic.test.ts

View workflow job for this annotation

GitHub Actions / test-rsc (macos-latest / webkit)

[webkit] › e2e/basic.test.ts:627:5 › dev-default › no FOUC after server restart @nojs

1) [webkit] › e2e/basic.test.ts:627:5 › dev-default › no FOUC after server restart @nojs ───────── Error: page.goto: Could not connect to the server. Call log: - navigating to "http://localhost:5173/", waiting until "load" 629 | expect(await res.text()).toBe('ok') 630 | await new Promise((r) => setTimeout(r, 100)) > 631 | await page.goto(f.url('./')) | ^ 632 | await testCss(page) 633 | await testTailwind(page) 634 | }) at /Users/runner/work/vite-plugin-react/vite-plugin-react/packages/plugin-rsc/e2e/basic.test.ts:631:18
await testCss(page)
await testTailwind(page)
})
Expand Down Expand Up @@ -928,4 +929,27 @@
'(actionCount: 5, innerFnCount: 3)',
)
})

test('hydration mismatch', async ({ page }) => {
const errors: Error[] = []
page.on('pageerror', (error) => {
errors.push(error)
})
await page.goto(f.url('/?test-hydration-mismatch'))
await waitForHydration(page)
expect(errors).toMatchObject([
{
message: expect.stringContaining(
f.mode === 'dev'
? `Hydration failed because the server rendered HTML didn't match the client.`
: `Minified React error #418`,
),
},
])

errors.length = 0
await page.goto(f.url())
await waitForHydration(page)
expect(errors).toEqual([])
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use client'

export function Mismatch() {
const value = typeof window !== 'undefined' ? 'browser' : 'ssr'
return <>[{value}]</>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Mismatch } from './client'

export function TestHydrationMismatch(props: { url: URL }) {
const show = props.url.searchParams.has('test-hydration-mismatch')
return (
<div>
<span>test-hydration-mismatch</span>{' '}
{show ? (
<a href="?">hide</a>
) : (
<a href="?test-hydration-mismatch">show</a>
)}{' '}
{show && <Mismatch />}
</div>
)
}
2 changes: 2 additions & 0 deletions packages/plugin-rsc/examples/basic/src/routes/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { TestTailwindClient } from './tailwind/client'
import { TestTailwindServer } from './tailwind/server'
import { TestTemporaryReference } from './temporary-reference/client'
import { TestUseCache } from './use-cache/server'
import { TestHydrationMismatch } from './hydration-mismatch/server'

export function Root(props: { url: URL }) {
return (
Expand All @@ -47,6 +48,7 @@ export function Root(props: { url: URL }) {
<TestCssClientNoSsr url={props.url} />
<TestTailwindClient />
<TestTailwindServer />
<TestHydrationMismatch url={props.url} />
<TestHmrClientDep />
<TestTemporaryReference />
<TestServerActionError />
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-rsc/examples/basic/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ input {
}

a {
@apply text-gray-500 underline hover:text-gray-700;
@apply text-gray-500 underline hover:text-gray-700 cursor-pointer;
}
3 changes: 1 addition & 2 deletions packages/plugin-rsc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
"tsc": "tsc -b ./tsconfig.json ./e2e/tsconfig.json ./examples/*/tsconfig.json",
"tsc-dev": "pnpm tsc --watch --preserveWatchOutput",
"dev": "tsdown --sourcemap --watch src",
"build": "tsdown",
"prepack": "tsdown --clean"
"build": "tsdown"
},
"dependencies": {
"@mjackson/node-fetch-server": "^0.6.1",
Expand Down
Loading