Skip to content

Commit 30db584

Browse files
hi-ogawacodex
andcommitted
test(rsc): move starter extra CSS module fixture
Co-authored-by: Codex <noreply@openai.com>
1 parent b9c3f6d commit 30db584

4 files changed

Lines changed: 22 additions & 31 deletions

File tree

packages/plugin-rsc/e2e/css-code-split.test.ts

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,6 @@ test.describe('cssCodeSplit-false', () => {
2323
2424
export default mergeConfig(baseConfig, overrideConfig)
2525
`,
26-
// test server css module too
27-
// (starter example already tests normal server css)
28-
'src/server-only.module.css': /* css */ `
29-
.serverOnly {
30-
color: rgb(123, 45, 67);
31-
}
32-
`,
33-
'src/server-only.tsx': /* js */ `
34-
import styles from './server-only.module.css'
35-
export function ServerOnly() {
36-
return (
37-
<button data-testid="server-only" className={styles.serverOnly}>
38-
server-only
39-
</button>
40-
)
41-
}
42-
`,
43-
'src/root.tsx': {
44-
edit: (s) =>
45-
s
46-
.replace(
47-
`import { ClientCounter } from './client.tsx'`,
48-
`import { ClientCounter } from './client.tsx';
49-
import { ServerOnly } from './server-only.tsx'`,
50-
)
51-
.replace(`<ClientCounter />`, `<ClientCounter /><ServerOnly />`),
52-
},
5326
},
5427
})
5528
})
@@ -60,10 +33,9 @@ test.describe('cssCodeSplit-false', () => {
6033

6134
test('server css module', async ({ page }) => {
6235
await page.goto(f.url())
63-
await expect(page.getByTestId('server-only')).toHaveCSS(
64-
'color',
65-
'rgb(123, 45, 67)',
66-
)
36+
await expect(
37+
page.getByTestId('starter-extra-server-css-module'),
38+
).toHaveCSS('color', 'rgb(123, 45, 67)')
6739
})
6840
})
6941
})
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.serverCssModule {
2+
color: rgb(123, 45, 67);
3+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import styles from './server-css-module.module.css'
2+
3+
export function ServerCssModule() {
4+
return (
5+
<button
6+
data-testid="starter-extra-server-css-module"
7+
className={styles.serverCssModule}
8+
>
9+
server css module
10+
</button>
11+
)
12+
}

packages/plugin-rsc/examples/starter-extra/src/root.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import viteLogo from '/vite.svg'
33
import { getServerCounter, updateServerCounter } from './action.tsx'
44
import reactLogo from './assets/react.svg'
55
import { ClientCounter } from './client.tsx'
6+
import { ServerCssModule } from './features/css/server-css-module.tsx'
67

78
export function Root(props: { url: URL }) {
89
return (
@@ -44,6 +45,9 @@ function App(props: { url: URL }) {
4445
</form>
4546
</div>
4647
<div className="card">Request URL: {props.url?.href}</div>
48+
<div className="card">
49+
<ServerCssModule />
50+
</div>
4751
<ul className="read-the-docs">
4852
<li>
4953
Edit <code>src/client.tsx</code> to test client HMR.

0 commit comments

Comments
 (0)