@atomic-testing/component-driver-mui-v9 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +76 -0
- package/dist/index.cjs +2439 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1391 -0
- package/dist/index.d.mts +1391 -0
- package/dist/index.mjs +2386 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +48 -0
- package/src/components/AccordionDriver.ts +109 -0
- package/src/components/AlertDriver.ts +74 -0
- package/src/components/AutoCompleteDriver.ts +151 -0
- package/src/components/AvatarDriver.ts +51 -0
- package/src/components/AvatarGroupDriver.ts +79 -0
- package/src/components/BadgeDriver.ts +43 -0
- package/src/components/BottomNavigationActionDriver.ts +23 -0
- package/src/components/BottomNavigationDriver.ts +138 -0
- package/src/components/ButtonDriver.ts +16 -0
- package/src/components/CheckboxDriver.ts +98 -0
- package/src/components/ChipDriver.ts +53 -0
- package/src/components/DialogDriver.ts +122 -0
- package/src/components/DrawerDriver.ts +90 -0
- package/src/components/FabDriver.ts +11 -0
- package/src/components/InputDriver.ts +112 -0
- package/src/components/ListDriver.ts +42 -0
- package/src/components/ListItemDriver.ts +34 -0
- package/src/components/MenuDriver.ts +65 -0
- package/src/components/MenuItemDriver.ts +15 -0
- package/src/components/OverlayDriver.ts +98 -0
- package/src/components/PaginationDriver.ts +117 -0
- package/src/components/ProgressDriver.ts +78 -0
- package/src/components/RadioDriver.ts +63 -0
- package/src/components/RadioGroupDriver.ts +129 -0
- package/src/components/RatingDriver.ts +121 -0
- package/src/components/SelectDriver.ts +223 -0
- package/src/components/SliderDriver.ts +109 -0
- package/src/components/SnackbarDriver.ts +68 -0
- package/src/components/SpeedDialDriver.ts +83 -0
- package/src/components/StepperDriver.ts +109 -0
- package/src/components/SwitchDriver.ts +62 -0
- package/src/components/TabDriver.ts +39 -0
- package/src/components/TableCellDriver.ts +14 -0
- package/src/components/TableDriver.ts +148 -0
- package/src/components/TablePaginationDriver.ts +110 -0
- package/src/components/TableRowDriver.ts +79 -0
- package/src/components/TabsDriver.ts +133 -0
- package/src/components/TextFieldDriver.ts +155 -0
- package/src/components/ToggleButtonDriver.ts +21 -0
- package/src/components/ToggleButtonGroupDriver.ts +75 -0
- package/src/components/TooltipDriver.ts +82 -0
- package/src/errors/MenuItemDisabledError.ts +17 -0
- package/src/errors/MenuItemNotFoundError.ts +17 -0
- package/src/index.ts +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Tianzhen Lin (Tangent)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# @atomic-testing/component-driver-mui-v9
|
|
2
|
+
|
|
3
|
+
Component drivers for [Material UI](https://mui.com) v9 components. Component drivers expose simple APIs for unit tests or end‑to‑end tests to interact with MUI components—such as reading states and setting values—so test engineers can focus on test flows without needing to track how the inner MUI components work.
|
|
4
|
+
|
|
5
|
+
## The problem
|
|
6
|
+
|
|
7
|
+
Material UI hides complex markup behind its components. Without dedicated drivers your tests often need to rely on implementation details, making them brittle as your application grows.
|
|
8
|
+
|
|
9
|
+
## The solution
|
|
10
|
+
|
|
11
|
+
The drivers in this package expose high‑level interactions for MUI widgets. Combined with the React adapter, they let you reuse scene definitions across DOM and end‑to‑end tests, focusing on **reusability**, **composability** and **adaptability**.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @atomic-testing/core @atomic-testing/react-19 \
|
|
17
|
+
@atomic-testing/component-driver-html @atomic-testing/component-driver-mui-v9 --save-dev
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Refer to the [documentation](https://atomic-testing.dev/) for usage patterns and examples.
|
|
21
|
+
|
|
22
|
+
## Example
|
|
23
|
+
|
|
24
|
+
1. Create a small component using MUI and assign `data-testid` values to the elements you want to interact with:
|
|
25
|
+
|
|
26
|
+
```tsx title="Counter.tsx"
|
|
27
|
+
import { useState } from 'react';
|
|
28
|
+
|
|
29
|
+
import Button from '@mui/material/Button';
|
|
30
|
+
|
|
31
|
+
export function Counter() {
|
|
32
|
+
const [count, setCount] = useState(0);
|
|
33
|
+
return (
|
|
34
|
+
<div>
|
|
35
|
+
<span data-testid='count'>{count}</span>
|
|
36
|
+
<Button data-testid='increment' onClick={() => setCount(c => c + 1)}>
|
|
37
|
+
Increment
|
|
38
|
+
</Button>
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
2. Define a `ScenePart` describing the count display and button using the MUI driver:
|
|
45
|
+
|
|
46
|
+
```ts title="counterScenePart.ts"
|
|
47
|
+
import { HTMLSpanDriver } from '@atomic-testing/component-driver-html';
|
|
48
|
+
import { ButtonDriver } from '@atomic-testing/component-driver-mui-v9';
|
|
49
|
+
import { byDataTestId, ScenePart } from '@atomic-testing/core';
|
|
50
|
+
|
|
51
|
+
export const counterScenePart = {
|
|
52
|
+
count: { locator: byDataTestId('count'), driver: HTMLSpanDriver },
|
|
53
|
+
increment: { locator: byDataTestId('increment'), driver: ButtonDriver },
|
|
54
|
+
} satisfies ScenePart;
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
3. Write a test using `createTestEngine` to render the component and interact with it:
|
|
58
|
+
|
|
59
|
+
```ts title="Counter.test.tsx"
|
|
60
|
+
import { createTestEngine } from '@atomic-testing/react-19';
|
|
61
|
+
|
|
62
|
+
import { Counter } from './Counter';
|
|
63
|
+
import { counterScenePart } from './counterScenePart';
|
|
64
|
+
|
|
65
|
+
test('increments when the button is clicked', async () => {
|
|
66
|
+
const engine = createTestEngine(<Counter />, counterScenePart);
|
|
67
|
+
|
|
68
|
+
expect(await engine.parts.count.getText()).toBe('0');
|
|
69
|
+
await engine.parts.increment.click();
|
|
70
|
+
expect(await engine.parts.count.getText()).toBe('1');
|
|
71
|
+
|
|
72
|
+
await engine.cleanUp();
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
For more in‑depth information, visit [https://atomic-testing.dev](https://atomic-testing.dev).
|