Skip to content

Commit 1fc1bab

Browse files
committed
test: tweak
1 parent 31de4d7 commit 1fc1bab

File tree

2 files changed

+21
-68
lines changed

2 files changed

+21
-68
lines changed

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

Lines changed: 20 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,74 +1156,27 @@ function defineTest(f: Fixture) {
11561156
test('css queries @js', async ({ page }) => {
11571157
await page.goto(f.url())
11581158
await waitForHydration(page)
1159-
await testCssQueries(page)
1160-
})
1161-
1162-
testNoJs('css queries @nojs', async ({ page }) => {
1163-
await page.goto(f.url())
1164-
await testCssQueries(page)
1165-
})
1166-
1167-
async function testCssQueries(page: Page) {
1168-
// Test that CSS with special queries (?url, ?inline, ?raw) don't break the page
1169-
// and that normal CSS imports still work for both server and client components
1170-
1171-
// Server component tests
1172-
await expect(
1173-
page.getByTestId('test-css-queries-server-normal'),
1174-
).toBeVisible()
1175-
1176-
// Client component tests
1177-
await expect(
1178-
page.getByTestId('test-css-queries-client-normal'),
1179-
).toBeVisible()
1180-
1181-
// Test that normal CSS imports are applied correctly to server component
1182-
await expect(page.locator('.test-css-query-server-normal')).toHaveCSS(
1183-
'background-color',
1184-
'rgb(255, 0, 0)',
1185-
)
1186-
await expect(page.locator('.test-css-query-server-normal')).toHaveCSS(
1187-
'color',
1188-
'rgb(0, 255, 0)',
1189-
)
11901159

1191-
// Test that normal CSS imports are applied correctly to client component
1192-
await expect(page.locator('.test-css-query-client-normal')).toHaveCSS(
1193-
'background-color',
1194-
'rgb(0, 0, 255)',
1195-
)
1196-
await expect(page.locator('.test-css-query-client-normal')).toHaveCSS(
1197-
'color',
1198-
'rgb(255, 255, 0)',
1199-
)
1200-
1201-
// Verify that URL query returns a string URL for server component (with filename pattern)
1202-
const serverUrlText = await page
1203-
.getByTestId('test-css-queries-server-url')
1204-
.textContent()
1205-
expect(serverUrlText).toMatch(/CSS URL \(server\): .*server-url.*\.css/)
1206-
1207-
// Verify that URL query returns a string URL for client component (with filename pattern)
1208-
const clientUrlText = await page
1209-
.getByTestId('test-css-queries-client-url')
1210-
.textContent()
1211-
expect(clientUrlText).toMatch(/CSS URL \(client\): .*client-url.*\.css/)
1160+
const tests = [
1161+
['.test-css-url-client', 'rgb(255, 100, 0)'],
1162+
['.test-css-inline-client', 'rgb(255, 50, 0)'],
1163+
['.test-css-raw-client', 'rgb(255, 0, 0)'],
1164+
['.test-css-url-server', 'rgb(0, 255, 100)'],
1165+
['.test-css-inline-server', 'rgb(0, 255, 50)'],
1166+
['.test-css-raw-server', 'rgb(0, 255, 0)'],
1167+
] as const
1168+
1169+
// css with queries are not injected automatically
1170+
for (const [selector] of tests) {
1171+
await expect(page.locator(selector)).toHaveCSS('color', 'rgb(0, 0, 0)')
1172+
}
12121173

1213-
// Verify that inline and raw queries return strings for server component (should not be collected for SSR)
1214-
await expect(
1215-
page.getByTestId('test-css-queries-server-inline'),
1216-
).toContainText('CSS Inline (server): string')
1217-
await expect(page.getByTestId('test-css-queries-server-raw')).toContainText(
1218-
'CSS Raw (server): string',
1219-
)
1174+
// inject css manually
1175+
await page.getByRole('button', { name: 'test-css-queries' }).click()
12201176

1221-
// Verify that inline and raw queries return strings for client component (should not be collected for SSR)
1222-
await expect(
1223-
page.getByTestId('test-css-queries-client-inline'),
1224-
).toContainText('CSS Inline (client): string')
1225-
await expect(page.getByTestId('test-css-queries-client-raw')).toContainText(
1226-
'CSS Raw (client): string',
1227-
)
1228-
}
1177+
// verify styles
1178+
for (const [selector, color] of tests) {
1179+
await expect(page.locator(selector)).toHaveCSS('color', color)
1180+
}
1181+
})
12291182
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
.test-css-url-server {
2-
color: rgb(0, 200, 100);
2+
color: rgb(0, 255, 100);
33
}

0 commit comments

Comments
 (0)