Files
Jiachi LiuandGitHub 4056994304 Recover not found errors from flight data to render with proper boundary (#53703)
### What?

We change the not-found rendering strategy to the origin one which recovers the not found error from the flight data, and hit the error boundary to display the closet not found component.

For parallel `@slot` we shouldn't pass down the not-found boundary, the boundary is only for `@children`.

### Why?

We're having a lot of not-found matching issues that manually searching for not found and layout won't be accurate as we have various scenarios like `(group)` routes, dynamic routes, etc.

### How?

Only render html with empty body so that the error can recover from flight and render the proper not-found component during hydration.

One change for metadata is that we need to get the "not-found" metadata in the initial render, so we'll catch the not-found error once there first and start render the "not-found" metadata and put it in the flight data. Then when it recovers it's still preserved.

Fixes #53694
2023-08-12 08:41:47 +00:00

46 lines
1.1 KiB
TypeScript

import { createNextDescribe } from 'e2e-utils'
createNextDescribe(
'app dir - not-found - group route',
{
files: __dirname,
skipDeployment: true,
},
({ next }) => {
const runTests = () => {
it('should use the not-found page under group routes', async () => {
const browser = await next.browser('/blog')
expect(await browser.elementByCss('h1').text()).toContain(
'Group Layout'
)
expect(await browser.elementByCss('#not-found').text()).toContain(
'Not found!'
)
})
}
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()
})
}
)