Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/next/build/webpack/loaders/next-app-loader.ts
Expand Up @@ -8,7 +8,7 @@ export const FILE_TYPES = {
template: 'template',
error: 'error',
loading: 'loading',
'404': '404',
'not-found': 'not-found',
} as const

// TODO-APP: check if this can be narrowed.
Expand Down Expand Up @@ -92,7 +92,7 @@ async function createTreeCodeFromPath({
file === FILE_TYPES.layout
? `layoutOrPagePath: '${filePath}',`
: ''
}${file}: () => require(${JSON.stringify(filePath)}),`
}'${file}': () => require(${JSON.stringify(filePath)}),`
})
.join('\n')}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/next/server/app-render.tsx
Expand Up @@ -822,7 +822,7 @@ export async function renderToHTMLOrFlight(
error,
loading,
page,
'404': notFound,
'not-found': notFound,
},
],
parentParams,
Expand Down
3 changes: 0 additions & 3 deletions test/e2e/app-dir/app/app/not-found/404.js

This file was deleted.

3 changes: 3 additions & 0 deletions test/e2e/app-dir/app/app/not-found/not-found.js
@@ -0,0 +1,3 @@
export default function NotFound() {
return <h1 id="not-found-component">Not Found!</h1>
}
33 changes: 18 additions & 15 deletions test/e2e/app-dir/index.test.ts
Expand Up @@ -1475,31 +1475,34 @@ describe('app dir', () => {
})
})

describe('404', () => {
it.skip('should trigger 404 in a server component', async () => {
describe('not-found', () => {
it.skip('should trigger not-found in a server component', async () => {
const browser = await webdriver(next.url, '/not-found/servercomponent')

expect(
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')
expect(
await browser.waitForElementByCss('#not-found-component').text()
).toBe('404!')
})
;(isDev ? it.skip : it)('should trigger 404 client-side', async () => {
const browser = await webdriver(next.url, '/not-found/client-side')
await browser
.elementByCss('button')
.click()
.waitForElementByCss('#not-found-component')
expect(await browser.elementByCss('#not-found-component').text()).toBe(
'404!'
)
).toBe('Not Found!')
})
;(isDev ? it.skip : it)(
'should trigger not-found client-side',
async () => {
const browser = await webdriver(next.url, '/not-found/client-side')
await browser
.elementByCss('button')
.click()
.waitForElementByCss('#not-found-component')
expect(
await browser.elementByCss('#not-found-component').text()
).toBe('Not Found!')
}
)
})

describe('redirect', () => {
Expand Down