@pie-lib/config-ui 13.0.3 → 13.0.4-next.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/dist/_virtual/_rolldown/runtime.js +11 -0
- package/dist/alert-dialog.d.ts +44 -0
- package/dist/alert-dialog.js +47 -0
- package/dist/checkbox.d.ts +34 -0
- package/dist/checkbox.js +57 -0
- package/dist/choice-configuration/feedback-menu.d.ts +32 -0
- package/dist/choice-configuration/feedback-menu.js +85 -0
- package/dist/choice-configuration/index.d.ts +62 -0
- package/dist/choice-configuration/index.js +240 -0
- package/dist/choice-utils.d.ts +21 -0
- package/dist/choice-utils.js +15 -0
- package/dist/feedback-config/feedback-selector.d.ts +33 -0
- package/dist/feedback-config/feedback-selector.js +92 -0
- package/dist/feedback-config/group.d.ts +21 -0
- package/dist/feedback-config/group.js +33 -0
- package/dist/feedback-config/index.d.ts +48 -0
- package/dist/feedback-config/index.js +96 -0
- package/dist/form-section.d.ts +25 -0
- package/dist/form-section.js +25 -0
- package/dist/help.d.ts +41 -0
- package/dist/help.js +61 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +34 -0
- package/dist/input.d.ts +29 -0
- package/dist/input.js +65 -0
- package/dist/inputs.d.ts +63 -0
- package/dist/inputs.js +70 -0
- package/dist/langs.d.ts +41 -0
- package/dist/langs.js +76 -0
- package/dist/layout/config-layout.d.ts +10 -0
- package/dist/layout/config-layout.js +75 -0
- package/dist/layout/index.d.ts +11 -0
- package/dist/layout/index.js +10 -0
- package/dist/layout/layout-contents.d.ts +21 -0
- package/dist/layout/layout-contents.js +70 -0
- package/dist/layout/settings-box.d.ts +19 -0
- package/dist/layout/settings-box.js +31 -0
- package/dist/mui-box/index.d.ts +21 -0
- package/dist/mui-box/index.js +47 -0
- package/dist/node_modules/.bun/@babel_runtime@7.29.7/node_modules/@babel/runtime/helpers/esm/extends.js +12 -0
- package/dist/node_modules/.bun/@babel_runtime@7.29.7/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js +7 -0
- package/dist/node_modules/.bun/@babel_runtime@7.29.7/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js +12 -0
- package/dist/node_modules/.bun/@babel_runtime@7.29.7/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js +8 -0
- package/dist/node_modules/.bun/react-measure@2.5.2_6dbf9a050bc9aadb/node_modules/react-measure/dist/index.esm.js +122 -0
- package/dist/node_modules/.bun/resize-observer-polyfill@1.5.1/node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js +276 -0
- package/dist/number-text-field-custom.d.ts +51 -0
- package/dist/number-text-field-custom.js +192 -0
- package/dist/number-text-field.d.ts +47 -0
- package/dist/number-text-field.js +122 -0
- package/dist/radio-with-label.d.ts +25 -0
- package/dist/radio-with-label.js +27 -0
- package/dist/settings/display-size.d.ts +26 -0
- package/dist/settings/display-size.js +45 -0
- package/dist/settings/index.d.ts +45 -0
- package/dist/settings/index.js +63 -0
- package/dist/settings/panel.d.ts +27 -0
- package/dist/settings/panel.js +201 -0
- package/dist/settings/settings-radio-label.d.ts +25 -0
- package/dist/settings/settings-radio-label.js +29 -0
- package/dist/settings/toggle.d.ts +25 -0
- package/dist/settings/toggle.js +33 -0
- package/dist/tabs/index.d.ts +22 -0
- package/dist/tabs/index.js +39 -0
- package/dist/tags-input/index.d.ts +21 -0
- package/dist/tags-input/index.js +83 -0
- package/dist/two-choice.d.ts +43 -0
- package/dist/two-choice.js +79 -0
- package/dist/with-stateful-model.d.ts +42 -0
- package/dist/with-stateful-model.js +32 -0
- package/package.json +30 -18
- package/CHANGELOG.json +0 -32
- package/CHANGELOG.md +0 -2419
- package/LICENSE.md +0 -5
- package/lib/alert-dialog.js +0 -68
- package/lib/alert-dialog.js.map +0 -1
- package/lib/checkbox.js +0 -84
- package/lib/checkbox.js.map +0 -1
- package/lib/choice-configuration/feedback-menu.js +0 -129
- package/lib/choice-configuration/feedback-menu.js.map +0 -1
- package/lib/choice-configuration/index.js +0 -381
- package/lib/choice-configuration/index.js.map +0 -1
- package/lib/choice-utils.js +0 -42
- package/lib/choice-utils.js.map +0 -1
- package/lib/feedback-config/feedback-selector.js +0 -155
- package/lib/feedback-config/feedback-selector.js.map +0 -1
- package/lib/feedback-config/group.js +0 -61
- package/lib/feedback-config/group.js.map +0 -1
- package/lib/feedback-config/index.js +0 -146
- package/lib/feedback-config/index.js.map +0 -1
- package/lib/form-section.js +0 -44
- package/lib/form-section.js.map +0 -1
- package/lib/help.js +0 -106
- package/lib/help.js.map +0 -1
- package/lib/index.js +0 -186
- package/lib/index.js.map +0 -1
- package/lib/input.js +0 -106
- package/lib/input.js.map +0 -1
- package/lib/inputs.js +0 -105
- package/lib/inputs.js.map +0 -1
- package/lib/langs.js +0 -136
- package/lib/langs.js.map +0 -1
- package/lib/layout/config-layout.js +0 -137
- package/lib/layout/config-layout.js.map +0 -1
- package/lib/layout/index.js +0 -21
- package/lib/layout/index.js.map +0 -1
- package/lib/layout/layout-contents.js +0 -160
- package/lib/layout/layout-contents.js.map +0 -1
- package/lib/layout/settings-box.js +0 -57
- package/lib/layout/settings-box.js.map +0 -1
- package/lib/mui-box/index.js +0 -63
- package/lib/mui-box/index.js.map +0 -1
- package/lib/number-text-field-custom.js +0 -376
- package/lib/number-text-field-custom.js.map +0 -1
- package/lib/number-text-field.js +0 -229
- package/lib/number-text-field.js.map +0 -1
- package/lib/radio-with-label.js +0 -48
- package/lib/radio-with-label.js.map +0 -1
- package/lib/settings/display-size.js +0 -61
- package/lib/settings/display-size.js.map +0 -1
- package/lib/settings/index.js +0 -110
- package/lib/settings/index.js.map +0 -1
- package/lib/settings/panel.js +0 -392
- package/lib/settings/panel.js.map +0 -1
- package/lib/settings/settings-radio-label.js +0 -51
- package/lib/settings/settings-radio-label.js.map +0 -1
- package/lib/settings/toggle.js +0 -63
- package/lib/settings/toggle.js.map +0 -1
- package/lib/tabs/index.js +0 -75
- package/lib/tabs/index.js.map +0 -1
- package/lib/tags-input/index.js +0 -149
- package/lib/tags-input/index.js.map +0 -1
- package/lib/two-choice.js +0 -136
- package/lib/two-choice.js.map +0 -1
- package/lib/with-stateful-model.js +0 -61
- package/lib/with-stateful-model.js.map +0 -1
- package/src/__tests__/alert-dialog.test.jsx +0 -183
- package/src/__tests__/checkbox.test.jsx +0 -152
- package/src/__tests__/choice-utils.test.js +0 -12
- package/src/__tests__/form-section.test.jsx +0 -328
- package/src/__tests__/help.test.jsx +0 -184
- package/src/__tests__/input.test.jsx +0 -156
- package/src/__tests__/langs.test.jsx +0 -376
- package/src/__tests__/number-text-field-custom.test.jsx +0 -255
- package/src/__tests__/number-text-field.test.jsx +0 -263
- package/src/__tests__/radio-with-label.test.jsx +0 -155
- package/src/__tests__/settings-panel.test.js +0 -187
- package/src/__tests__/settings.test.jsx +0 -452
- package/src/__tests__/tabs.test.jsx +0 -188
- package/src/__tests__/two-choice.test.js +0 -110
- package/src/__tests__/with-stateful-model.test.jsx +0 -139
- package/src/alert-dialog.jsx +0 -75
- package/src/checkbox.jsx +0 -61
- package/src/choice-configuration/__tests__/feedback-menu.test.jsx +0 -151
- package/src/choice-configuration/__tests__/index.test.jsx +0 -234
- package/src/choice-configuration/feedback-menu.jsx +0 -96
- package/src/choice-configuration/index.jsx +0 -357
- package/src/choice-utils.js +0 -30
- package/src/feedback-config/__tests__/feedback-config.test.jsx +0 -141
- package/src/feedback-config/__tests__/feedback-selector.test.jsx +0 -97
- package/src/feedback-config/feedback-selector.jsx +0 -112
- package/src/feedback-config/group.jsx +0 -51
- package/src/feedback-config/index.jsx +0 -111
- package/src/form-section.jsx +0 -31
- package/src/help.jsx +0 -79
- package/src/index.js +0 -55
- package/src/input.jsx +0 -72
- package/src/inputs.jsx +0 -69
- package/src/langs.jsx +0 -111
- package/src/layout/__tests__/config.layout.test.jsx +0 -59
- package/src/layout/__tests__/layout-content.test.jsx +0 -3
- package/src/layout/config-layout.jsx +0 -103
- package/src/layout/index.js +0 -4
- package/src/layout/layout-contents.jsx +0 -117
- package/src/layout/settings-box.jsx +0 -32
- package/src/mui-box/index.jsx +0 -56
- package/src/number-text-field-custom.jsx +0 -333
- package/src/number-text-field.jsx +0 -215
- package/src/radio-with-label.jsx +0 -30
- package/src/settings/display-size.jsx +0 -53
- package/src/settings/index.js +0 -83
- package/src/settings/panel.jsx +0 -333
- package/src/settings/settings-radio-label.jsx +0 -32
- package/src/settings/toggle.jsx +0 -46
- package/src/tabs/index.jsx +0 -47
- package/src/tags-input/__tests__/index.test.jsx +0 -113
- package/src/tags-input/index.jsx +0 -116
- package/src/two-choice.jsx +0 -90
- package/src/with-stateful-model.jsx +0 -36
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import userEvent from '@testing-library/user-event';
|
|
4
|
-
import AlertDialog from '../alert-dialog';
|
|
5
|
-
|
|
6
|
-
describe('AlertDialog Component', () => {
|
|
7
|
-
const onClose = jest.fn();
|
|
8
|
-
const onConfirm = jest.fn();
|
|
9
|
-
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
onClose.mockClear();
|
|
12
|
-
onConfirm.mockClear();
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
describe('Rendering when open', () => {
|
|
16
|
-
it('should render dialog when open is true', () => {
|
|
17
|
-
render(<AlertDialog open={true} title="Confirm" text="Are you sure?" onClose={onClose} onConfirm={onConfirm} />);
|
|
18
|
-
|
|
19
|
-
expect(screen.getByText('Confirm')).toBeInTheDocument();
|
|
20
|
-
expect(screen.getByText('Are you sure?')).toBeInTheDocument();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('should not render dialog when open is false', () => {
|
|
24
|
-
const { container } = render(
|
|
25
|
-
<AlertDialog open={false} title="Confirm" text="Are you sure?" onClose={onClose} onConfirm={onConfirm} />,
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
const dialogs = container.querySelectorAll('[role="dialog"]');
|
|
29
|
-
expect(dialogs.length).toBe(0);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
describe('Title and Text', () => {
|
|
34
|
-
it('should handle both title and text', () => {
|
|
35
|
-
render(
|
|
36
|
-
<AlertDialog
|
|
37
|
-
open={true}
|
|
38
|
-
title="Important"
|
|
39
|
-
text="This is an important message"
|
|
40
|
-
onClose={onClose}
|
|
41
|
-
onConfirm={onConfirm}
|
|
42
|
-
/>,
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
expect(screen.getByText('Important')).toBeInTheDocument();
|
|
46
|
-
expect(screen.getByText('This is an important message')).toBeInTheDocument();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('should handle text as object', () => {
|
|
50
|
-
const textObj = <div>Rich text content</div>;
|
|
51
|
-
render(<AlertDialog open={true} title="Rich Content" text={textObj} onClose={onClose} onConfirm={onConfirm} />);
|
|
52
|
-
|
|
53
|
-
expect(screen.getByText('Rich text content')).toBeInTheDocument();
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
describe('Buttons', () => {
|
|
58
|
-
it('should render close button when onClose is provided', () => {
|
|
59
|
-
render(<AlertDialog open={true} title="Dialog" text="Content" onClose={onClose} onConfirm={onConfirm} />);
|
|
60
|
-
|
|
61
|
-
expect(screen.getByRole('button', { name: 'CANCEL' })).toBeInTheDocument();
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('should render confirm button when onConfirm is provided', () => {
|
|
65
|
-
render(<AlertDialog open={true} title="Dialog" text="Content" onClose={onClose} onConfirm={onConfirm} />);
|
|
66
|
-
|
|
67
|
-
expect(screen.getByRole('button', { name: 'OK' })).toBeInTheDocument();
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('should have default button text', () => {
|
|
71
|
-
render(<AlertDialog open={true} title="Dialog" text="Content" onClose={onClose} onConfirm={onConfirm} />);
|
|
72
|
-
|
|
73
|
-
expect(screen.getByRole('button', { name: 'CANCEL' })).toBeInTheDocument();
|
|
74
|
-
expect(screen.getByRole('button', { name: 'OK' })).toBeInTheDocument();
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
describe('User interactions', () => {
|
|
79
|
-
it('should call onClose when close button is clicked', async () => {
|
|
80
|
-
const user = userEvent.setup();
|
|
81
|
-
render(<AlertDialog open={true} title="Dialog" text="Content" onClose={onClose} onConfirm={onConfirm} />);
|
|
82
|
-
|
|
83
|
-
const closeButton = screen.getByRole('button', { name: 'CANCEL' });
|
|
84
|
-
await user.click(closeButton);
|
|
85
|
-
|
|
86
|
-
expect(onClose).toHaveBeenCalled();
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('should call onConfirm when confirm button is clicked', async () => {
|
|
90
|
-
const user = userEvent.setup();
|
|
91
|
-
render(<AlertDialog open={true} title="Dialog" text="Content" onClose={onClose} onConfirm={onConfirm} />);
|
|
92
|
-
|
|
93
|
-
const confirmButton = screen.getByRole('button', { name: 'OK' });
|
|
94
|
-
await user.click(confirmButton);
|
|
95
|
-
|
|
96
|
-
expect(onConfirm).toHaveBeenCalled();
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
describe('Focus management', () => {
|
|
101
|
-
it('should have autoFocus on confirm button by default', () => {
|
|
102
|
-
render(<AlertDialog open={true} title="Dialog" text="Content" onClose={onClose} onConfirm={onConfirm} />);
|
|
103
|
-
|
|
104
|
-
const confirmButton = screen.getByRole('button', { name: 'OK' });
|
|
105
|
-
expect(confirmButton).toBeInTheDocument();
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('should disable auto focus when disableAutoFocus is true', () => {
|
|
109
|
-
render(
|
|
110
|
-
<AlertDialog
|
|
111
|
-
open={true}
|
|
112
|
-
title="Dialog"
|
|
113
|
-
text="Content"
|
|
114
|
-
onClose={onClose}
|
|
115
|
-
onConfirm={onConfirm}
|
|
116
|
-
disableAutoFocus={true}
|
|
117
|
-
/>,
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
expect(screen.getByText('Dialog')).toBeInTheDocument();
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('should disable enforce focus when disableEnforceFocus is true', () => {
|
|
124
|
-
render(
|
|
125
|
-
<AlertDialog
|
|
126
|
-
open={true}
|
|
127
|
-
title="Dialog"
|
|
128
|
-
text="Content"
|
|
129
|
-
onClose={onClose}
|
|
130
|
-
onConfirm={onConfirm}
|
|
131
|
-
disableEnforceFocus={true}
|
|
132
|
-
/>,
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
expect(screen.getByText('Dialog')).toBeInTheDocument();
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it('should disable restore focus when disableRestoreFocus is true', () => {
|
|
139
|
-
render(
|
|
140
|
-
<AlertDialog
|
|
141
|
-
open={true}
|
|
142
|
-
title="Dialog"
|
|
143
|
-
text="Content"
|
|
144
|
-
onClose={onClose}
|
|
145
|
-
onConfirm={onConfirm}
|
|
146
|
-
disableRestoreFocus={true}
|
|
147
|
-
/>,
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
expect(screen.getByText('Dialog')).toBeInTheDocument();
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
describe('Edge cases', () => {
|
|
155
|
-
it('should handle very long title', () => {
|
|
156
|
-
const longTitle = 'This is a very long title that should wrap properly in the dialog';
|
|
157
|
-
render(<AlertDialog open={true} title={longTitle} text="Content" onClose={onClose} onConfirm={onConfirm} />);
|
|
158
|
-
|
|
159
|
-
expect(screen.getByText(longTitle)).toBeInTheDocument();
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it('should handle very long text', () => {
|
|
163
|
-
const longText = 'This is a very long text that should wrap properly in the dialog. '.repeat(10);
|
|
164
|
-
render(<AlertDialog open={true} title="Dialog" text={longText} onClose={onClose} onConfirm={onConfirm} />);
|
|
165
|
-
|
|
166
|
-
expect(screen.getByText(new RegExp(longText.slice(0, 50)))).toBeInTheDocument();
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it('should handle only close callback', () => {
|
|
170
|
-
render(<AlertDialog open={true} title="Close Only" text="Content" onClose={onClose} />);
|
|
171
|
-
|
|
172
|
-
expect(screen.getByRole('button', { name: 'CANCEL' })).toBeInTheDocument();
|
|
173
|
-
expect(screen.queryByRole('button', { name: 'OK' })).not.toBeInTheDocument();
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it('should handle only confirm callback', () => {
|
|
177
|
-
render(<AlertDialog open={true} title="Confirm Only" text="Content" onConfirm={onConfirm} />);
|
|
178
|
-
|
|
179
|
-
expect(screen.getByRole('button', { name: 'OK' })).toBeInTheDocument();
|
|
180
|
-
expect(screen.queryByRole('button', { name: 'CANCEL' })).not.toBeInTheDocument();
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
});
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import userEvent from '@testing-library/user-event';
|
|
4
|
-
import Checkbox from '../checkbox';
|
|
5
|
-
|
|
6
|
-
describe('Checkbox Component', () => {
|
|
7
|
-
const onChange = jest.fn();
|
|
8
|
-
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
onChange.mockClear();
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
describe('Rendering', () => {
|
|
14
|
-
it('should render checkbox with label', () => {
|
|
15
|
-
render(<Checkbox checked={false} onChange={onChange} label="Accept terms" />);
|
|
16
|
-
|
|
17
|
-
expect(screen.getByText('Accept terms')).toBeInTheDocument();
|
|
18
|
-
expect(screen.getByRole('checkbox')).toBeInTheDocument();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('should render checkbox in checked state', () => {
|
|
22
|
-
render(<Checkbox checked={true} onChange={onChange} label="Accept terms" />);
|
|
23
|
-
|
|
24
|
-
expect(screen.getByRole('checkbox')).toBeChecked();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('should render checkbox in unchecked state', () => {
|
|
28
|
-
render(<Checkbox checked={false} onChange={onChange} label="Accept terms" />);
|
|
29
|
-
|
|
30
|
-
expect(screen.getByRole('checkbox')).not.toBeChecked();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('should render mini checkbox with reduced styling', () => {
|
|
34
|
-
render(<Checkbox checked={false} onChange={onChange} label="Mini" mini={true} />);
|
|
35
|
-
|
|
36
|
-
expect(screen.getByRole('checkbox')).toBeInTheDocument();
|
|
37
|
-
expect(screen.getByText('Mini')).toBeInTheDocument();
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
describe('User interaction', () => {
|
|
42
|
-
it('should call onChange when checkbox is clicked', async () => {
|
|
43
|
-
const user = userEvent.setup();
|
|
44
|
-
render(<Checkbox checked={false} onChange={onChange} label="Accept" />);
|
|
45
|
-
|
|
46
|
-
const checkbox = screen.getByRole('checkbox');
|
|
47
|
-
await user.click(checkbox);
|
|
48
|
-
|
|
49
|
-
expect(onChange).toHaveBeenCalled();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('should call onChange when label is clicked', async () => {
|
|
53
|
-
const user = userEvent.setup();
|
|
54
|
-
render(<Checkbox checked={false} onChange={onChange} label="Click label" />);
|
|
55
|
-
|
|
56
|
-
const label = screen.getByText('Click label');
|
|
57
|
-
await user.click(label);
|
|
58
|
-
|
|
59
|
-
expect(onChange).toHaveBeenCalled();
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
describe('Props', () => {
|
|
64
|
-
it('should handle value prop', () => {
|
|
65
|
-
render(<Checkbox checked={true} onChange={onChange} label="With value" value="option1" />);
|
|
66
|
-
|
|
67
|
-
expect(screen.getByRole('checkbox')).toBeInTheDocument();
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('should display error styling when error is true', () => {
|
|
71
|
-
render(<Checkbox checked={false} onChange={onChange} label="Error state" error={true} />);
|
|
72
|
-
|
|
73
|
-
expect(screen.getByRole('checkbox')).toBeInTheDocument();
|
|
74
|
-
expect(screen.getByText('Error state')).toBeInTheDocument();
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
describe('Default props', () => {
|
|
79
|
-
it('should have mini default to false', () => {
|
|
80
|
-
const { container } = render(<Checkbox checked={true} onChange={onChange} label="Test" />);
|
|
81
|
-
|
|
82
|
-
expect(screen.getByRole('checkbox')).toBeInTheDocument();
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('should have error default to false', () => {
|
|
86
|
-
const { container } = render(<Checkbox checked={true} onChange={onChange} label="Test" />);
|
|
87
|
-
|
|
88
|
-
expect(screen.getByRole('checkbox')).toBeInTheDocument();
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('should have value default to empty string', () => {
|
|
92
|
-
render(<Checkbox checked={true} onChange={onChange} label="Test" />);
|
|
93
|
-
|
|
94
|
-
expect(screen.getByRole('checkbox')).toBeInTheDocument();
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
describe('Accessibility', () => {
|
|
99
|
-
it('should have proper label association', () => {
|
|
100
|
-
render(<Checkbox checked={false} onChange={onChange} label="Accessible label" />);
|
|
101
|
-
|
|
102
|
-
expect(screen.getByLabelText('Accessible label')).toBeInTheDocument();
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('should be keyboard accessible', async () => {
|
|
106
|
-
const user = userEvent.setup();
|
|
107
|
-
render(<Checkbox checked={false} onChange={onChange} label="Keyboard test" />);
|
|
108
|
-
|
|
109
|
-
const checkbox = screen.getByRole('checkbox');
|
|
110
|
-
checkbox.focus();
|
|
111
|
-
expect(checkbox).toHaveFocus();
|
|
112
|
-
|
|
113
|
-
await user.keyboard(' ');
|
|
114
|
-
expect(onChange).toHaveBeenCalled();
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
describe('Multiple checkboxes', () => {
|
|
119
|
-
it('should render multiple independent checkboxes', () => {
|
|
120
|
-
const onChange1 = jest.fn();
|
|
121
|
-
const onChange2 = jest.fn();
|
|
122
|
-
|
|
123
|
-
render(
|
|
124
|
-
<>
|
|
125
|
-
<Checkbox checked={true} onChange={onChange1} label="Option 1" />
|
|
126
|
-
<Checkbox checked={false} onChange={onChange2} label="Option 2" />
|
|
127
|
-
</>,
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
expect(screen.getByLabelText('Option 1')).toBeChecked();
|
|
131
|
-
expect(screen.getByLabelText('Option 2')).not.toBeChecked();
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it('should handle independent onChange callbacks', async () => {
|
|
135
|
-
const user = userEvent.setup();
|
|
136
|
-
const onChange1 = jest.fn();
|
|
137
|
-
const onChange2 = jest.fn();
|
|
138
|
-
|
|
139
|
-
render(
|
|
140
|
-
<>
|
|
141
|
-
<Checkbox checked={true} onChange={onChange1} label="Option 1" />
|
|
142
|
-
<Checkbox checked={false} onChange={onChange2} label="Option 2" />
|
|
143
|
-
</>,
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
await user.click(screen.getByLabelText('Option 2'));
|
|
147
|
-
|
|
148
|
-
expect(onChange2).toHaveBeenCalled();
|
|
149
|
-
expect(onChange1).not.toHaveBeenCalled();
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { firstAvailableIndex } from '../choice-utils';
|
|
2
|
-
|
|
3
|
-
describe('firstAvailableIndex', () => {
|
|
4
|
-
const assert = (values, index, expected) => {
|
|
5
|
-
it(`[${values.join(',')}], ${index} ==> ${expected}`, () => {
|
|
6
|
-
expect(firstAvailableIndex(['0'], 0)).toEqual('1');
|
|
7
|
-
});
|
|
8
|
-
};
|
|
9
|
-
assert(['0'], 0, '1');
|
|
10
|
-
assert(['0', '1', '2'], 0, '3');
|
|
11
|
-
assert(['0', '1', '2'], 100, '100');
|
|
12
|
-
});
|
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import FormSection from '../form-section';
|
|
4
|
-
|
|
5
|
-
describe('FormSection Component', () => {
|
|
6
|
-
describe('Rendering', () => {
|
|
7
|
-
it('should render with label and children', () => {
|
|
8
|
-
render(
|
|
9
|
-
<FormSection label="Settings">
|
|
10
|
-
<div>Child content</div>
|
|
11
|
-
</FormSection>,
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
expect(screen.getByText('Settings')).toBeInTheDocument();
|
|
15
|
-
expect(screen.getByText('Child content')).toBeInTheDocument();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('should render label as subtitle1 typography', () => {
|
|
19
|
-
const { container } = render(
|
|
20
|
-
<FormSection label="Configuration">
|
|
21
|
-
<div>Content</div>
|
|
22
|
-
</FormSection>,
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
const typography = container.querySelector('[class*="MuiTypography"]');
|
|
26
|
-
expect(typography).toBeInTheDocument();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('should render with custom className', () => {
|
|
30
|
-
const { container } = render(
|
|
31
|
-
<FormSection label="Custom" className="custom-class">
|
|
32
|
-
<div>Content</div>
|
|
33
|
-
</FormSection>,
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
expect(container.querySelector('.custom-class')).toBeInTheDocument();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('should render multiple children', () => {
|
|
40
|
-
render(
|
|
41
|
-
<FormSection label="Multiple Children">
|
|
42
|
-
<div>First child</div>
|
|
43
|
-
<div>Second child</div>
|
|
44
|
-
<div>Third child</div>
|
|
45
|
-
</FormSection>,
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
expect(screen.getByText('First child')).toBeInTheDocument();
|
|
49
|
-
expect(screen.getByText('Second child')).toBeInTheDocument();
|
|
50
|
-
expect(screen.getByText('Third child')).toBeInTheDocument();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('should render with single child', () => {
|
|
54
|
-
render(
|
|
55
|
-
<FormSection label="Single Child">
|
|
56
|
-
<input type="text" placeholder="Input" />
|
|
57
|
-
</FormSection>,
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
expect(screen.getByPlaceholderText('Input')).toBeInTheDocument();
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('should render with complex child components', () => {
|
|
64
|
-
render(
|
|
65
|
-
<FormSection label="Complex">
|
|
66
|
-
<div>
|
|
67
|
-
<label>Name:</label>
|
|
68
|
-
<input type="text" placeholder="Enter name" />
|
|
69
|
-
</div>
|
|
70
|
-
<div>
|
|
71
|
-
<label>Email:</label>
|
|
72
|
-
<input type="email" placeholder="Enter email" />
|
|
73
|
-
</div>
|
|
74
|
-
</FormSection>,
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
expect(screen.getByPlaceholderText('Enter name')).toBeInTheDocument();
|
|
78
|
-
expect(screen.getByPlaceholderText('Enter email')).toBeInTheDocument();
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
describe('Labels', () => {
|
|
83
|
-
it('should display different labels', () => {
|
|
84
|
-
const { rerender } = render(
|
|
85
|
-
<FormSection label="First Label">
|
|
86
|
-
<div>Content</div>
|
|
87
|
-
</FormSection>,
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
expect(screen.getByText('First Label')).toBeInTheDocument();
|
|
91
|
-
|
|
92
|
-
rerender(
|
|
93
|
-
<FormSection label="Second Label">
|
|
94
|
-
<div>Content</div>
|
|
95
|
-
</FormSection>,
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
expect(screen.getByText('Second Label')).toBeInTheDocument();
|
|
99
|
-
expect(screen.queryByText('First Label')).not.toBeInTheDocument();
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('should handle empty label', () => {
|
|
103
|
-
const { container } = render(
|
|
104
|
-
<FormSection label="">
|
|
105
|
-
<div>Content</div>
|
|
106
|
-
</FormSection>,
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
expect(container.querySelector('[class*="MuiTypography"]')).toBeInTheDocument();
|
|
110
|
-
expect(screen.getByText('Content')).toBeInTheDocument();
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('should handle long labels', () => {
|
|
114
|
-
const longLabel = 'This is a very long label that should wrap properly within the form section';
|
|
115
|
-
render(
|
|
116
|
-
<FormSection label={longLabel}>
|
|
117
|
-
<div>Content</div>
|
|
118
|
-
</FormSection>,
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
expect(screen.getByText(longLabel)).toBeInTheDocument();
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('should handle special characters in labels', () => {
|
|
125
|
-
const specialLabel = 'Settings & Configuration < Advanced > Test @ #1';
|
|
126
|
-
render(
|
|
127
|
-
<FormSection label={specialLabel}>
|
|
128
|
-
<div>Content</div>
|
|
129
|
-
</FormSection>,
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
expect(screen.getByText(specialLabel)).toBeInTheDocument();
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
describe('Styling and Layout', () => {
|
|
137
|
-
it('should apply default spacing', () => {
|
|
138
|
-
const { container } = render(
|
|
139
|
-
<FormSection label="Spaced">
|
|
140
|
-
<div>Content</div>
|
|
141
|
-
</FormSection>,
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
const formSection = container.querySelector('[class*="MuiBox"], div');
|
|
145
|
-
expect(formSection).toBeInTheDocument();
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it('should apply labelExtraStyle to the label', () => {
|
|
149
|
-
const { container } = render(
|
|
150
|
-
<FormSection label="Styled Label" labelExtraStyle={{ color: 'red', fontWeight: 'bold' }}>
|
|
151
|
-
<div>Content</div>
|
|
152
|
-
</FormSection>,
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
const typography = container.querySelector('[class*="MuiTypography"]');
|
|
156
|
-
expect(typography).toHaveStyle('color: red');
|
|
157
|
-
expect(typography).toHaveStyle('fontWeight: bold');
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it('should apply multiple labelExtraStyle properties', () => {
|
|
161
|
-
const extraStyle = {
|
|
162
|
-
fontSize: '18px',
|
|
163
|
-
margin: '10px',
|
|
164
|
-
padding: '5px',
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
const { container } = render(
|
|
168
|
-
<FormSection label="Multi-styled" labelExtraStyle={extraStyle}>
|
|
169
|
-
<div>Content</div>
|
|
170
|
-
</FormSection>,
|
|
171
|
-
);
|
|
172
|
-
|
|
173
|
-
const typography = container.querySelector('[class*="MuiTypography"]');
|
|
174
|
-
expect(typography).toHaveStyle('fontSize: 18px');
|
|
175
|
-
expect(typography).toHaveStyle('margin: 10px');
|
|
176
|
-
expect(typography).toHaveStyle('padding: 5px');
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it('should handle no labelExtraStyle', () => {
|
|
180
|
-
const { container } = render(
|
|
181
|
-
<FormSection label="No Extra Style">
|
|
182
|
-
<div>Content</div>
|
|
183
|
-
</FormSection>,
|
|
184
|
-
);
|
|
185
|
-
|
|
186
|
-
expect(container.querySelector('[class*="MuiTypography"]')).toBeInTheDocument();
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
describe('CSS classes', () => {
|
|
191
|
-
it('should support multiple custom classes', () => {
|
|
192
|
-
const { container } = render(
|
|
193
|
-
<FormSection label="Test" className="class1 class2 class3">
|
|
194
|
-
<div>Content</div>
|
|
195
|
-
</FormSection>,
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
const element = container.querySelector('.class1.class2.class3');
|
|
199
|
-
expect(element).toBeInTheDocument();
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
it('should work without custom className', () => {
|
|
203
|
-
const { container } = render(
|
|
204
|
-
<FormSection label="Test">
|
|
205
|
-
<div>Content</div>
|
|
206
|
-
</FormSection>,
|
|
207
|
-
);
|
|
208
|
-
|
|
209
|
-
expect(container.firstChild).toBeInTheDocument();
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
describe('Content variations', () => {
|
|
214
|
-
it('should render form inputs as children', () => {
|
|
215
|
-
render(
|
|
216
|
-
<FormSection label="Form Inputs">
|
|
217
|
-
<input type="text" placeholder="Text input" />
|
|
218
|
-
<input type="number" placeholder="Number input" />
|
|
219
|
-
<textarea placeholder="Text area"></textarea>
|
|
220
|
-
</FormSection>,
|
|
221
|
-
);
|
|
222
|
-
|
|
223
|
-
expect(screen.getByPlaceholderText('Text input')).toBeInTheDocument();
|
|
224
|
-
expect(screen.getByPlaceholderText('Number input')).toBeInTheDocument();
|
|
225
|
-
expect(screen.getByPlaceholderText('Text area')).toBeInTheDocument();
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
it('should render lists as children', () => {
|
|
229
|
-
render(
|
|
230
|
-
<FormSection label="Options">
|
|
231
|
-
<ul>
|
|
232
|
-
<li>Option 1</li>
|
|
233
|
-
<li>Option 2</li>
|
|
234
|
-
<li>Option 3</li>
|
|
235
|
-
</ul>
|
|
236
|
-
</FormSection>,
|
|
237
|
-
);
|
|
238
|
-
|
|
239
|
-
expect(screen.getByText('Option 1')).toBeInTheDocument();
|
|
240
|
-
expect(screen.getByText('Option 2')).toBeInTheDocument();
|
|
241
|
-
expect(screen.getByText('Option 3')).toBeInTheDocument();
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
it('should render buttons as children', () => {
|
|
245
|
-
render(
|
|
246
|
-
<FormSection label="Actions">
|
|
247
|
-
<button>Save</button>
|
|
248
|
-
<button>Cancel</button>
|
|
249
|
-
</FormSection>,
|
|
250
|
-
);
|
|
251
|
-
|
|
252
|
-
expect(screen.getByRole('button', { name: 'Save' })).toBeInTheDocument();
|
|
253
|
-
expect(screen.getByRole('button', { name: 'Cancel' })).toBeInTheDocument();
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
it('should render nested form sections', () => {
|
|
257
|
-
render(
|
|
258
|
-
<FormSection label="Outer">
|
|
259
|
-
<FormSection label="Inner">
|
|
260
|
-
<div>Nested content</div>
|
|
261
|
-
</FormSection>
|
|
262
|
-
</FormSection>,
|
|
263
|
-
);
|
|
264
|
-
|
|
265
|
-
expect(screen.getByText('Outer')).toBeInTheDocument();
|
|
266
|
-
expect(screen.getByText('Inner')).toBeInTheDocument();
|
|
267
|
-
expect(screen.getByText('Nested content')).toBeInTheDocument();
|
|
268
|
-
});
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
describe('Edge cases', () => {
|
|
272
|
-
it('should render with conditional children', () => {
|
|
273
|
-
const showContent = true;
|
|
274
|
-
|
|
275
|
-
render(
|
|
276
|
-
<FormSection label="Conditional">
|
|
277
|
-
{showContent && <div>Visible</div>}
|
|
278
|
-
{!showContent && <div>Hidden</div>}
|
|
279
|
-
</FormSection>,
|
|
280
|
-
);
|
|
281
|
-
|
|
282
|
-
expect(screen.getByText('Visible')).toBeInTheDocument();
|
|
283
|
-
expect(screen.queryByText('Hidden')).not.toBeInTheDocument();
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
it('should update when children change', () => {
|
|
287
|
-
const { rerender } = render(
|
|
288
|
-
<FormSection label="Dynamic">
|
|
289
|
-
<div>Initial content</div>
|
|
290
|
-
</FormSection>,
|
|
291
|
-
);
|
|
292
|
-
|
|
293
|
-
expect(screen.getByText('Initial content')).toBeInTheDocument();
|
|
294
|
-
|
|
295
|
-
rerender(
|
|
296
|
-
<FormSection label="Dynamic">
|
|
297
|
-
<div>Updated content</div>
|
|
298
|
-
</FormSection>,
|
|
299
|
-
);
|
|
300
|
-
|
|
301
|
-
expect(screen.queryByText('Initial content')).not.toBeInTheDocument();
|
|
302
|
-
expect(screen.getByText('Updated content')).toBeInTheDocument();
|
|
303
|
-
});
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
describe('Accessibility', () => {
|
|
307
|
-
it('should have proper heading hierarchy', () => {
|
|
308
|
-
const { container } = render(
|
|
309
|
-
<FormSection label="Accessible Section">
|
|
310
|
-
<div>Content</div>
|
|
311
|
-
</FormSection>,
|
|
312
|
-
);
|
|
313
|
-
|
|
314
|
-
const typography = container.querySelector('[class*="MuiTypography"]');
|
|
315
|
-
expect(typography).toBeInTheDocument();
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
it('should be properly semantically structured', () => {
|
|
319
|
-
const { container } = render(
|
|
320
|
-
<FormSection label="Semantic">
|
|
321
|
-
<input type="text" />
|
|
322
|
-
</FormSection>,
|
|
323
|
-
);
|
|
324
|
-
|
|
325
|
-
expect(container.querySelector('div')).toBeInTheDocument();
|
|
326
|
-
});
|
|
327
|
-
});
|
|
328
|
-
});
|