Unverified Commit 833a67ff authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Rename 404 -> not-found for new router (#40941)

As discussed with @sebmarkbage, the handling is more about showing a not found component than it is about a specific status code as these can come in late with streaming.



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
parent b508fef2
...@@ -8,7 +8,7 @@ export const FILE_TYPES = { ...@@ -8,7 +8,7 @@ export const FILE_TYPES = {
template: 'template', template: 'template',
error: 'error', error: 'error',
loading: 'loading', loading: 'loading',
'404': '404', 'not-found': 'not-found',
} as const } as const
// TODO-APP: check if this can be narrowed. // TODO-APP: check if this can be narrowed.
...@@ -92,7 +92,7 @@ async function createTreeCodeFromPath({ ...@@ -92,7 +92,7 @@ async function createTreeCodeFromPath({
file === FILE_TYPES.layout file === FILE_TYPES.layout
? `layoutOrPagePath: '${filePath}',` ? `layoutOrPagePath: '${filePath}',`
: '' : ''
}${file}: () => require(${JSON.stringify(filePath)}),` }'${file}': () => require(${JSON.stringify(filePath)}),`
}) })
.join('\n')} .join('\n')}
} }
......
...@@ -822,7 +822,7 @@ export async function renderToHTMLOrFlight( ...@@ -822,7 +822,7 @@ export async function renderToHTMLOrFlight(
error, error,
loading, loading,
page, page,
'404': notFound, 'not-found': notFound,
}, },
], ],
parentParams, parentParams,
......
export default function NotFound() { export default function NotFound() {
return <h1 id="not-found-component">404!</h1> return <h1 id="not-found-component">Not Found!</h1>
} }
...@@ -1475,32 +1475,35 @@ describe('app dir', () => { ...@@ -1475,32 +1475,35 @@ describe('app dir', () => {
}) })
}) })
describe('404', () => { describe('not-found', () => {
it.skip('should trigger 404 in a server component', async () => { it.skip('should trigger not-found in a server component', async () => {
const browser = await webdriver(next.url, '/not-found/servercomponent') const browser = await webdriver(next.url, '/not-found/servercomponent')
expect( expect(
await browser.waitForElementByCss('#not-found-component').text() await browser.waitForElementByCss('#not-found-component').text()
).toBe('404!') ).toBe('Not Found!')
}) })
it.skip('should trigger 404 in a client component', async () => { it.skip('should trigger not-found in a client component', async () => {
const browser = await webdriver(next.url, '/not-found/clientcomponent') const browser = await webdriver(next.url, '/not-found/clientcomponent')
expect( expect(
await browser.waitForElementByCss('#not-found-component').text() await browser.waitForElementByCss('#not-found-component').text()
).toBe('404!') ).toBe('Not Found!')
}) })
;(isDev ? it.skip : it)('should trigger 404 client-side', async () => { ;(isDev ? it.skip : it)(
'should trigger not-found client-side',
async () => {
const browser = await webdriver(next.url, '/not-found/client-side') const browser = await webdriver(next.url, '/not-found/client-side')
await browser await browser
.elementByCss('button') .elementByCss('button')
.click() .click()
.waitForElementByCss('#not-found-component') .waitForElementByCss('#not-found-component')
expect(await browser.elementByCss('#not-found-component').text()).toBe( expect(
'404!' await browser.elementByCss('#not-found-component').text()
).toBe('Not Found!')
}
) )
}) })
})
describe('redirect', () => { describe('redirect', () => {
describe('components', () => { describe('components', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment