Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type LayoutProps = {
children: React.ReactNode
}

export default function Layout({ children }: LayoutProps) {
return <div>{children}</div>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Link from 'next/link'

export default function Page() {
return (
<div>
<div>Home header</div>
<Link href="/parallel-route/product" id="product-link">
Product
</Link>
</div>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type LayoutProps = {
children: React.ReactNode
}

export default function Layout({ children }: LayoutProps) {
return <>{children}</>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Link from 'next/link'

export default function Page() {
return (
<div>
<h1 id="product-title">Product header</h1>
<Link href="/parallel-route" id="home-link">
Go to Home page
</Link>
</div>
)
}
17 changes: 17 additions & 0 deletions test/e2e/app-dir/metadata-navigation/app/parallel-route/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export default function Layout({ children, header }) {
return (
<html>
<head></head>
<body>
{header}
{children}
</body>
</html>
)
}

export const metadata = {
title: 'Home Layout',
description: 'this is the layout description',
keywords: ['nextjs', 'react'],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function Home() {
return (
<div>
<h3 id="home-title">Home page content</h3>
</div>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Metadata } from 'next'

export const metadata: Metadata = {
title: 'Product Layout',
}

export default function Layout({
children,
}: Readonly<{
children: React.ReactNode
}>) {
return <>{children}</>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page() {
return <div>Product page content</div>
}
21 changes: 21 additions & 0 deletions test/e2e/app-dir/metadata-navigation/metadata-navigation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,26 @@ describe('app dir - metadata navigation', () => {
})
expect(res.status).toBe(307)
})

it('should show the index title', async () => {
const browser = await next.browser('/parallel-route')
expect(await browser.elementByCss('title').text()).toBe('Home Layout')
})

it('should show target page metadata after navigation', async () => {
const browser = await next.browser('/parallel-route')
await browser.elementByCss('#product-link').click()
await browser.waitForElementByCss('#product-title')
expect(await browser.elementByCss('title').text()).toBe('Product Layout')
})

it('should show target page metadata after navigation with back', async () => {
const browser = await next.browser('/parallel-route')
await browser.elementByCss('#product-link').click()
await browser.waitForElementByCss('#product-title')
await browser.elementByCss('#home-link').click()
await browser.waitForElementByCss('#home-title')
expect(await browser.elementByCss('title').text()).toBe('Home Layout')
})
})
})
Loading