mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
These tests have started failing in deploy mode in environments outside of the new Vercel adapter. Shell related behavior is changing as part of the new `partialFallbacks` flag and will not be backported to the old CLI, so this gates the test to ensure it runs in the right deployment environment.
88 lines
2.2 KiB
TypeScript
88 lines
2.2 KiB
TypeScript
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,
|
|
})
|
|
})
|
|
})
|
|
})
|
|
})
|