-
Notifications
You must be signed in to change notification settings - Fork 30.7k
Expand file tree
/
Copy pathsub-shell-generation.test.ts
More file actions
87 lines (80 loc) · 2.22 KB
/
sub-shell-generation.test.ts
File metadata and controls
87 lines (80 loc) · 2.22 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { nextTestSetup } from 'e2e-utils'
import * as cheerio from 'cheerio'
const isAdapterTest = Boolean(process.env.NEXT_ENABLE_ADAPTER)
describe('sub-shell-generation', () => {
const { next, isNextDev, isNextDeploy } = nextTestSetup({
files: __dirname,
// The latest changes to support this behavior on deployed infra are available in the adapter,
// and are not being backported to the CLI
skipDeployment: !isAdapterTest,
})
if (isNextDev) {
it.skip('skipping dev test', () => {})
return
}
describe('should serve the correct shell', () => {
describe.each([
[
'/[lang]/[slug]',
{
page: 'Page: (runtime)',
langLayout: 'Lang Layout: (runtime)',
rootLayout: 'Root Layout: (buildtime)',
},
['/es/1', '/es/2'],
true,
],
[
'/en/[slug]',
{
page: 'Page: (runtime)',
langLayout: 'Lang Layout: (buildtime)',
rootLayout: 'Root Layout: (buildtime)',
},
['/en/1', '/en/2'],
true,
],
[
'/fr/[slug]',
{
page: 'Page: (runtime)',
langLayout: 'Lang Layout: (buildtime)',
rootLayout: 'Root Layout: (buildtime)',
},
['/fr/2', '/fr/3'],
true,
],
[
'/fr/1',
{
page: 'Page: (buildtime)',
langLayout: 'Lang Layout: (buildtime)',
rootLayout: 'Root Layout: (buildtime)',
},
['/fr/1'],
false,
],
])('%s', (shell, { page, langLayout, rootLayout }, paths, isPostponed) => {
it.each(paths)('should serve the correct shell for %s', async (path) => {
const res = await next.fetch(path)
expect(res.status).toBe(200)
if (!isNextDeploy) {
expect(res.headers.get('x-nextjs-postponed')).toBe(
isPostponed ? '1' : null
)
}
const html = await res.text()
const $ = cheerio.load(html)
expect({
page: $('#page').text(),
langLayout: $('#lang-layout').text(),
rootLayout: $('#root-layout').text(),
}).toEqual({
page,
langLayout,
rootLayout,
})
})
})
})
})