Skip to content

Commit 613168c

Browse files
committed
chore: update the example
1 parent f6f98b8 commit 613168c

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

examples/react-component-bundle/src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const Counter: React.FC = () => {
88

99
return (
1010
<div>
11-
<h1 className="counter-title">Counter React Component</h1>
11+
<h1 className="counter-title">React</h1>
1212
<h2 className="counter-text">Counter: {count}</h2>
1313
<CounterButton onClick={decrement} label="-" />
1414
<CounterButton onClick={increment} label="+" />

tests/e2e/react-component/index.pw.test.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import fs from 'node:fs';
22
import path from 'node:path';
33
import { type Page, expect, test } from '@playwright/test';
44
import { dev } from 'test-helper/rsbuild';
5+
import assert from 'node:assert';
56

67
function getCwdByExample(exampleName: string) {
78
return path.join(__dirname, '../../../examples', exampleName);
@@ -27,9 +28,19 @@ async function styleShouldWork(page: Page) {
2728

2829
const buttonEl = page.locator('#root button');
2930
const [subtractEl, addEl] = await buttonEl.all();
30-
subtractEl &&
31-
expect(subtractEl).toHaveCSS('background-color', 'rgb(255, 255, 0)');
32-
addEl && expect(addEl).toHaveCSS('background-color', 'rgb(255, 255, 0)');
31+
assert(subtractEl);
32+
assert(addEl);
33+
expect(subtractEl).toHaveCSS('background-color', 'rgb(255, 255, 0)');
34+
expect(addEl).toHaveCSS('background-color', 'rgb(255, 255, 0)');
35+
}
36+
37+
async function assetShouldWork(page: Page) {
38+
// asset in css url('./logo.svg')
39+
const h1El = page.locator('h1');
40+
assert(h1El);
41+
expect(h1El).toHaveCSS('background', /static\/svg\/logo/);
42+
43+
// TODO: asset in js
3344
}
3445

3546
test('should render example "react-component-bundle" successfully', async ({
@@ -43,6 +54,7 @@ test('should render example "react-component-bundle" successfully', async ({
4354

4455
await counterCompShouldWork(page);
4556
await styleShouldWork(page);
57+
await assetShouldWork(page);
4658
await rsbuild.close();
4759
});
4860

tests/e2e/react-component/rsbuild.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export default defineConfig({
6262
},
6363
output: {
6464
target: 'web',
65+
dataUriLimit: 0
6566
},
6667
plugins: [
6768
pluginReact({

0 commit comments

Comments
 (0)