diff --git a/packages/next/src/server/app-render/create-component-tree.tsx b/packages/next/src/server/app-render/create-component-tree.tsx index ccb0dcbfa6831..0a330d00ec102 100644 --- a/packages/next/src/server/app-render/create-component-tree.tsx +++ b/packages/next/src/server/app-render/create-component-tree.tsx @@ -411,7 +411,6 @@ async function createComponentTreeInternal({ const notFoundElement = NotFound ? ( <> - {metadata} {notFoundStyles} ) : undefined @@ -419,7 +418,6 @@ async function createComponentTreeInternal({ const forbiddenElement = Forbidden ? ( <> - {metadata} {forbiddenStyles} ) : undefined @@ -427,7 +425,6 @@ async function createComponentTreeInternal({ const unauthorizedElement = Unauthorized ? ( <> - {metadata} {unauthorizedStyles} ) : undefined @@ -858,7 +855,6 @@ async function createComponentTreeInternal({ {notFoundStyles} - {metadata} ) : undefined } diff --git a/test/e2e/app-dir/parallel-routes-not-found/app/layout.tsx b/test/e2e/app-dir/parallel-routes-not-found/app/layout.tsx index 8edcca91b6c6b..1e2a530ec2273 100644 --- a/test/e2e/app-dir/parallel-routes-not-found/app/layout.tsx +++ b/test/e2e/app-dir/parallel-routes-not-found/app/layout.tsx @@ -6,7 +6,7 @@ export default function Layout({ slot: React.ReactNode }) { return ( - + {children} {slot} @@ -14,3 +14,7 @@ export default function Layout({ ) } + +export const metadata = { + title: 'layout title', +} diff --git a/test/e2e/app-dir/parallel-routes-not-found/next.config.js b/test/e2e/app-dir/parallel-routes-not-found/next.config.js index 3f1bcf9fbe2e1..807126e4cf0bf 100644 --- a/test/e2e/app-dir/parallel-routes-not-found/next.config.js +++ b/test/e2e/app-dir/parallel-routes-not-found/next.config.js @@ -1,8 +1,6 @@ /** * @type {import('next').NextConfig} */ -const nextConfig = { - pageExtensions: ['tsx', 'ts'], -} +const nextConfig = {} module.exports = nextConfig diff --git a/test/e2e/app-dir/parallel-routes-not-found/parallel-routes-not-found.test.ts b/test/e2e/app-dir/parallel-routes-not-found/parallel-routes-not-found.test.ts index 132ff581b95f1..ba41f3c28283f 100644 --- a/test/e2e/app-dir/parallel-routes-not-found/parallel-routes-not-found.test.ts +++ b/test/e2e/app-dir/parallel-routes-not-found/parallel-routes-not-found.test.ts @@ -1,7 +1,9 @@ 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) }) }) diff --git a/test/e2e/app-dir/parallel-routes-not-found/tsconfig.json b/test/e2e/app-dir/parallel-routes-not-found/tsconfig.json index 2eef1368c65e7..140aa2eecad48 100644 --- a/test/e2e/app-dir/parallel-routes-not-found/tsconfig.json +++ b/test/e2e/app-dir/parallel-routes-not-found/tsconfig.json @@ -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"] }