Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eslint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const config: Config[] = defineConfig([
},
},
rules: {
'react/prop-types': 'off',
'react/jsx-curly-brace-presence': 'error',
},
},
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions tests-e2e/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests-e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"@rspack/cli": "^1.4.11",
"@rspack/core": "^1.4.11",
"@types/node": "^24.2.1",
"@types/react": "^19.1.10",
"@types/react-dom": "^19.1.7",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
"css-loader": "^7.1.2",
"prettier": "^3.6.2",
"typescript": "^5.9.2"
Expand Down
7 changes: 7 additions & 0 deletions tests-e2e/src/reset.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,10 @@ input:not([type='checkbox']) {
box-shadow: inset 0 0 0 2px #000;
border-radius: 6px;
}

textarea {
font-size: 16px;
padding: 0 8px;
box-shadow: inset 0 0 0 2px #000;
border-radius: 6px;
}
18 changes: 18 additions & 0 deletions tests-e2e/stories/error-boundary/primary.m.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.container {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 12px;
}

.broken {
border: 1px solid #eee;
border-radius: 8px;
padding: 16px;
}

.fallback {
background: rgb(255, 162, 162);
border-radius: 8px;
padding: 16px;
}
36 changes: 36 additions & 0 deletions tests-e2e/stories/error-boundary/primary.story.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { useState } from 'react';
import { ErrorBoundary } from '@krutoo/utils/react';
import styles from './primary.m.css';

export const meta = {
category: 'React components/ErrorBoundary',
title: 'Primary example',
};

function BrokenUI({ broken }: { broken?: boolean }) {
if (broken) {
throw Error('Render error');
}

return <div className={styles.broken}>I am fine 👍</div>;
}

function Fallback() {
return <div className={styles.fallback}>Oops, something broke =(</div>;
}

export default function Example() {
const [broken, setBroken] = useState(false);

return (
<div className={styles.container}>
<button disabled={broken} onClick={() => setBroken(true)}>
Broke it!
</button>

<ErrorBoundary fallback={<Fallback />}>
<BrokenUI broken={broken} />
</ErrorBoundary>
</div>
);
}
12 changes: 12 additions & 0 deletions tests-e2e/tests/error-boundary.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { expect, test } from '@playwright/test';

test('ErrorBoundary', async ({ page }) => {
await page.goto('/sandbox.html?path=/error-boundary/primary');

expect(await page.textContent('body')).toContain('I am fine 👍');

await page.getByRole('button', { name: 'Broke it!' }).click();

expect(await page.textContent('body')).not.toContain('I am fine 👍');
expect(await page.textContent('body')).toContain('Oops, something broke =(');
});
18 changes: 18 additions & 0 deletions tests-e2e/tests/portal.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { expect, test } from '@playwright/test';

test('Portal', async ({ page }) => {
await page.goto('/sandbox.html?path=/portal/primary');

const button = page.getByRole('button', { name: 'Toggle' });

expect(await button.count()).toBe(1);
expect(await page.locator('body > *').count()).toBe(1);

await button.click();

expect(await page.locator('body > *').count()).toBe(2);
expect(await page.locator('body > *').last().textContent()).toContain('Hello from Portal!');

await button.click();
expect(await page.locator('body > *').count()).toBe(1);
});
14 changes: 2 additions & 12 deletions tests-e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"rootDir": ".",
"noEmit": true,
"target": "ESNext",
"module": "NodeNext",
Expand All @@ -13,18 +14,7 @@
"noUnusedLocals": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"allowImportingTsExtensions": true,
"paths": {
"@krutoo/utils": ["../src/mod.ts"],
"@krutoo/utils/di": ["../src/di/mod.ts"],
"@krutoo/utils/dom": ["../src/dom/mod.ts"],
"@krutoo/utils/math": ["../src/math/mod.ts"],
"@krutoo/utils/misc": ["../src/misc/mod.ts"],
"@krutoo/utils/react": ["../src/react/mod.ts"],
"@krutoo/utils/router": ["../src/router/mod.ts"],
"@krutoo/utils/rspack": ["../src/rspack/mod.ts"],
"@krutoo/utils/types": ["../src/types/mod.ts"]
}
"allowImportingTsExtensions": true
},
"exclude": ["node_modules"]
}
Loading