Skip to content

Commit ed57d90

Browse files
hi-ogawaclaude
andcommitted
refactor(rsc): use consistent naming for lazy CSS test files
Rename files, selectors, and text content to match component names: - client-to-client: client -> lazy client -> CSS - server-to-client: server -> lazy client with CSS - server-to-server: server -> lazy server with CSS Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 72be380 commit ed57d90

27 files changed

Lines changed: 186 additions & 113 deletions

packages/plugin-rsc/e2e/basic.test.ts

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,78 +1045,76 @@ function defineTest(f: Fixture) {
10451045
)
10461046
})
10471047

1048-
// TODO: lazy client component CSS is not yet supported
1049-
// https://github.com/wakujs/waku/issues/1911
1048+
// TODO: lazy component CSS is not yet fully supported
1049+
// https://github.com/vitejs/vite-plugin-react/issues/1057
10501050

1051-
// Case 1: client component -> lazy client component -> CSS (two steps)
1052-
test('lazy client css @js', async ({ page }) => {
1051+
// Case 1: client -> lazy client -> CSS
1052+
test('lazy css client to client @js', async ({ page }) => {
10531053
await page.goto(f.url())
10541054
await waitForHydration(page)
1055-
// CSS is loaded after hydration via JS, so it works
1056-
await expect(page.locator('.test-lazy-client-css')).toHaveCSS(
1055+
// CSS is loaded after hydration via JS
1056+
await expect(page.locator('.test-lazy-css-client-to-client')).toHaveCSS(
10571057
'color',
10581058
'rgb(255, 165, 0)',
10591059
)
10601060
})
10611061

1062-
testNoJs('lazy client css @nojs', async ({ page }) => {
1062+
testNoJs('lazy css client to client @nojs', async ({ page }) => {
10631063
await page.goto(f.url())
1064-
// lazy component is rendered correctly in SSR
1065-
await expect(page.locator('.test-lazy-client-css')).toHaveText(
1066-
'lazy-client-css',
1064+
// component is rendered correctly in SSR
1065+
await expect(page.locator('.test-lazy-css-client-to-client')).toHaveText(
1066+
'lazy-css-client-to-client',
10671067
)
1068-
// but CSS from lazy client component is not included in SSR (FOUC)
1069-
await expect(page.locator('.test-lazy-client-css')).toHaveCSS(
1068+
// but CSS is not included in SSR (FOUC)
1069+
await expect(page.locator('.test-lazy-css-client-to-client')).toHaveCSS(
10701070
'color',
10711071
'rgb(0, 0, 0)',
10721072
)
10731073
})
10741074

1075-
// Case 2: server component -> lazy client component with CSS (one step)
1076-
// This works because the client component CSS is tracked
1077-
test('lazy client css direct @js', async ({ page }) => {
1075+
// Case 2: server -> lazy client with CSS
1076+
test('lazy css server to client @js', async ({ page }) => {
10781077
await page.goto(f.url())
10791078
await waitForHydration(page)
1080-
await expect(page.locator('.test-lazy-client-css-direct')).toHaveCSS(
1079+
await expect(page.locator('.test-lazy-css-server-to-client')).toHaveCSS(
10811080
'color',
10821081
'rgb(255, 165, 0)',
10831082
)
10841083
})
10851084

1086-
testNoJs('lazy client css direct @nojs', async ({ page }) => {
1085+
testNoJs('lazy css server to client @nojs', async ({ page }) => {
10871086
await page.goto(f.url())
1088-
await expect(page.locator('.test-lazy-client-css-direct')).toHaveText(
1089-
'lazy-client-css-direct',
1087+
await expect(page.locator('.test-lazy-css-server-to-client')).toHaveText(
1088+
'lazy-css-server-to-client',
10901089
)
1091-
// CSS is included in SSR for direct lazy client components
1092-
await expect(page.locator('.test-lazy-client-css-direct')).toHaveCSS(
1090+
// CSS is included in SSR
1091+
await expect(page.locator('.test-lazy-css-server-to-client')).toHaveCSS(
10931092
'color',
10941093
'rgb(255, 165, 0)',
10951094
)
10961095
})
10971096

1098-
// Case 3: server component -> lazy server component with CSS
1099-
// CSS from lazy server components is not supported
1100-
test('lazy server css @js', async ({ page }) => {
1097+
// Case 3: server -> lazy server with CSS
1098+
test('lazy css server to server @js', async ({ page }) => {
11011099
await page.goto(f.url())
11021100
await waitForHydration(page)
1103-
await expect(page.locator('.test-lazy-server-css')).toHaveText(
1104-
'lazy-server-css',
1101+
await expect(page.locator('.test-lazy-css-server-to-server')).toHaveText(
1102+
'lazy-css-server-to-server',
11051103
)
11061104
// CSS is never loaded (not even via JS)
1107-
await expect(page.locator('.test-lazy-server-css')).toHaveCSS(
1105+
await expect(page.locator('.test-lazy-css-server-to-server')).toHaveCSS(
11081106
'color',
11091107
'rgb(0, 0, 0)',
11101108
)
11111109
})
11121110

1113-
testNoJs('lazy server css @nojs', async ({ page }) => {
1111+
testNoJs('lazy css server to server @nojs', async ({ page }) => {
11141112
await page.goto(f.url())
1115-
await expect(page.locator('.test-lazy-server-css')).toHaveText(
1116-
'lazy-server-css',
1113+
await expect(page.locator('.test-lazy-css-server-to-server')).toHaveText(
1114+
'lazy-css-server-to-server',
11171115
)
1118-
// CSS from lazy server component is not included in SSR
1119-
await expect(page.locator('.test-lazy-server-css')).toHaveCSS(
1116+
// CSS is not included in SSR
1117+
await expect(page.locator('.test-lazy-css-server-to-server')).toHaveCSS(
11201118
'color',
11211119
'rgb(0, 0, 0)',
11221120
)

packages/plugin-rsc/examples/basic/src/routes/lazy-css/lazy-server-dep.css renamed to packages/plugin-rsc/examples/basic/src/routes/lazy-css/case1-child.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
.test-lazy-server-css {
1+
.test-lazy-css-case1 {
22
color: rgb(255, 165, 0);
33
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import './case1-child.css'
2+
3+
export default function Case1Child() {
4+
return <span className="test-lazy-css-case1">case1-child</span>
5+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use client'
2+
3+
// Case 1: client component -> lazy client component -> CSS
4+
import * as React from 'react'
5+
6+
const LazyChild = React.lazy(() => import('./case1-child'))
7+
8+
export function TestLazyCssClientToClient() {
9+
return (
10+
<div data-testid="test-lazy-css-case1">
11+
<React.Suspense fallback={<span>loading...</span>}>
12+
<LazyChild />
13+
</React.Suspense>
14+
</div>
15+
)
16+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.test-lazy-css-case2 {
2+
color: rgb(255, 165, 0);
3+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use client'
2+
3+
import './case2-child.css'
4+
5+
export default function Case2Child() {
6+
return <span className="test-lazy-css-case2">case2-child</span>
7+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Case 2: server component -> lazy client component with CSS
2+
import * as React from 'react'
3+
4+
const LazyChild = React.lazy(() => import('./case2-child'))
5+
6+
export function TestLazyCssServerToClient() {
7+
return (
8+
<div data-testid="test-lazy-css-case2">
9+
<React.Suspense fallback={<span>loading...</span>}>
10+
<LazyChild />
11+
</React.Suspense>
12+
</div>
13+
)
14+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.test-lazy-css-case3 {
2+
color: rgb(255, 165, 0);
3+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import './case3-child.css'
2+
3+
export default function Case3Child() {
4+
return <span className="test-lazy-css-case3">case3-child</span>
5+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Case 3: server component -> lazy server component with CSS
2+
import * as React from 'react'
3+
4+
const LazyChild = React.lazy(() => import('./case3-child'))
5+
6+
export function TestLazyCssServerToServer() {
7+
return (
8+
<div data-testid="test-lazy-css-case3">
9+
<React.Suspense fallback={<span>loading...</span>}>
10+
<LazyChild />
11+
</React.Suspense>
12+
</div>
13+
)
14+
}

0 commit comments

Comments
 (0)