|
1 | 1 | import { expect, test } from '@playwright/test' |
2 | 2 | import { setupInlineFixture, type Fixture, useFixture } from './fixture' |
3 | 3 | import { |
| 4 | + expectNoPageError, |
4 | 5 | expectNoReload, |
5 | 6 | testNoJs, |
6 | 7 | waitForHydration as waitForHydration_, |
@@ -203,6 +204,64 @@ test.describe(() => { |
203 | 204 | }) |
204 | 205 | }) |
205 | 206 |
|
| 207 | +test.describe(() => { |
| 208 | + const root = 'examples/e2e/temp/ssr-thenable' |
| 209 | + |
| 210 | + test.beforeAll(async () => { |
| 211 | + await setupInlineFixture({ |
| 212 | + src: 'examples/starter', |
| 213 | + dest: root, |
| 214 | + files: { |
| 215 | + 'src/root.tsx': /* tsx */ ` |
| 216 | + import { TestClientUse } from './client.tsx' |
| 217 | +
|
| 218 | + export function Root() { |
| 219 | + return ( |
| 220 | + <html lang="en"> |
| 221 | + <head> |
| 222 | + <meta charSet="UTF-8" /> |
| 223 | + </head> |
| 224 | + <body> |
| 225 | + <TestClientUse /> |
| 226 | + </body> |
| 227 | + </html> |
| 228 | + ) |
| 229 | + } |
| 230 | + `, |
| 231 | + 'src/client.tsx': /* tsx */ ` |
| 232 | + "use client"; |
| 233 | + import React from 'react' |
| 234 | +
|
| 235 | + const promise = Promise.resolve('ok') |
| 236 | +
|
| 237 | + export function TestClientUse() { |
| 238 | + const value = React.use(promise) |
| 239 | + return <span data-testid="client-use">{value}</span> |
| 240 | + } |
| 241 | + `, |
| 242 | + }, |
| 243 | + }) |
| 244 | + }) |
| 245 | + |
| 246 | + function defineSsrThenableTest(f: Fixture) { |
| 247 | + test('ssr-thenable', async ({ page }) => { |
| 248 | + using _ = expectNoPageError(page) |
| 249 | + await page.goto(f.url()) |
| 250 | + await waitForHydration_(page) |
| 251 | + }) |
| 252 | + } |
| 253 | + |
| 254 | + test.describe('dev', () => { |
| 255 | + const f = useFixture({ root, mode: 'dev' }) |
| 256 | + defineSsrThenableTest(f) |
| 257 | + }) |
| 258 | + |
| 259 | + test.describe('build', () => { |
| 260 | + const f = useFixture({ root, mode: 'build' }) |
| 261 | + defineSsrThenableTest(f) |
| 262 | + }) |
| 263 | +}) |
| 264 | + |
206 | 265 | function defineTest(f: Fixture, variant?: 'no-ssr') { |
207 | 266 | const waitForHydration: typeof waitForHydration_ = (page) => |
208 | 267 | waitForHydration_(page, variant === 'no-ssr' ? '#root' : 'body') |
|
0 commit comments