Unverified Commit 51ffc255 authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

[metadata] remove the duplicate metadata in the error boundary (#76791)

### What 

Those metadata were added into error boundaries but they're actually duplicated, we already have the actual metadata in the page and the metadata outlet can trigger the error boundary. The metadata element in the error boundary is not necessary.
parent 33553712
...@@ -411,7 +411,6 @@ async function createComponentTreeInternal({ ...@@ -411,7 +411,6 @@ async function createComponentTreeInternal({
const notFoundElement = NotFound ? ( const notFoundElement = NotFound ? (
<> <>
<NotFound /> <NotFound />
{metadata}
{notFoundStyles} {notFoundStyles}
</> </>
) : undefined ) : undefined
...@@ -419,7 +418,6 @@ async function createComponentTreeInternal({ ...@@ -419,7 +418,6 @@ async function createComponentTreeInternal({
const forbiddenElement = Forbidden ? ( const forbiddenElement = Forbidden ? (
<> <>
<Forbidden /> <Forbidden />
{metadata}
{forbiddenStyles} {forbiddenStyles}
</> </>
) : undefined ) : undefined
...@@ -427,7 +425,6 @@ async function createComponentTreeInternal({ ...@@ -427,7 +425,6 @@ async function createComponentTreeInternal({
const unauthorizedElement = Unauthorized ? ( const unauthorizedElement = Unauthorized ? (
<> <>
<Unauthorized /> <Unauthorized />
{metadata}
{unauthorizedStyles} {unauthorizedStyles}
</> </>
) : undefined ) : undefined
...@@ -858,7 +855,6 @@ async function createComponentTreeInternal({ ...@@ -858,7 +855,6 @@ async function createComponentTreeInternal({
{notFoundStyles} {notFoundStyles}
<NotFound /> <NotFound />
</SegmentComponent> </SegmentComponent>
{metadata}
</> </>
) : undefined ) : undefined
} }
......
...@@ -6,7 +6,7 @@ export default function Layout({ ...@@ -6,7 +6,7 @@ export default function Layout({
slot: React.ReactNode slot: React.ReactNode
}) { }) {
return ( return (
<html> <html lang="en" className="layout">
<body> <body>
{children} {children}
{slot} {slot}
...@@ -14,3 +14,7 @@ export default function Layout({ ...@@ -14,3 +14,7 @@ export default function Layout({
</html> </html>
) )
} }
export const metadata = {
title: 'layout title',
}
/** /**
* @type {import('next').NextConfig} * @type {import('next').NextConfig}
*/ */
const nextConfig = { const nextConfig = {}
pageExtensions: ['tsx', 'ts'],
}
module.exports = nextConfig module.exports = nextConfig
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
const isPPR = process.env.__NEXT_EXPERIMENTAL_PPR === 'true'
describe('parallel-routes-and-interception', () => { describe('parallel-routes-and-interception', () => {
const { next, skipped } = nextTestSetup({ const { next, isNextDev, skipped } = nextTestSetup({
files: __dirname, files: __dirname,
// TODO: remove after deployment handling is updated // TODO: remove after deployment handling is updated
skipDeployment: true, skipDeployment: true,
...@@ -21,5 +23,28 @@ describe('parallel-routes-and-interception', () => { ...@@ -21,5 +23,28 @@ describe('parallel-routes-and-interception', () => {
// we also check that the #children-slot id is not present // we also check that the #children-slot id is not present
expect(await browser.hasElementByCssSelector('#children-slot')).toBe(false) expect(await browser.hasElementByCssSelector('#children-slot')).toBe(false)
if (isPPR && !isNextDev) {
let $ = await next.render$('/')
expect($('title').text()).toBe('')
$ = await next.render$('/', null, {
headers: {
'User-Agent': 'Discordbot',
},
})
expect($('title').text()).toBe('layout title')
} else {
const $ = await next.render$('/')
expect($('title').text()).toBe('layout title')
}
})
it('should render the title once for the non-existed route', async () => {
const browser = await next.browser('/non-existed')
const titles = await browser.elementsByCss('title')
// FIXME: (metadata), the title should only be rendered once and using the not-found title
expect(titles).toHaveLength(3)
}) })
}) })
...@@ -21,5 +21,5 @@ ...@@ -21,5 +21,5 @@
"target": "ES2017" "target": "ES2017"
}, },
"include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"], "include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"] "exclude": ["node_modules", "**/*.test.ts", "**/*.test.tsx"]
} }
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