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({
const notFoundElement = NotFound ? (
<>
<NotFound />
{metadata}
{notFoundStyles}
</>
) : undefined
......@@ -419,7 +418,6 @@ async function createComponentTreeInternal({
const forbiddenElement = Forbidden ? (
<>
<Forbidden />
{metadata}
{forbiddenStyles}
</>
) : undefined
......@@ -427,7 +425,6 @@ async function createComponentTreeInternal({
const unauthorizedElement = Unauthorized ? (
<>
<Unauthorized />
{metadata}
{unauthorizedStyles}
</>
) : undefined
......@@ -858,7 +855,6 @@ async function createComponentTreeInternal({
{notFoundStyles}
<NotFound />
</SegmentComponent>
{metadata}
</>
) : undefined
}
......
......@@ -6,7 +6,7 @@ export default function Layout({
slot: React.ReactNode
}) {
return (
<html>
<html lang="en" className="layout">
<body>
{children}
{slot}
......@@ -14,3 +14,7 @@ export default function Layout({
</html>
)
}
export const metadata = {
title: 'layout title',
}
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
pageExtensions: ['tsx', 'ts'],
}
const nextConfig = {}
module.exports = nextConfig
import { nextTestSetup } from 'e2e-utils'
const isPPR = process.env.__NEXT_EXPERIMENTAL_PPR === 'true'
describe('parallel-routes-and-interception', () => {
const { next, skipped } = nextTestSetup({
const { next, isNextDev, skipped } = nextTestSetup({
files: __dirname,
// TODO: remove after deployment handling is updated
skipDeployment: true,
......@@ -21,5 +23,28 @@ describe('parallel-routes-and-interception', () => {
// we also check that the #children-slot id is not present
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 @@
"target": "ES2017"
},
"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