Skip to content

Commit 10cda62

Browse files
hi-ogawacodex
andcommitted
test(rsc): share starter CSS HMR coverage
Co-authored-by: Codex <noreply@openai.com>
1 parent bd87e65 commit 10cda62

2 files changed

Lines changed: 26 additions & 22 deletions

File tree

packages/plugin-rsc/e2e/css-link-precedence.test.ts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { expect, test } from '@playwright/test'
1+
import { test } from '@playwright/test'
22
import { setupInlineFixture, useFixture } from './fixture'
3-
import { expectNoReload, waitForHydration } from './helper'
43
import { defineStarterTest } from './starter'
54

65
test.describe('cssLinkPrecedence-false', () => {
@@ -31,26 +30,6 @@ test.describe('cssLinkPrecedence-false', () => {
3130
test.describe('dev', () => {
3231
const f = useFixture({ root, mode: 'dev' })
3332
defineStarterTest(f)
34-
35-
// TODO: move css hmr test to `starter.ts`
36-
test('css hmr', async ({ page }) => {
37-
await page.goto(f.url())
38-
await waitForHydration(page)
39-
const card = page.locator('.card').nth(0)
40-
41-
await using _ = await expectNoReload(page)
42-
const editor = f.createEditor('src/index.css')
43-
editor.edit((s) =>
44-
s.replace(
45-
'.card {\n padding: 1rem;',
46-
`.card {\n padding: 1rem; background-color: rgb(255, 0, 200);`,
47-
),
48-
)
49-
await expect(card).toHaveCSS('background-color', 'rgb(255, 0, 200)')
50-
51-
editor.reset()
52-
await expect(card).not.toHaveCSS('background-color', 'rgb(255, 0, 200)')
53-
})
5433
})
5534

5635
test.describe('build', () => {

packages/plugin-rsc/e2e/starter.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,31 @@ export function defineStarterTest(
123123
await expect(page.locator('.card').nth(0)).toHaveCSS('padding-left', '16px')
124124
})
125125

126+
test('css hmr', async ({ page }) => {
127+
test.skip(
128+
f.mode === 'build' ||
129+
variant === 'dev-production' ||
130+
variant === 'browser-mode',
131+
)
132+
133+
await page.goto(f.url())
134+
await waitForHydration(page)
135+
const card = page.locator('.card').nth(0)
136+
137+
await using _ = await expectNoReload(page)
138+
const editor = f.createEditor('src/index.css')
139+
editor.edit((s) =>
140+
s.replace(
141+
'.card {\n padding: 1rem;',
142+
`.card {\n padding: 1rem; background-color: rgb(255, 0, 200);`,
143+
),
144+
)
145+
await expect(card).toHaveCSS('background-color', 'rgb(255, 0, 200)')
146+
147+
editor.reset()
148+
await expect(card).not.toHaveCSS('background-color', 'rgb(255, 0, 200)')
149+
})
150+
126151
test.describe(() => {
127152
test.skip(variant === 'no-ssr' || variant === 'browser-mode')
128153

0 commit comments

Comments
 (0)