Skip to content

Commit 8a6280e

Browse files
committed
Test TLA
1 parent 05578a1 commit 8a6280e

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use client'
2+
3+
let name = await Promise.resolve('async')
4+
5+
export default (props) => {
6+
return <button {...props}>this is an {name} client button</button>
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use client'
2+
3+
let name = await Promise.resolve('async')
4+
5+
export default (props) => {
6+
return <button {...props}>this is an {name} client button with SSR</button>
7+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import dynamic from 'next/dynamic'
2+
3+
const Client1 = dynamic(() => import('./client'))
4+
const Client2 = dynamic(() => import('./client-no-ssr'), { ssr: false })
5+
6+
export default function Page() {
7+
return (
8+
<>
9+
<Client1 id="client-button" />
10+
<Client2 id="client-button-no-ssr" />
11+
</>
12+
)
13+
}

test/e2e/app-dir/dynamic/dynamic.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,5 +148,21 @@ describe('app dir - next/dynamic', () => {
148148
const $ = await next.render$('/dynamic/named-export')
149149
expect($('#client-button').text()).toBe('this is a client button')
150150
})
151+
152+
it('should support dynamic import with TLA in the client component', async () => {
153+
const $ = await next.render$('/dynamic/async-client')
154+
expect($('#client-button').text()).toBe(
155+
'this is an async client button with SSR'
156+
)
157+
expect($('#client-button-no-ssr').text()).toBe('')
158+
159+
const browser = await next.browser('/dynamic/async-client')
160+
expect(await browser.elementByCss('#client-button').text()).toBe(
161+
'this is an async client button with SSR'
162+
)
163+
expect(await browser.elementByCss('#client-button-no-ssr').text()).toBe(
164+
'this is an async client button'
165+
)
166+
})
151167
})
152168
})

0 commit comments

Comments
 (0)