Files
Jiachi LiuandGitHub 9035f14dda Fix not-found rendering in production with edge (#53687)
Edge runtime doesn't have `/404` entry points as not-found, if server hits 404 it's hitting `/_not-found` entry point of edge bundles unlike nodejs server rendering.

In app-render it needs the information that when `pathname` (or can call `pagePath`) is `/404` it can render the `not-found.js` components properly

Separate the not-found test suite into 2 parts, a basic case testing all urls with `not-found.js` boundary, and another conflict route case with `not-found.js` with `not-found/` route at the same time

Fixes #53652
Fixes #53210
2023-08-07 20:05:22 +00:00

50 lines
1.3 KiB
TypeScript

import { createNextDescribe } from 'e2e-utils'
createNextDescribe(
'app dir - not-found - conflict route',
{
files: __dirname,
skipDeployment: true,
},
({ next }) => {
const runTests = () => {
it('should use the not-found page for non-matching routes', async () => {
const browser = await next.browser('/random-content')
expect(await browser.elementByCss('h1').text()).toContain(
'This Is The Not Found Page'
)
// should contain root layout content
expect(await browser.elementByCss('#layout-nav').text()).toBe('Navbar')
})
it('should allow to have a valid /not-found route', async () => {
const html = await next.render('/not-found')
expect(html).toContain("I'm still a valid page")
})
}
describe('with default runtime', () => {
runTests()
})
describe('with runtime = edge', () => {
let originalLayout = ''
beforeAll(async () => {
await next.stop()
originalLayout = await next.readFile('app/layout.js')
await next.patchFile(
'app/layout.js',
`export const runtime = 'edge'\n${originalLayout}`
)
await next.start()
})
afterAll(async () => {
await next.patchFile('app/layout.js', originalLayout)
})
runTests()
})
}
)