|
| 1 | +import { test } from '@playwright/test' |
| 2 | +import { setupInlineFixture, type Fixture, useFixture } from './fixture' |
| 3 | +import { |
| 4 | + expectNoPageError, |
| 5 | + waitForHydration as waitForHydration_, |
| 6 | +} from './helper' |
| 7 | + |
| 8 | +test.describe(() => { |
| 9 | + const root = 'examples/e2e/temp/ssr-thenable' |
| 10 | + |
| 11 | + test.beforeAll(async () => { |
| 12 | + await setupInlineFixture({ |
| 13 | + src: 'examples/starter', |
| 14 | + dest: root, |
| 15 | + files: { |
| 16 | + 'src/root.tsx': /* tsx */ ` |
| 17 | + import { TestClientUse } from './client.tsx' |
| 18 | +
|
| 19 | + export function Root() { |
| 20 | + return ( |
| 21 | + <html lang="en"> |
| 22 | + <head> |
| 23 | + <meta charSet="UTF-8" /> |
| 24 | + </head> |
| 25 | + <body> |
| 26 | + <TestClientUse /> |
| 27 | + </body> |
| 28 | + </html> |
| 29 | + ) |
| 30 | + } |
| 31 | + `, |
| 32 | + 'src/client.tsx': /* tsx */ ` |
| 33 | + "use client"; |
| 34 | + import React from 'react' |
| 35 | +
|
| 36 | + const promise = Promise.resolve('ok') |
| 37 | +
|
| 38 | + export function TestClientUse() { |
| 39 | + const value = React.use(promise) |
| 40 | + return <span data-testid="client-use">{value}</span> |
| 41 | + } |
| 42 | + `, |
| 43 | + }, |
| 44 | + }) |
| 45 | + }) |
| 46 | + |
| 47 | + function defineSsrThenableTest(f: Fixture) { |
| 48 | + test('ssr-thenable', async ({ page }) => { |
| 49 | + using _ = expectNoPageError(page) |
| 50 | + await page.goto(f.url()) |
| 51 | + await waitForHydration_(page) |
| 52 | + }) |
| 53 | + } |
| 54 | + |
| 55 | + test.describe('dev', () => { |
| 56 | + const f = useFixture({ root, mode: 'dev' }) |
| 57 | + defineSsrThenableTest(f) |
| 58 | + }) |
| 59 | + |
| 60 | + test.describe('build', () => { |
| 61 | + const f = useFixture({ root, mode: 'build' }) |
| 62 | + defineSsrThenableTest(f) |
| 63 | + }) |
| 64 | +}) |
0 commit comments