test: add name re-export from client components as page case (#66760)

### What

Add new test case where a named export from client component is being
exported as page

### Why

We found this case while investigating the errors triggered introduced
by #66286 , adding this test to avoid future regression
This commit is contained in:
Jiachi Liu 2024-06-11 20:42:10 +02:00 committed by GitHub
parent b5d0a67912
commit 62e8c9dd45
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 30 additions and 1 deletions

View file

@ -0,0 +1,7 @@
export default function RootLayout({ children }) {
return (
<html>
<body>{children}</body>
</html>
)
}

View file

@ -0,0 +1,9 @@
'use client'
export function PageComponent() {
return (
<div>
<h1 id="client-title">Client Title</h1>
</div>
)
}

View file

@ -0,0 +1,3 @@
import { PageComponent } from './client'
export default PageComponent

View file

@ -1,5 +1,5 @@
'use client'
export function Foo() {
return <div>Foo</div>
return <div id="foo">Foo</div>
}

View file

@ -109,6 +109,16 @@ describe('app dir - rsc basics', () => {
expect($('#return-undefined-layout').html()).toBeEmpty()
})
it('should handle named client components imported as page', async () => {
const $ = await next.render$('/reexport-named')
expect($('#client-title').text()).toBe('Client Title')
})
it('should handle client components imported as namespace', async () => {
const $ = await next.render$('/reexport-namespace')
expect($('#foo').text()).toBe('Foo')
})
it('should render server components correctly', async () => {
const homeHTML = await next.render('/', null, {
headers: {