Skip to content

Commit

Permalink
test: add name re-export from client components as page case (#66760)
Browse files Browse the repository at this point in the history
### 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
  • Loading branch information
huozhi authored Jun 11, 2024
1 parent b5d0a67 commit 62e8c9d
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 1 deletion.
7 changes: 7 additions & 0 deletions test/e2e/app-dir/app-routes-client-component/app/layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function RootLayout({ children }) {
return (
<html>
<body>{children}</body>
</html>
)
}
9 changes: 9 additions & 0 deletions test/e2e/app-dir/rsc-basic/app/reexport-named/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use client'

export function PageComponent() {
return (
<div>
<h1 id="client-title">Client Title</h1>
</div>
)
}
3 changes: 3 additions & 0 deletions test/e2e/app-dir/rsc-basic/app/reexport-named/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { PageComponent } from './client'

export default PageComponent
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use client'

export function Foo() {
return <div>Foo</div>
return <div id="foo">Foo</div>
}
10 changes: 10 additions & 0 deletions test/e2e/app-dir/rsc-basic/rsc-basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 62e8c9d

Please sign in to comment.