Skip to content

Commit

Permalink
Test TLA
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Sep 18, 2024
1 parent 5791706 commit 3fb9594
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use client'

let name = await Promise.resolve('async')

export default (props) => {
return <button {...props}>this is an {name} client button</button>
}
7 changes: 7 additions & 0 deletions test/e2e/app-dir/dynamic/app/dynamic/async-client/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use client'

let name = await Promise.resolve('async')

export default (props) => {
return <button {...props}>this is an {name} client button with SSR</button>
}
13 changes: 13 additions & 0 deletions test/e2e/app-dir/dynamic/app/dynamic/async-client/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import dynamic from 'next/dynamic'

const Client1 = dynamic(() => import('./client'))
const Client2 = dynamic(() => import('./client-no-ssr'), { ssr: false })

export default function Page() {
return (
<>
<Client1 id="client-button" />
<Client2 id="client-button-no-ssr" />
</>
)
}
16 changes: 16 additions & 0 deletions test/e2e/app-dir/dynamic/dynamic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,21 @@ describe('app dir - next/dynamic', () => {
const $ = await next.render$('/dynamic/named-export')
expect($('#client-button').text()).toBe('this is a client button')
})

it('should support dynamic import with TLA in client components', async () => {
const $ = await next.render$('/dynamic/async-client')
expect($('#client-button').text()).toBe(
'this is an async client button with SSR'
)
expect($('#client-button-no-ssr').text()).toBe('')

const browser = await next.browser('/dynamic/async-client')
expect(await browser.elementByCss('#client-button').text()).toBe(
'this is an async client button with SSR'
)
expect(await browser.elementByCss('#client-button-no-ssr').text()).toBe(
'this is an async client button'
)
})
})
})

0 comments on commit 3fb9594

Please sign in to comment.