-
Notifications
You must be signed in to change notification settings - Fork 27.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix client reference access causing metadata missing (#70732)
- Loading branch information
Showing
7 changed files
with
72 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
test/e2e/app-dir/reexport-client-component-metadata/app/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export default function Layout({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<html> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} | ||
|
||
export const metadata = { | ||
title: 'Root Layout', | ||
description: 'Root Description', | ||
} |
5 changes: 5 additions & 0 deletions
5
test/e2e/app-dir/reexport-client-component-metadata/app/no-override/page-content.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use client' | ||
|
||
export default function PageContent() { | ||
return <h1>Page 2 Content</h1> | ||
} |
3 changes: 3 additions & 0 deletions
3
test/e2e/app-dir/reexport-client-component-metadata/app/no-override/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import PageContent from './page-content' | ||
|
||
export default PageContent |
5 changes: 5 additions & 0 deletions
5
test/e2e/app-dir/reexport-client-component-metadata/app/override/page-content.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use client' | ||
|
||
export default function PageContent() { | ||
return <h1>Page 1 Content</h1> | ||
} |
8 changes: 8 additions & 0 deletions
8
test/e2e/app-dir/reexport-client-component-metadata/app/override/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import PageContent from './page-content' | ||
|
||
export const metadata = { | ||
title: 'Page 1', | ||
description: 'Page 1 Description', | ||
} | ||
|
||
export default PageContent |
39 changes: 39 additions & 0 deletions
39
...e2e/app-dir/reexport-client-component-metadata/reexport-client-component-metadata.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { nextTestSetup } from 'e2e-utils' | ||
|
||
describe('app-dir - reexport-client-component-metadata', () => { | ||
const { next } = nextTestSetup({ | ||
files: __dirname, | ||
}) | ||
|
||
it('should render the page metadata if override', async () => { | ||
const $ = await next.render$('/override') | ||
expect($('title').text()).toBe('Page 1') | ||
expect($('meta[name="description"]').attr('content')).toBe( | ||
'Page 1 Description' | ||
) | ||
|
||
const browser = await next.browser('/override') | ||
expect(await browser.elementByCss('title').text()).toBe('Page 1') | ||
expect( | ||
await browser | ||
.elementByCss('meta[name="description"]') | ||
.getAttribute('content') | ||
).toBe('Page 1 Description') | ||
}) | ||
|
||
it('should render the layout metadata if not override', async () => { | ||
const $ = await next.render$('/no-override') | ||
expect($('title').text()).toBe('Root Layout') | ||
expect($('meta[name="description"]').attr('content')).toBe( | ||
'Root Description' | ||
) | ||
|
||
const browser = await next.browser('/no-override') | ||
expect(await browser.elementByCss('title').text()).toBe('Root Layout') | ||
expect( | ||
await browser | ||
.elementByCss('meta[name="description"]') | ||
.getAttribute('content') | ||
).toBe('Root Description') | ||
}) | ||
}) |