-
Notifications
You must be signed in to change notification settings - Fork 28.2k
/
Copy pathdynamic-io.server-action.test.ts
56 lines (47 loc) · 1.98 KB
/
dynamic-io.server-action.test.ts
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
52
53
54
55
56
import { nextTestSetup } from 'e2e-utils'
import { assertNoRedbox, retry } from 'next-test-utils'
describe('dynamic-io', () => {
const { next, isNextDev } = nextTestSetup({
files: __dirname,
})
it('should not fail decoding server action arguments', async () => {
const browser = await next.browser('/server-action')
expect(await browser.elementByCss('p').text()).toBe('initial')
await browser.elementByCss('button').click()
await retry(async () => {
expect(await browser.elementByCss('p').text()).toBe('result')
})
})
it('should not have dynamic IO errors when encoding bound args for inline server actions', async () => {
const browser = await next.browser('/server-action-inline')
expect(await browser.elementByCss('p').text()).toBe('initial')
await browser.elementByCss('button').click()
await retry(async () => {
expect(await browser.elementByCss('p').text()).toBe('result')
})
const isExperimentalReact = Boolean(process.env.__NEXT_EXPERIMENTAL_PPR)
if (isExperimentalReact && isNextDev) {
// TODO(react-time-info): Remove this branch for experimental React in dev mode when the
// issue is resolved where the inclusion of server timings in the RSC
// payload makes the serialized bound args not suitable to be used as a
// cache key.
expect(next.cliOutput).toMatch('Error: Route "/server-action-inline"')
} else {
expect(next.cliOutput).not.toMatch('Error: Route "/server-action-inline"')
}
if (isNextDev) {
await assertNoRedbox(browser)
}
})
/* eslint-enable jest/no-standalone-expect */
it('should prerender pages with inline server actions', async () => {
let $ = await next.render$('/server-action-inline', {})
if (isNextDev) {
expect($('#layout').text()).toBe('at runtime')
expect($('#page').text()).toBe('at runtime')
} else {
expect($('#layout').text()).toBe('at buildtime')
expect($('#page').text()).toBe('at buildtime')
}
})
})