Skip to content

Commit e9f902b

Browse files
committed
test: add e2e
1 parent c9c2701 commit e9f902b

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

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

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,13 +1183,24 @@ function defineTest(f: Fixture) {
11831183
test('assets', async ({ page }) => {
11841184
await page.goto(f.url())
11851185
await waitForHydration(page)
1186-
// await expect(page.getByAltText('Vite logo')).not.toHaveJSProperty(
1187-
// 'naturalWidth',
1188-
// 0,
1189-
// )
1190-
// await expect(page.getByAltText('React logo')).not.toHaveJSProperty(
1191-
// 'naturalWidth',
1192-
// 0,
1193-
// )
1186+
await expect(
1187+
page.getByTestId('test-assets-server-import'),
1188+
).not.toHaveJSProperty('naturalWidth', 0)
1189+
await expect(
1190+
page.getByTestId('test-assets-client-import'),
1191+
).not.toHaveJSProperty('naturalWidth', 0)
1192+
1193+
async function testBackgroundImage(selector: string) {
1194+
const url = await page
1195+
.locator(selector)
1196+
.evaluate((el) => getComputedStyle(el).backgroundImage)
1197+
expect(url).toMatch(/^url\(.*\)$/)
1198+
const response = await page.request.get(url.slice(5, -2))
1199+
expect(response.ok()).toBeTruthy()
1200+
expect(response.headers()['content-type']).toBe('image/svg+xml')
1201+
}
1202+
1203+
await testBackgroundImage('.test-assets-server-css')
1204+
await testBackgroundImage('.test-assets-client-css')
11941205
})
11951206
}

packages/plugin-rsc/examples/basic/src/routes/assets/client.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function TestAssetsClient() {
99
<span>test-assets-client</span>
1010
<img
1111
src={svg}
12-
data-testid="test-assets-client-js"
12+
data-testid="test-assets-client-import"
1313
width="20"
1414
height="20"
1515
/>

packages/plugin-rsc/examples/basic/src/routes/assets/server.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function TestAssetsServer() {
99
<span>test-assets-server</span>
1010
<img
1111
src={svg}
12-
data-testid="test-assets-server-js"
12+
data-testid="test-assets-server-import"
1313
width="20"
1414
height="20"
1515
/>

0 commit comments

Comments
 (0)