Skip to content

Commit 72515f9

Browse files
committed
test: tweak
1 parent 22f0606 commit 72515f9

File tree

2 files changed

+64
-59
lines changed

2 files changed

+64
-59
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
})

packages/plugin-rsc/e2e/starter.test.ts

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { expect, test } from '@playwright/test'
22
import { setupInlineFixture, type Fixture, useFixture } from './fixture'
33
import {
4-
expectNoPageError,
54
expectNoReload,
65
testNoJs,
76
waitForHydration as waitForHydration_,
@@ -204,64 +203,6 @@ test.describe(() => {
204203
})
205204
})
206205

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-
265206
function defineTest(f: Fixture, variant?: 'no-ssr') {
266207
const waitForHydration: typeof waitForHydration_ = (page) =>
267208
waitForHydration_(page, variant === 'no-ssr' ? '#root' : 'body')

0 commit comments

Comments
 (0)