@woosmap/ui 2.39.0 → 2.43.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/package.json +1 -1
- package/src/components/Button/Button.js +4 -0
- package/src/components/Button/Button.stories.js +1 -1
- package/src/components/Button/Button.test.js +3 -3
- package/src/components/Button/ButtonGroup.js +4 -1
- package/src/components/Button/ButtonSwitch.js +4 -2
- package/src/components/Button/ButtonWithDropdown.js +22 -8
- package/src/components/Button/ButtonWithDropdown.test.js +35 -0
- package/src/components/Card/Card.js +5 -0
- package/src/components/Card/Card.test.js +3 -3
- package/src/components/Card/SimpleCard.js +25 -5
- package/src/components/Card/SimpleCard.test.js +2 -2
- package/src/components/CopyClipboardButton/CopyClipboardButton.js +4 -1
- package/src/components/CopyClipboardButton/CopyToClipboard.test.js +2 -2
- package/src/components/Demo/SearchDemo.js +1 -0
- package/src/components/Dropdown/Dropdown.js +30 -5
- package/src/components/Dropdown/Dropdown.test.js +2 -2
- package/src/components/DynamicTag/DynamicTag.js +8 -4
- package/src/components/Flash/Flash.js +4 -1
- package/src/components/Icon/Icon.js +45 -21
- package/src/components/Icon/Icon.test.js +4 -4
- package/src/components/InfoMessage/InfoMessage.js +5 -2
- package/src/components/InfoMessage/InfoMessage.test.js +2 -2
- package/src/components/Input/Input.test.js +26 -0
- package/src/components/Label/Label.js +18 -3
- package/src/components/Label/Label.styl +1 -1
- package/src/components/Modal/ConfirmationModal.js +4 -1
- package/src/components/Modal/Modal.js +13 -6
- package/src/components/Modal/Modal.test.js +3 -3
- package/src/components/Panel/Panel.js +5 -3
- package/src/components/Panel/Panel.test.js +2 -2
- package/src/components/Popover/ConfirmationPopover.js +5 -3
- package/src/components/ScrollBar/ScrollBar.js +4 -1
- package/src/components/ScrollBar/ScrollBar.test.js +2 -2
- package/src/components/ServiceMessage/ServiceMessage.js +8 -4
- package/src/components/SnackBar/SnackBar.test.js +2 -2
- package/src/components/Tab/Tab.js +6 -3
- package/src/components/Tab/Tab.test.js +9 -9
- package/src/components/Tooltip/Tooltip.js +4 -2
- package/src/components/Tooltip/Tooltip.test.js +4 -4
- package/src/components/withFormValidation/withFormValidation.test.js +1 -5
- package/src/icons/autocomplete.svg +1 -0
- package/src/icons/buildings.svg +1 -0
- package/src/icons/github.svg +1 -0
- package/src/icons/position.svg +1 -0
- package/src/icons/quote.svg +1 -0
- package/src/icons/save-money.svg +1 -0
- package/src/icons/world.svg +1 -0
- package/src/styles/console/button.styl +69 -43
- package/src/styles/console/mixins.styl +2 -2
- package/src/styles/console/select.styl +0 -1
- package/src/styles/style-next-website.styl +25 -0
|
@@ -5,7 +5,7 @@ import Icon from '../Icon/Icon';
|
|
|
5
5
|
|
|
6
6
|
export default class Flash extends Component {
|
|
7
7
|
render() {
|
|
8
|
-
const { children, icon, inverse, fill, type, shadowed, ...rest } = this.props;
|
|
8
|
+
const { children, icon, inverse, fill, type, shadowed, testId, ...rest } = this.props;
|
|
9
9
|
const iconComponent = icon ? <Icon size={24} icon={icon} /> : null;
|
|
10
10
|
return (
|
|
11
11
|
<div
|
|
@@ -17,6 +17,7 @@ export default class Flash extends Component {
|
|
|
17
17
|
{ 'flash--fill': fill },
|
|
18
18
|
{ 'flash--shadowed': shadowed && !inverse }
|
|
19
19
|
)}
|
|
20
|
+
data-testid={testId}
|
|
20
21
|
{...rest}
|
|
21
22
|
>
|
|
22
23
|
{iconComponent}
|
|
@@ -32,6 +33,7 @@ Flash.defaultProps = {
|
|
|
32
33
|
inverse: false,
|
|
33
34
|
fill: false,
|
|
34
35
|
shadowed: false,
|
|
36
|
+
testId: 'flash',
|
|
35
37
|
};
|
|
36
38
|
|
|
37
39
|
Flash.propTypes = {
|
|
@@ -41,4 +43,5 @@ Flash.propTypes = {
|
|
|
41
43
|
inverse: PropTypes.bool,
|
|
42
44
|
fill: PropTypes.bool,
|
|
43
45
|
shadowed: PropTypes.bool,
|
|
46
|
+
testId: PropTypes.string,
|
|
44
47
|
};
|
|
@@ -19,10 +19,12 @@ import { ReactComponent as ArrowTop } from '../../icons/arrow-top.svg';
|
|
|
19
19
|
import { ReactComponent as Asset } from '../../icons/asset.svg';
|
|
20
20
|
import { ReactComponent as AssetAddFile } from '../../icons/asset-add-file.svg';
|
|
21
21
|
import { ReactComponent as AssetAdd } from '../../icons/asset-add.svg';
|
|
22
|
+
import { ReactComponent as Autocomplete } from '../../icons/autocomplete.svg';
|
|
22
23
|
import { ReactComponent as Bank } from '../../icons/bank.svg';
|
|
23
24
|
import { ReactComponent as Beaker } from '../../icons/beaker.svg';
|
|
24
25
|
import { ReactComponent as Bell } from '../../icons/bell.svg';
|
|
25
26
|
import { ReactComponent as Bookmark } from '../../icons/bookmark.svg';
|
|
27
|
+
import { ReactComponent as Buildings } from '../../icons/buildings.svg';
|
|
26
28
|
import { ReactComponent as Bulb } from '../../icons/bulb.svg';
|
|
27
29
|
import { ReactComponent as CaretBotton } from '../../icons/caret-bottom.svg';
|
|
28
30
|
import { ReactComponent as CaretLeft } from '../../icons/caret-left.svg';
|
|
@@ -54,6 +56,7 @@ import { ReactComponent as Exchange } from '../../icons/exchange.svg';
|
|
|
54
56
|
import { ReactComponent as Expand } from '../../icons/expand.svg';
|
|
55
57
|
import { ReactComponent as Export } from '../../icons/export.svg';
|
|
56
58
|
import { ReactComponent as Flag } from '../../icons/flag.svg';
|
|
59
|
+
import { ReactComponent as Github } from '../../icons/github.svg';
|
|
57
60
|
import { ReactComponent as Globe } from '../../icons/globe.svg';
|
|
58
61
|
import { ReactComponent as Home } from '../../icons/home.svg';
|
|
59
62
|
import { ReactComponent as HomeUser } from '../../icons/home-user.svg';
|
|
@@ -75,17 +78,25 @@ import { ReactComponent as Organization } from '../../icons/organization.svg';
|
|
|
75
78
|
import { ReactComponent as Organizations } from '../../icons/organizations.svg';
|
|
76
79
|
import { ReactComponent as Phone } from '../../icons/phone.svg';
|
|
77
80
|
import { ReactComponent as Platform } from '../../icons/platform.svg';
|
|
81
|
+
import { ReactComponent as Position } from '../../icons/position.svg';
|
|
78
82
|
import { ReactComponent as ProductActivated } from '../../icons/product-activated.svg';
|
|
79
83
|
import { ReactComponent as ProductAdd } from '../../icons/product-add.svg';
|
|
80
84
|
import { ReactComponent as Products } from '../../icons/products.svg';
|
|
81
85
|
import { ReactComponent as Projects } from '../../icons/projects.svg';
|
|
82
86
|
import { ReactComponent as Puzzle } from '../../icons/puzzle.svg';
|
|
83
87
|
import { ReactComponent as Question } from '../../icons/question.svg';
|
|
88
|
+
import { ReactComponent as Quote } from '../../icons/quote.svg';
|
|
84
89
|
import { ReactComponent as Receipt } from '../../icons/receipt.svg';
|
|
90
|
+
import { ReactComponent as SaveMoney } from '../../icons/save-money.svg';
|
|
85
91
|
import { ReactComponent as Search } from '../../icons/search.svg';
|
|
86
92
|
import { ReactComponent as SeePage } from '../../icons/see-page.svg';
|
|
87
93
|
import { ReactComponent as Settings } from '../../icons/settings.svg';
|
|
88
94
|
import { ReactComponent as Shield } from '../../icons/shield.svg';
|
|
95
|
+
import { ReactComponent as Star } from '../../icons/star.svg';
|
|
96
|
+
import { ReactComponent as StarFilled } from '../../icons/star-filled.svg';
|
|
97
|
+
import { ReactComponent as Stores } from '../../icons/stores.svg';
|
|
98
|
+
import { ReactComponent as Support } from '../../icons/support.svg';
|
|
99
|
+
import { ReactComponent as Switch } from '../../icons/switch.svg';
|
|
89
100
|
import { ReactComponent as Team } from '../../icons/team.svg';
|
|
90
101
|
import { ReactComponent as Time } from '../../icons/time.svg';
|
|
91
102
|
import { ReactComponent as Tool } from '../../icons/tool.svg';
|
|
@@ -95,18 +106,14 @@ import { ReactComponent as ViewList } from '../../icons/view-list.svg';
|
|
|
95
106
|
import { ReactComponent as ViewMiniCard } from '../../icons/view-mini-card.svg';
|
|
96
107
|
import { ReactComponent as Warning } from '../../icons/warning.svg';
|
|
97
108
|
import { ReactComponent as Woosmap } from '../../icons/woosmap.svg';
|
|
98
|
-
import { ReactComponent as
|
|
99
|
-
import { ReactComponent as
|
|
100
|
-
import { ReactComponent as Map } from '../../icons/map.svg';
|
|
109
|
+
import { ReactComponent as World } from '../../icons/world.svg';
|
|
110
|
+
import { ReactComponent as Address } from '../../icons/address.svg';
|
|
101
111
|
import { ReactComponent as Distance } from '../../icons/distance.svg';
|
|
102
112
|
import { ReactComponent as Geolocation } from '../../icons/geolocation.svg';
|
|
103
|
-
import { ReactComponent as
|
|
104
|
-
import { ReactComponent as
|
|
105
|
-
import { ReactComponent as StarFilled } from '../../icons/star-filled.svg';
|
|
106
|
-
import { ReactComponent as Stores } from '../../icons/stores.svg';
|
|
107
|
-
import { ReactComponent as Support } from '../../icons/support.svg';
|
|
108
|
-
import { ReactComponent as Switch } from '../../icons/switch.svg';
|
|
113
|
+
import { ReactComponent as Localities } from '../../icons/localities.svg';
|
|
114
|
+
import { ReactComponent as Map } from '../../icons/map.svg';
|
|
109
115
|
import { ReactComponent as Merchant } from '../../icons/merchant.svg';
|
|
116
|
+
import { ReactComponent as Traffic } from '../../icons/traffic.svg';
|
|
110
117
|
|
|
111
118
|
const Icons = {
|
|
112
119
|
access: Access,
|
|
@@ -127,10 +134,12 @@ const Icons = {
|
|
|
127
134
|
asset: Asset,
|
|
128
135
|
'asset-add-file': AssetAddFile,
|
|
129
136
|
'asset-add': AssetAdd,
|
|
137
|
+
autocomplete: Autocomplete,
|
|
130
138
|
bank: Bank,
|
|
131
139
|
beaker: Beaker,
|
|
132
140
|
bell: Bell,
|
|
133
141
|
bookmark: Bookmark,
|
|
142
|
+
buildings: Buildings,
|
|
134
143
|
bulb: Bulb,
|
|
135
144
|
'caret-bottom': CaretBotton,
|
|
136
145
|
'caret-left': CaretLeft,
|
|
@@ -163,6 +172,7 @@ const Icons = {
|
|
|
163
172
|
export: Export,
|
|
164
173
|
flag: Flag,
|
|
165
174
|
globe: Globe,
|
|
175
|
+
github: Github,
|
|
166
176
|
home: Home,
|
|
167
177
|
'home-user': HomeUser,
|
|
168
178
|
import: Import,
|
|
@@ -183,17 +193,25 @@ const Icons = {
|
|
|
183
193
|
organizations: Organizations,
|
|
184
194
|
phone: Phone,
|
|
185
195
|
platform: Platform,
|
|
196
|
+
position: Position,
|
|
186
197
|
'product-activated': ProductActivated,
|
|
187
198
|
'product-add': ProductAdd,
|
|
188
199
|
products: Products,
|
|
189
200
|
projects: Projects,
|
|
190
201
|
puzzle: Puzzle,
|
|
191
|
-
receipt: Receipt,
|
|
192
202
|
question: Question,
|
|
203
|
+
quote: Quote,
|
|
204
|
+
receipt: Receipt,
|
|
205
|
+
'save-money': SaveMoney,
|
|
193
206
|
search: Search,
|
|
194
207
|
'see-page': SeePage,
|
|
195
208
|
settings: Settings,
|
|
196
209
|
shield: Shield,
|
|
210
|
+
star: Star,
|
|
211
|
+
'star-filled': StarFilled,
|
|
212
|
+
stores: Stores,
|
|
213
|
+
support: Support,
|
|
214
|
+
switch: Switch,
|
|
197
215
|
team: Team,
|
|
198
216
|
time: Time,
|
|
199
217
|
tool: Tool,
|
|
@@ -203,25 +221,29 @@ const Icons = {
|
|
|
203
221
|
'view-mini-card': ViewMiniCard,
|
|
204
222
|
warning: Warning,
|
|
205
223
|
woosmap: Woosmap,
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
maps: Map,
|
|
224
|
+
world: World,
|
|
225
|
+
address: Address,
|
|
209
226
|
distance: Distance,
|
|
210
227
|
geolocation: Geolocation,
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
'star-filled': StarFilled,
|
|
214
|
-
stores: Stores,
|
|
215
|
-
support: Support,
|
|
216
|
-
switch: Switch,
|
|
228
|
+
localities: Localities,
|
|
229
|
+
maps: Map,
|
|
217
230
|
merchant: Merchant,
|
|
231
|
+
traffic: Traffic,
|
|
218
232
|
};
|
|
219
233
|
|
|
220
234
|
class Icon extends Component {
|
|
221
235
|
render() {
|
|
222
|
-
const { icon, size, className, title } = this.props;
|
|
236
|
+
const { icon, size, className, title, testId } = this.props;
|
|
223
237
|
const IconComponent = Icons[icon];
|
|
224
|
-
return
|
|
238
|
+
return (
|
|
239
|
+
<IconComponent
|
|
240
|
+
className={cl('icon', className)}
|
|
241
|
+
data-testid={testId}
|
|
242
|
+
width={size}
|
|
243
|
+
height={size}
|
|
244
|
+
title={title}
|
|
245
|
+
/>
|
|
246
|
+
);
|
|
225
247
|
}
|
|
226
248
|
}
|
|
227
249
|
|
|
@@ -229,6 +251,7 @@ Icon.defaultProps = {
|
|
|
229
251
|
size: 24,
|
|
230
252
|
className: null,
|
|
231
253
|
title: null,
|
|
254
|
+
testId: 'icon',
|
|
232
255
|
};
|
|
233
256
|
|
|
234
257
|
Icon.propTypes = {
|
|
@@ -236,6 +259,7 @@ Icon.propTypes = {
|
|
|
236
259
|
className: PropTypes.string,
|
|
237
260
|
icon: PropTypes.string.isRequired,
|
|
238
261
|
title: PropTypes.string,
|
|
262
|
+
testId: PropTypes.string,
|
|
239
263
|
};
|
|
240
264
|
export default Object.assign(Icon, {
|
|
241
265
|
Icons,
|
|
@@ -5,10 +5,10 @@ import '@testing-library/jest-dom/extend-expect';
|
|
|
5
5
|
import Icon from './Icon';
|
|
6
6
|
|
|
7
7
|
it('renders an icon component', () => {
|
|
8
|
-
const {
|
|
9
|
-
expect(
|
|
10
|
-
expect(
|
|
11
|
-
expect(
|
|
8
|
+
const { getByTestId } = render(<Icon icon="home" size={64} />);
|
|
9
|
+
expect(getByTestId('icon')).toHaveClass('icon');
|
|
10
|
+
expect(getByTestId('icon')).toHaveAttribute('width', '64');
|
|
11
|
+
expect(getByTestId('icon')).toHaveTextContent('home');
|
|
12
12
|
});
|
|
13
13
|
/*
|
|
14
14
|
it('renders all icon components', () => {
|
|
@@ -10,7 +10,7 @@ export default class InfoMessage extends Component {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
render() {
|
|
13
|
-
const { modalProps, actionLabel, children, ...rest } = this.props;
|
|
13
|
+
const { modalProps, actionLabel, children, testId, ...rest } = this.props;
|
|
14
14
|
return (
|
|
15
15
|
<>
|
|
16
16
|
<Button
|
|
@@ -19,8 +19,9 @@ export default class InfoMessage extends Component {
|
|
|
19
19
|
type="link-flex-info"
|
|
20
20
|
{...rest}
|
|
21
21
|
onClick={() => this.modalRef.current.open()}
|
|
22
|
+
testId={`${testId}-button`}
|
|
22
23
|
/>
|
|
23
|
-
<Modal ref={this.modalRef} footer={false} {...modalProps}>
|
|
24
|
+
<Modal ref={this.modalRef} footer={false} testId={`${testId}-modal`} {...modalProps}>
|
|
24
25
|
{children}
|
|
25
26
|
</Modal>
|
|
26
27
|
</>
|
|
@@ -30,8 +31,10 @@ export default class InfoMessage extends Component {
|
|
|
30
31
|
InfoMessage.defaultProps = {
|
|
31
32
|
actionLabel: '',
|
|
32
33
|
modalProps: {},
|
|
34
|
+
testId: 'info-message',
|
|
33
35
|
};
|
|
34
36
|
InfoMessage.propTypes = {
|
|
37
|
+
testId: PropTypes.string,
|
|
35
38
|
children: PropTypes.node.isRequired,
|
|
36
39
|
actionLabel: PropTypes.string,
|
|
37
40
|
modalProps: PropTypes.object,
|
|
@@ -14,12 +14,12 @@ it('renders a InfoMessage component ', () => {
|
|
|
14
14
|
it('opens a modal with the content when clicking the button ', () => {
|
|
15
15
|
const { container } = render(<InfoMessage actionLabel="action">Content</InfoMessage>);
|
|
16
16
|
try {
|
|
17
|
-
screen.getByTestId('modal');
|
|
17
|
+
screen.getByTestId('info-message-modal');
|
|
18
18
|
expect('Modal displayed').toBeFalsy();
|
|
19
19
|
} catch (e) {
|
|
20
20
|
// nothink
|
|
21
21
|
}
|
|
22
22
|
userEvent.click(container.firstChild);
|
|
23
|
-
const modal = screen.getByTestId('modal');
|
|
23
|
+
const modal = screen.getByTestId('info-message-modal');
|
|
24
24
|
expect(modal).toHaveClass('modal');
|
|
25
25
|
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, fireEvent } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
4
|
+
|
|
5
|
+
import Input from './Input';
|
|
6
|
+
|
|
7
|
+
it('renders an input component ', () => {
|
|
8
|
+
const { container } = render(<Input>input</Input>);
|
|
9
|
+
expect(container.firstChild).toHaveClass('input');
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('should call func if Enter key is pressed', () => {
|
|
13
|
+
const fakeFunc = jest.fn();
|
|
14
|
+
const { container } = render(<Input onPressEnter={fakeFunc}>input</Input>);
|
|
15
|
+
const [input] = container.querySelectorAll('input');
|
|
16
|
+
fireEvent.keyDown(input, { keyCode: 13 });
|
|
17
|
+
expect(fakeFunc).toHaveBeenCalled();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should not accept input if disabled', () => {
|
|
21
|
+
const { container } = render(<Input disabled>input</Input>);
|
|
22
|
+
expect(container.firstChild).toHaveClass('input--disabled');
|
|
23
|
+
const [input] = container.querySelectorAll('input');
|
|
24
|
+
fireEvent.click(input);
|
|
25
|
+
expect(input).not.toHaveFocus();
|
|
26
|
+
});
|
|
@@ -18,6 +18,7 @@ export default class Label extends Component {
|
|
|
18
18
|
isPill,
|
|
19
19
|
noWrap,
|
|
20
20
|
plan,
|
|
21
|
+
testId,
|
|
21
22
|
...rest
|
|
22
23
|
} = this.props;
|
|
23
24
|
const classes = cl(
|
|
@@ -33,9 +34,21 @@ export default class Label extends Component {
|
|
|
33
34
|
className
|
|
34
35
|
);
|
|
35
36
|
return (
|
|
36
|
-
<span className={classes} {...rest}>
|
|
37
|
-
{label &&
|
|
38
|
-
|
|
37
|
+
<span className={classes} data-testid={testId} {...rest}>
|
|
38
|
+
{label && (
|
|
39
|
+
<span className="label__name" data-testid={`${testId}-label`}>
|
|
40
|
+
{label}
|
|
41
|
+
</span>
|
|
42
|
+
)}
|
|
43
|
+
{closable && (
|
|
44
|
+
<Button
|
|
45
|
+
type="link-flex"
|
|
46
|
+
iconSize={12}
|
|
47
|
+
icon="close-thick"
|
|
48
|
+
onClick={closeCb}
|
|
49
|
+
testId={`${testId}-button`}
|
|
50
|
+
/>
|
|
51
|
+
)}
|
|
39
52
|
</span>
|
|
40
53
|
);
|
|
41
54
|
}
|
|
@@ -54,10 +67,12 @@ Label.defaultProps = {
|
|
|
54
67
|
isPill: null,
|
|
55
68
|
noWrap: null,
|
|
56
69
|
plan: undefined,
|
|
70
|
+
testId: 'label',
|
|
57
71
|
};
|
|
58
72
|
|
|
59
73
|
Label.propTypes = {
|
|
60
74
|
label: PropTypes.string,
|
|
75
|
+
testId: PropTypes.string,
|
|
61
76
|
color: PropTypes.oneOf(['bleu', 'mauve', 'green', 'grey', 'orange', 'red', 'white', undefined, '']),
|
|
62
77
|
className: PropTypes.string,
|
|
63
78
|
product: PropTypes.oneOf([
|
|
@@ -24,7 +24,7 @@ export default class ConfirmationModal extends Component {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
render() {
|
|
27
|
-
const { text, title, defaultIsOpen } = this.props;
|
|
27
|
+
const { text, title, defaultIsOpen, testId } = this.props;
|
|
28
28
|
return (
|
|
29
29
|
<Modal
|
|
30
30
|
ref={this.modalRef}
|
|
@@ -32,6 +32,7 @@ export default class ConfirmationModal extends Component {
|
|
|
32
32
|
title={title || tr('Beware...')}
|
|
33
33
|
validateBtnProps={{ type: 'important' }}
|
|
34
34
|
validateCb={this.confirm}
|
|
35
|
+
testId={testId}
|
|
35
36
|
>
|
|
36
37
|
<div>{text}</div>
|
|
37
38
|
</Modal>
|
|
@@ -42,6 +43,7 @@ export default class ConfirmationModal extends Component {
|
|
|
42
43
|
ConfirmationModal.defaultProps = {
|
|
43
44
|
title: '',
|
|
44
45
|
defaultIsOpen: false,
|
|
46
|
+
testId: 'confirmation-modal',
|
|
45
47
|
};
|
|
46
48
|
|
|
47
49
|
ConfirmationModal.propTypes = {
|
|
@@ -49,4 +51,5 @@ ConfirmationModal.propTypes = {
|
|
|
49
51
|
text: PropTypes.string.isRequired,
|
|
50
52
|
title: PropTypes.string,
|
|
51
53
|
confirmCb: PropTypes.func.isRequired,
|
|
54
|
+
testId: PropTypes.string,
|
|
52
55
|
};
|
|
@@ -51,7 +51,7 @@ class Modal extends Component {
|
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
renderFooter = () => {
|
|
54
|
-
const { footer, labelValidate, errorLabel, validateCb, validateBtnProps, mainButtonType } = this.props;
|
|
54
|
+
const { footer, labelValidate, errorLabel, validateCb, validateBtnProps, mainButtonType, testId } = this.props;
|
|
55
55
|
const { isLoading } = this.state;
|
|
56
56
|
|
|
57
57
|
if (footer === false) {
|
|
@@ -63,11 +63,16 @@ class Modal extends Component {
|
|
|
63
63
|
<div className="modal__footer__error">{errorLabel}</div>
|
|
64
64
|
<>
|
|
65
65
|
{validateCb && (
|
|
66
|
-
<Button
|
|
66
|
+
<Button
|
|
67
|
+
testId={`${testId}-cancel-button`}
|
|
68
|
+
label={tr('Cancel')}
|
|
69
|
+
type="transparent"
|
|
70
|
+
onClick={this.close}
|
|
71
|
+
/>
|
|
67
72
|
)}
|
|
68
73
|
<Button
|
|
69
74
|
type={mainButtonType}
|
|
70
|
-
|
|
75
|
+
testId={`${testId}-validate-button`}
|
|
71
76
|
label={labelValidate || tr('Validate')}
|
|
72
77
|
onClick={this.validate}
|
|
73
78
|
isLoading={isLoading}
|
|
@@ -83,7 +88,7 @@ class Modal extends Component {
|
|
|
83
88
|
render() {
|
|
84
89
|
const { open } = this.state;
|
|
85
90
|
|
|
86
|
-
const { title, children, className, isFull, header, disableCloseOutside } = this.props;
|
|
91
|
+
const { title, children, className, isFull, header, disableCloseOutside, testId } = this.props;
|
|
87
92
|
const tit = open && title;
|
|
88
93
|
return ReactDOM.createPortal(
|
|
89
94
|
<AnimatePresence>
|
|
@@ -92,7 +97,7 @@ class Modal extends Component {
|
|
|
92
97
|
className={cl('modal', className, {
|
|
93
98
|
'modal--full': isFull,
|
|
94
99
|
})}
|
|
95
|
-
data-testid=
|
|
100
|
+
data-testid={testId}
|
|
96
101
|
>
|
|
97
102
|
<Animate className="modal__wrapper">
|
|
98
103
|
<div ref={this.modalRef} className="modal__content">
|
|
@@ -100,7 +105,7 @@ class Modal extends Component {
|
|
|
100
105
|
{header || <h1 className="title">{tit}</h1>}
|
|
101
106
|
{!disableCloseOutside && (
|
|
102
107
|
<Button
|
|
103
|
-
|
|
108
|
+
testId={`${testId}-close-button`}
|
|
104
109
|
className="modal__close"
|
|
105
110
|
icon="close"
|
|
106
111
|
type="link-flex"
|
|
@@ -135,6 +140,7 @@ Modal.defaultProps = {
|
|
|
135
140
|
defaultIsOpen: false,
|
|
136
141
|
validateBtnProps: {},
|
|
137
142
|
mainButtonType: 'primary',
|
|
143
|
+
testId: 'modal',
|
|
138
144
|
};
|
|
139
145
|
|
|
140
146
|
Modal.propTypes = {
|
|
@@ -153,6 +159,7 @@ Modal.propTypes = {
|
|
|
153
159
|
labelValidate: PropTypes.string,
|
|
154
160
|
validateBtnProps: PropTypes.object,
|
|
155
161
|
mainButtonType: PropTypes.string,
|
|
162
|
+
testId: PropTypes.string,
|
|
156
163
|
};
|
|
157
164
|
|
|
158
165
|
export default withClickOutside(Modal, '.ignore-click-outside-modal');
|
|
@@ -26,7 +26,7 @@ it('is hidden after clicking close', () => {
|
|
|
26
26
|
const modal = screen.getByTestId('modal');
|
|
27
27
|
expect(modal).toHaveClass('modal');
|
|
28
28
|
|
|
29
|
-
const close = screen.getByTestId('close');
|
|
29
|
+
const close = screen.getByTestId('modal-close-button');
|
|
30
30
|
userEvent.click(close);
|
|
31
31
|
try {
|
|
32
32
|
screen.getByTestId('modal');
|
|
@@ -46,7 +46,7 @@ it('is hidden after clicking cancel', () => {
|
|
|
46
46
|
act(() => {
|
|
47
47
|
modalRef.current.open();
|
|
48
48
|
});
|
|
49
|
-
const cancel = screen.getByTestId('cancel');
|
|
49
|
+
const cancel = screen.getByTestId('modal-cancel-button');
|
|
50
50
|
userEvent.click(cancel);
|
|
51
51
|
try {
|
|
52
52
|
screen.getByTestId('modal');
|
|
@@ -68,7 +68,7 @@ it('is hidden after clicking cancel', () => {
|
|
|
68
68
|
modalRef.current.open();
|
|
69
69
|
});
|
|
70
70
|
expect(validateCb.mock.calls.length).toBe(0);
|
|
71
|
-
const validate = screen.getByTestId('validate');
|
|
71
|
+
const validate = screen.getByTestId('modal-validate-button');
|
|
72
72
|
userEvent.click(validate);
|
|
73
73
|
expect(validateCb.mock.calls.length).toBe(1);
|
|
74
74
|
});
|
|
@@ -50,13 +50,13 @@ class Panel extends Component {
|
|
|
50
50
|
|
|
51
51
|
render() {
|
|
52
52
|
const { open } = this.state;
|
|
53
|
-
const { children, position, header, disableCloseOutside, ...rest } = this.props;
|
|
53
|
+
const { children, position, header, disableCloseOutside, testId, ...rest } = this.props;
|
|
54
54
|
return (
|
|
55
55
|
<AnimatePresence>
|
|
56
56
|
{open && (
|
|
57
57
|
<motion.div
|
|
58
58
|
ref={this.clickOutsideRef}
|
|
59
|
-
data-testid=
|
|
59
|
+
data-testid={testId}
|
|
60
60
|
className={cl('panel', `panel--${position}`)}
|
|
61
61
|
initial={{ right: -300 }}
|
|
62
62
|
animate={{ right: 0 }}
|
|
@@ -76,7 +76,7 @@ class Panel extends Component {
|
|
|
76
76
|
icon="close"
|
|
77
77
|
type="link-flex"
|
|
78
78
|
onClick={this.close}
|
|
79
|
-
|
|
79
|
+
testId={`${testId}-close-button`}
|
|
80
80
|
/>
|
|
81
81
|
</div>
|
|
82
82
|
</div>
|
|
@@ -94,10 +94,12 @@ Panel.defaultProps = {
|
|
|
94
94
|
closeCb: null,
|
|
95
95
|
header: null,
|
|
96
96
|
disableCloseOutside: false,
|
|
97
|
+
testId: 'panel',
|
|
97
98
|
};
|
|
98
99
|
|
|
99
100
|
Panel.propTypes = {
|
|
100
101
|
closeCb: PropTypes.func,
|
|
102
|
+
testId: PropTypes.string,
|
|
101
103
|
defaultIsOpen: PropTypes.bool,
|
|
102
104
|
disableCloseOutside: PropTypes.bool,
|
|
103
105
|
children: PropTypes.node.isRequired,
|
|
@@ -26,7 +26,7 @@ it('is hidden after clicking close', () => {
|
|
|
26
26
|
const panel = screen.getByTestId('panel');
|
|
27
27
|
expect(panel).toHaveClass('panel');
|
|
28
28
|
|
|
29
|
-
const close = screen.getByTestId('close');
|
|
29
|
+
const close = screen.getByTestId('panel-close-button');
|
|
30
30
|
userEvent.click(close);
|
|
31
31
|
try {
|
|
32
32
|
screen.getByTestId('panel');
|
|
@@ -34,4 +34,4 @@ it('is hidden after clicking close', () => {
|
|
|
34
34
|
} catch (e) {
|
|
35
35
|
// nothink
|
|
36
36
|
}
|
|
37
|
-
});
|
|
37
|
+
});
|
|
@@ -25,13 +25,13 @@ export default class ConfirmationPopover extends Component {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
renderContent = () => {
|
|
28
|
-
const { text } = this.props;
|
|
28
|
+
const { text, testId } = this.props;
|
|
29
29
|
return (
|
|
30
30
|
<div className="popover__content-box">
|
|
31
31
|
<div className="popover__message">{text}</div>
|
|
32
32
|
<div className="popover__footer ignore-click-outside">
|
|
33
|
-
<Button label={tr('Cancel')} type="link" onClick={this.close} />
|
|
34
|
-
<Button label={tr('Confirm')} onClick={this.confirm} />
|
|
33
|
+
<Button label={tr('Cancel')} testId={`${testId}-cancel-button`} type="link" onClick={this.close} />
|
|
34
|
+
<Button label={tr('Confirm')} testId={`${testId}-confirm-button`} onClick={this.confirm} />
|
|
35
35
|
</div>
|
|
36
36
|
</div>
|
|
37
37
|
);
|
|
@@ -48,12 +48,14 @@ export default class ConfirmationPopover extends Component {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
ConfirmationPopover.defaultProps = {
|
|
51
|
+
testId: 'confirm-popover',
|
|
51
52
|
container: null,
|
|
52
53
|
placement: 'bottom-center',
|
|
53
54
|
};
|
|
54
55
|
|
|
55
56
|
ConfirmationPopover.propTypes = {
|
|
56
57
|
text: PropTypes.string.isRequired,
|
|
58
|
+
testId: PropTypes.string,
|
|
57
59
|
placement: PropTypes.string,
|
|
58
60
|
children: PropTypes.node.isRequired,
|
|
59
61
|
container: PropTypes.string,
|
|
@@ -110,12 +110,13 @@ export default class ScrollBar extends Component {
|
|
|
110
110
|
component,
|
|
111
111
|
onSync,
|
|
112
112
|
children,
|
|
113
|
+
testId,
|
|
113
114
|
...rest
|
|
114
115
|
} = this.props;
|
|
115
116
|
const Comp = component;
|
|
116
117
|
|
|
117
118
|
return (
|
|
118
|
-
<Comp className={className} style={style} ref={this.containerRef} {...rest}>
|
|
119
|
+
<Comp className={className} style={style} ref={this.containerRef} data-testid={testId} {...rest}>
|
|
119
120
|
{children}
|
|
120
121
|
</Comp>
|
|
121
122
|
);
|
|
@@ -123,6 +124,7 @@ export default class ScrollBar extends Component {
|
|
|
123
124
|
}
|
|
124
125
|
|
|
125
126
|
ScrollBar.defaultProps = {
|
|
127
|
+
testId: 'scrollbar',
|
|
126
128
|
className: '',
|
|
127
129
|
style: {},
|
|
128
130
|
options: undefined,
|
|
@@ -142,6 +144,7 @@ ScrollBar.defaultProps = {
|
|
|
142
144
|
|
|
143
145
|
ScrollBar.propTypes = {
|
|
144
146
|
component: PropTypes.string,
|
|
147
|
+
testId: PropTypes.string,
|
|
145
148
|
style: PropTypes.object,
|
|
146
149
|
options: PropTypes.object,
|
|
147
150
|
className: PropTypes.string,
|
|
@@ -5,6 +5,6 @@ import '@testing-library/jest-dom/extend-expect';
|
|
|
5
5
|
import ScrollBar from './ScrollBar';
|
|
6
6
|
|
|
7
7
|
it('renders a ScrollBar component ', () => {
|
|
8
|
-
const {
|
|
9
|
-
expect(
|
|
8
|
+
const { getByTestId } = render(<ScrollBar>content</ScrollBar>);
|
|
9
|
+
expect(getByTestId('scrollbar')).toHaveClass('scrollbar-container');
|
|
10
10
|
});
|
|
@@ -18,14 +18,16 @@ export default class ServiceMessage extends Component {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
render() {
|
|
21
|
-
const { type, text, ...rest } = this.props;
|
|
21
|
+
const { type, text, testId, ...rest } = this.props;
|
|
22
22
|
const { open } = this.state;
|
|
23
23
|
const classes = cl('service-message', type ? `service-message--${type}` : null);
|
|
24
24
|
return (
|
|
25
25
|
open && (
|
|
26
|
-
<div data-testid=
|
|
27
|
-
<div className="service-message__text"
|
|
28
|
-
|
|
26
|
+
<div data-testid={testId} className={classes} {...rest}>
|
|
27
|
+
<div className="service-message__text" data-testid={`${testId}-text`}>
|
|
28
|
+
{text}
|
|
29
|
+
</div>
|
|
30
|
+
<Button icon="close" type="link-flex" onClick={this.close} testId={`${testId}-close-button`} />
|
|
29
31
|
</div>
|
|
30
32
|
)
|
|
31
33
|
);
|
|
@@ -35,9 +37,11 @@ export default class ServiceMessage extends Component {
|
|
|
35
37
|
ServiceMessage.defaultProps = {
|
|
36
38
|
type: 'error',
|
|
37
39
|
text: '',
|
|
40
|
+
testId: 'service-message',
|
|
38
41
|
};
|
|
39
42
|
|
|
40
43
|
ServiceMessage.propTypes = {
|
|
41
44
|
type: PropTypes.oneOf([undefined, 'success', 'error', 'warning', 'info']),
|
|
42
45
|
text: PropTypes.string,
|
|
46
|
+
testId: PropTypes.string,
|
|
43
47
|
};
|
|
@@ -14,11 +14,11 @@ class SomeChildComponent extends React.Component {
|
|
|
14
14
|
return (
|
|
15
15
|
<div>
|
|
16
16
|
<Button
|
|
17
|
-
|
|
17
|
+
testId="open"
|
|
18
18
|
label="Open"
|
|
19
19
|
onClick={() => openSnackBar('This is the content of the Snackbar.')}
|
|
20
20
|
/>
|
|
21
|
-
<Button
|
|
21
|
+
<Button testId="close" label="Close" onClick={closeSnackBar} />
|
|
22
22
|
</div>
|
|
23
23
|
);
|
|
24
24
|
}
|