Files
Jiachi LiuandGitHub 6bc23cd2bd Fix group routes custom root not-found (#54931)
For group routes, as their custom layout show up at the 1st level of the loader tree, so previously we tried to add the default not-found to that layer, but if they have custom root not-found, we should use that as the root not-found componeny, instead of using default not-found component to form the 404 page

Closes NEXT-1588

Fixes #51075
Fixes #54892
2023-09-03 20:15:24 +00:00

30 lines
992 B
TypeScript

import { createNextDescribe } from 'e2e-utils'
createNextDescribe(
'app dir - group routes with root not-found',
{
files: __dirname,
skipDeployment: true,
},
({ next }) => {
it('should render default 404 with root layout for non-existent page', async () => {
const browser = await next.browser('/non-existent')
expect(await browser.elementByCss('p').text()).toBe(
'Not found placeholder'
)
expect(await browser.elementByCss('h1').text()).toBe('Root layout')
})
it('should render root not found for group routes if hit 404', async () => {
const browser = await next.browser('/group-dynamic/123')
expect(await browser.elementByCss('p').text()).toBe('group-dynamic [id]')
await browser.loadPage(next.url + '/group-dynamic/404')
expect(await browser.elementByCss('p').text()).toBe(
'Not found placeholder'
)
expect(await browser.elementByCss('h1').text()).toBe('Root layout')
})
}
)