Skip to content

Commit eab0a16

Browse files
authored
test(rsc): test adding css import works without reload (#845)
1 parent cb5ce55 commit eab0a16

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

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

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -836,12 +836,40 @@ function defineTest(f: Fixture) {
836836
await expectNoDuplicateServerCss(page)
837837
})
838838

839-
// TODO: need a way to add/remove links on server hmr. for now, it requires a manually reload.
840-
test.skip('adding/removing css server @js', async ({ page }) => {
839+
// TODO: need a way to remove css links on server hmr. for now, it requires a manually reload.
840+
test('adding/removing css server @js', async ({ page }) => {
841841
await page.goto(f.url())
842842
await waitForHydration(page)
843+
await expect(page.locator('.test-style-server')).toHaveCSS(
844+
'color',
845+
'rgb(255, 165, 0)',
846+
)
847+
848+
// remove css import
849+
const editor = f.createEditor('src/routes/style-server/server.tsx')
850+
editor.edit((s) =>
851+
s.replaceAll(`import './server.css'`, `/* import './server.css' */`),
852+
)
853+
await page.waitForTimeout(100)
854+
await expect(async () => {
855+
// TODO: shouldn't require reload
856+
await page.reload()
857+
await expect(page.locator('.test-style-server')).toHaveCSS(
858+
'color',
859+
'rgb(0, 0, 0)',
860+
{ timeout: 10 },
861+
)
862+
}).toPass()
863+
864+
// adding css works without reload
865+
await waitForHydration(page)
843866
await using _ = await expectNoReload(page)
844-
await testAddRemoveCssServer(page, { js: true })
867+
868+
editor.reset()
869+
await expect(page.locator('.test-style-server')).toHaveCSS(
870+
'color',
871+
'rgb(255, 165, 0)',
872+
)
845873
})
846874

847875
testNoJs('adding/removing css server @nojs', async ({ page }) => {

0 commit comments

Comments
 (0)