@woosmap/ui 2.41.0 → 2.45.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.
Files changed (60) hide show
  1. package/package.json +1 -1
  2. package/src/components/Button/Button.js +4 -0
  3. package/src/components/Button/Button.stories.js +1 -1
  4. package/src/components/Button/Button.test.js +3 -3
  5. package/src/components/Button/ButtonGroup.js +4 -1
  6. package/src/components/Button/ButtonSwitch.js +4 -2
  7. package/src/components/Button/ButtonWithDropdown.js +22 -8
  8. package/src/components/Button/ButtonWithDropdown.test.js +35 -0
  9. package/src/components/Card/Card.js +5 -0
  10. package/src/components/Card/Card.test.js +3 -3
  11. package/src/components/Card/SimpleCard.js +25 -5
  12. package/src/components/Card/SimpleCard.test.js +2 -2
  13. package/src/components/CopyClipboardButton/CopyClipboardButton.js +4 -1
  14. package/src/components/CopyClipboardButton/CopyToClipboard.test.js +2 -2
  15. package/src/components/Demo/DistanceDemo.js +2 -1
  16. package/src/components/Demo/GeolocationDemo.js +9 -12
  17. package/src/components/Demo/LocalitiesAddressDemo.js +2 -1
  18. package/src/components/Demo/LocalitiesDemo.js +2 -2
  19. package/src/components/Demo/SearchDemo.js +3 -1
  20. package/src/components/Dropdown/Dropdown.js +30 -5
  21. package/src/components/Dropdown/Dropdown.test.js +2 -2
  22. package/src/components/DynamicTag/DynamicTag.js +8 -4
  23. package/src/components/Flash/Flash.js +4 -1
  24. package/src/components/Icon/Icon.js +51 -21
  25. package/src/components/Icon/Icon.test.js +4 -4
  26. package/src/components/InfoMessage/InfoMessage.js +5 -2
  27. package/src/components/InfoMessage/InfoMessage.test.js +2 -2
  28. package/src/components/Input/Input.test.js +26 -0
  29. package/src/components/Label/Label.js +18 -3
  30. package/src/components/Map/drawOnMap.js +40 -0
  31. package/src/components/Modal/ConfirmationModal.js +4 -1
  32. package/src/components/Modal/Modal.js +13 -6
  33. package/src/components/Modal/Modal.test.js +3 -3
  34. package/src/components/Panel/Panel.js +5 -3
  35. package/src/components/Panel/Panel.test.js +2 -2
  36. package/src/components/Popover/ConfirmationPopover.js +5 -3
  37. package/src/components/ScrollBar/ScrollBar.js +4 -1
  38. package/src/components/ScrollBar/ScrollBar.test.js +2 -2
  39. package/src/components/ServiceMessage/ServiceMessage.js +8 -4
  40. package/src/components/SnackBar/SnackBar.test.js +2 -2
  41. package/src/components/Tab/Tab.js +6 -3
  42. package/src/components/Tab/Tab.test.js +9 -9
  43. package/src/components/Tooltip/Tooltip.js +4 -2
  44. package/src/components/Tooltip/Tooltip.test.js +4 -4
  45. package/src/components/withFormValidation/withFormValidation.test.js +1 -5
  46. package/src/icons/autocomplete.svg +1 -0
  47. package/src/icons/buildings.svg +1 -0
  48. package/src/icons/github.svg +1 -0
  49. package/src/icons/position.svg +1 -0
  50. package/src/icons/quote.svg +1 -0
  51. package/src/icons/save-money.svg +1 -0
  52. package/src/icons/social-facebook.svg +1 -0
  53. package/src/icons/social-linkedin.svg +1 -0
  54. package/src/icons/social-twitter.svg +1 -0
  55. package/src/icons/world.svg +1 -0
  56. package/src/images/marker-dot.svg +15 -0
  57. package/src/styles/commons/base.styl +6 -6
  58. package/src/styles/console/button.styl +69 -43
  59. package/src/styles/console/mixins.styl +2 -2
  60. package/src/styles/style-next-website.styl +25 -0
@@ -45,11 +45,11 @@ class DropdownMenu extends Component {
45
45
  };
46
46
 
47
47
  render() {
48
- const { direction, children, closeCb, ...rest } = this.props;
48
+ const { direction, children, closeCb, testId, ...rest } = this.props;
49
49
  const childrenWithProps = mapChildrenWithProps(children, this.childrenRefs, closeCb);
50
50
 
51
51
  return (
52
- <ul role="menu" className={cl('dropdown__menu', direction)} {...rest}>
52
+ <ul role="menu" className={cl('dropdown__menu', direction)} data-testid={testId} {...rest}>
53
53
  {childrenWithProps}
54
54
  </ul>
55
55
  );
@@ -59,25 +59,36 @@ class DropdownMenu extends Component {
59
59
  DropdownMenu.defaultProps = {
60
60
  direction: 'sw',
61
61
  closeCb: null,
62
+ testId: 'dropdown-menu',
62
63
  };
63
64
 
64
65
  DropdownMenu.propTypes = {
65
66
  children: PropTypes.node.isRequired,
66
67
  closeCb: PropTypes.func,
68
+ testId: PropTypes.string,
67
69
  direction: PropTypes.oneOf(['ne', 'e', 'se', 's', 'sw', 'w']),
68
70
  };
69
71
 
70
72
  class DropdownSeparator extends Component {
71
73
  render() {
72
- return <li className={cl('dropdown__separator')} />;
74
+ const { testId } = this.props;
75
+ return <li className={cl('dropdown__separator')} data-testid={testId} />;
73
76
  }
74
77
  }
75
78
 
79
+ DropdownSeparator.defaultProps = {
80
+ testId: 'dropdown-separator',
81
+ };
82
+
83
+ DropdownSeparator.propTypes = {
84
+ testId: PropTypes.string,
85
+ };
86
+
76
87
  class DropdownItem extends Component {
77
88
  render() {
78
- const { children, closeCb, ...rest } = this.props;
89
+ const { children, closeCb, testId, ...rest } = this.props;
79
90
  return (
80
- <li className={cl('dropdown__item')} {...rest}>
91
+ <li className={cl('dropdown__item')} data-testid={testId} {...rest}>
81
92
  {children}
82
93
  </li>
83
94
  );
@@ -86,11 +97,13 @@ class DropdownItem extends Component {
86
97
 
87
98
  DropdownItem.defaultProps = {
88
99
  closeCb: null,
100
+ testId: 'dropdown-item',
89
101
  };
90
102
 
91
103
  DropdownItem.propTypes = {
92
104
  children: PropTypes.node.isRequired,
93
105
  closeCb: PropTypes.func,
106
+ testId: PropTypes.string,
94
107
  };
95
108
 
96
109
  class DropdownButtonItem extends Component {
@@ -125,6 +138,7 @@ DropdownButtonItem.defaultProps = {
125
138
  onClick: null,
126
139
  btnIcon: null,
127
140
  btnLabel: '',
141
+ testId: 'dropdown-button-item',
128
142
  isImportant: false,
129
143
  closeCb: null,
130
144
  };
@@ -133,6 +147,7 @@ DropdownButtonItem.propTypes = {
133
147
  onClick: PropTypes.func,
134
148
  btnIcon: PropTypes.string,
135
149
  btnLabel: PropTypes.string,
150
+ testId: PropTypes.string,
136
151
  isImportant: PropTypes.bool,
137
152
  closeCb: PropTypes.func,
138
153
  };
@@ -183,6 +198,7 @@ class DropdownConfirmButtonItem extends Component {
183
198
  }
184
199
 
185
200
  DropdownConfirmButtonItem.defaultProps = {
201
+ testId: 'dropdown-confirm-button-item',
186
202
  onConfirm: null,
187
203
  btnIcon: null,
188
204
  closeCb: null,
@@ -195,6 +211,7 @@ DropdownConfirmButtonItem.defaultProps = {
195
211
  DropdownConfirmButtonItem.propTypes = {
196
212
  onConfirm: PropTypes.func,
197
213
  btnIcon: PropTypes.string,
214
+ testId: PropTypes.string,
198
215
  confirmLabel: PropTypes.string,
199
216
  btnLabel: PropTypes.string,
200
217
  closeCb: PropTypes.func,
@@ -246,6 +263,7 @@ class Dropdown extends Component {
246
263
  const {
247
264
  children,
248
265
  size,
266
+ disabled,
249
267
  className,
250
268
  label,
251
269
  btnFace,
@@ -254,6 +272,7 @@ class Dropdown extends Component {
254
272
  btnFaceIconSize,
255
273
  closeCb,
256
274
  disableCloseOutside,
275
+ testId,
257
276
  ...rest
258
277
  } = this.props;
259
278
  const { open } = this.state;
@@ -266,6 +285,7 @@ class Dropdown extends Component {
266
285
  {...rest}
267
286
  >
268
287
  <Button
288
+ disabled={disabled}
269
289
  type={btnFace}
270
290
  onClick={this.onClick}
271
291
  onDoubleClick={this.onDoubleClick}
@@ -273,6 +293,7 @@ class Dropdown extends Component {
273
293
  size={btnSize}
274
294
  iconSize={btnFaceIconSize}
275
295
  label={label}
296
+ testId={testId}
276
297
  />
277
298
  {childrenWithProps}
278
299
  </div>
@@ -284,6 +305,7 @@ Dropdown.defaultProps = {
284
305
  size: 'normal',
285
306
  btnSize: null,
286
307
  onClick: null,
308
+ disabled: false,
287
309
  disableCloseOutside: false,
288
310
  onDoubleClick: null,
289
311
  label: null,
@@ -292,14 +314,17 @@ Dropdown.defaultProps = {
292
314
  btnFace: 'link-flex',
293
315
  btnFaceIcon: 'caret-bottom',
294
316
  btnFaceIconSize: 24,
317
+ testId: 'dropdown',
295
318
  };
296
319
 
297
320
  Dropdown.propTypes = {
298
321
  onClick: PropTypes.func,
299
322
  closeCb: PropTypes.func,
300
323
  onDoubleClick: PropTypes.func,
324
+ disabled: PropTypes.bool,
301
325
  disableCloseOutside: PropTypes.bool,
302
326
  label: PropTypes.string,
327
+ testId: PropTypes.string,
303
328
  children: PropTypes.node.isRequired,
304
329
  className: PropTypes.string,
305
330
  btnFace: PropTypes.oneOf(['link-flex', 'primary', 'secondary', 'important', 'transparent', 'link']),
@@ -7,14 +7,14 @@ import 'resize-observer-polyfill/dist/ResizeObserver.global';
7
7
  import Dropdown from './Dropdown';
8
8
 
9
9
  it('renders a Dropdown component ', () => {
10
- const { container } = render(
10
+ const { getByTestId } = render(
11
11
  <Dropdown label="My dropdown">
12
12
  <Dropdown.Menu>
13
13
  <Dropdown.Item>Item 1</Dropdown.Item>
14
14
  </Dropdown.Menu>
15
15
  </Dropdown>
16
16
  );
17
- expect(container.firstChild).toHaveClass('dropdown');
17
+ expect(getByTestId('dropdown').parentElement).toHaveClass('dropdown');
18
18
  const menu = screen.getByRole('menu');
19
19
  expect(menu).toHaveClass('dropdown__menu');
20
20
  });
@@ -50,7 +50,7 @@ export default class DynamicTag extends Component {
50
50
 
51
51
  renderInput = () => {
52
52
  const { inputValue, error } = this.state;
53
- const { placeholder } = this.props;
53
+ const { placeholder, testId } = this.props;
54
54
 
55
55
  return (
56
56
  <>
@@ -61,17 +61,18 @@ export default class DynamicTag extends Component {
61
61
  onBlur={this.handleInputConfirm}
62
62
  onPressEnter={this.handleInputConfirm}
63
63
  error={error}
64
+ testId={`${testId}-input`}
64
65
  />
65
- <Button label={tr('Add')} onClick={this.handleInputConfirm} />
66
+ <Button label={tr('Add')} onClick={this.handleInputConfirm} testId={`${testId}-button`} />
66
67
  </>
67
68
  );
68
69
  };
69
70
 
70
71
  render() {
71
72
  const { tags } = this.state;
72
- const { color } = this.props;
73
+ const { color, testId } = this.props;
73
74
  return (
74
- <div className={cl('dynamic-tag')}>
75
+ <div className={cl('dynamic-tag')} data-testid={testId}>
75
76
  <div className={cl('dynamic-tag__input')}>{this.renderInput()}</div>
76
77
  <div className={cl('dynamic-tag__tags')}>
77
78
  {tags.map((item) => (
@@ -83,6 +84,7 @@ export default class DynamicTag extends Component {
83
84
  closeCb={() => {
84
85
  this.handleTagRemove(item);
85
86
  }}
87
+ testId={`${testId}-label`}
86
88
  />
87
89
  ))}
88
90
  </div>
@@ -95,10 +97,12 @@ DynamicTag.defaultProps = {
95
97
  defaultTags: [],
96
98
  placeholder: '',
97
99
  color: '',
100
+ testId: 'dynamic-tag',
98
101
  };
99
102
 
100
103
  DynamicTag.propTypes = {
101
104
  defaultTags: PropTypes.array,
102
105
  placeholder: PropTypes.string,
103
106
  color: PropTypes.string,
107
+ testId: PropTypes.string,
104
108
  };
@@ -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,17 @@ 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 Localities } from '../../icons/localities.svg';
99
- import { ReactComponent as Traffic } from '../../icons/traffic.svg';
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 Address } from '../../icons/address.svg';
104
- import { ReactComponent as Star } from '../../icons/star.svg';
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';
117
+ import { ReactComponent as SocialFacebook } from '../../icons/social-facebook.svg';
118
+ import { ReactComponent as SocialLinkedin } from '../../icons/social-linkedin.svg';
119
+ import { ReactComponent as SocialTwitter } from '../../icons/social-twitter.svg';
110
120
 
111
121
  const Icons = {
112
122
  access: Access,
@@ -127,10 +137,12 @@ const Icons = {
127
137
  asset: Asset,
128
138
  'asset-add-file': AssetAddFile,
129
139
  'asset-add': AssetAdd,
140
+ autocomplete: Autocomplete,
130
141
  bank: Bank,
131
142
  beaker: Beaker,
132
143
  bell: Bell,
133
144
  bookmark: Bookmark,
145
+ buildings: Buildings,
134
146
  bulb: Bulb,
135
147
  'caret-bottom': CaretBotton,
136
148
  'caret-left': CaretLeft,
@@ -163,6 +175,7 @@ const Icons = {
163
175
  export: Export,
164
176
  flag: Flag,
165
177
  globe: Globe,
178
+ github: Github,
166
179
  home: Home,
167
180
  'home-user': HomeUser,
168
181
  import: Import,
@@ -183,17 +196,25 @@ const Icons = {
183
196
  organizations: Organizations,
184
197
  phone: Phone,
185
198
  platform: Platform,
199
+ position: Position,
186
200
  'product-activated': ProductActivated,
187
201
  'product-add': ProductAdd,
188
202
  products: Products,
189
203
  projects: Projects,
190
204
  puzzle: Puzzle,
191
- receipt: Receipt,
192
205
  question: Question,
206
+ quote: Quote,
207
+ receipt: Receipt,
208
+ 'save-money': SaveMoney,
193
209
  search: Search,
194
210
  'see-page': SeePage,
195
211
  settings: Settings,
196
212
  shield: Shield,
213
+ star: Star,
214
+ 'star-filled': StarFilled,
215
+ stores: Stores,
216
+ support: Support,
217
+ switch: Switch,
197
218
  team: Team,
198
219
  time: Time,
199
220
  tool: Tool,
@@ -203,25 +224,32 @@ const Icons = {
203
224
  'view-mini-card': ViewMiniCard,
204
225
  warning: Warning,
205
226
  woosmap: Woosmap,
206
- localities: Localities,
207
- traffic: Traffic,
208
- maps: Map,
227
+ world: World,
228
+ address: Address,
209
229
  distance: Distance,
210
230
  geolocation: Geolocation,
211
- address: Address,
212
- star: Star,
213
- 'star-filled': StarFilled,
214
- stores: Stores,
215
- support: Support,
216
- switch: Switch,
231
+ localities: Localities,
232
+ maps: Map,
217
233
  merchant: Merchant,
234
+ traffic: Traffic,
235
+ 'social-facebook': SocialFacebook,
236
+ 'social-linkedin': SocialLinkedin,
237
+ 'social-twitter': SocialTwitter,
218
238
  };
219
239
 
220
240
  class Icon extends Component {
221
241
  render() {
222
- const { icon, size, className, title } = this.props;
242
+ const { icon, size, className, title, testId } = this.props;
223
243
  const IconComponent = Icons[icon];
224
- return <IconComponent className={cl('icon', className)} width={size} height={size} title={title} />;
244
+ return (
245
+ <IconComponent
246
+ className={cl('icon', className)}
247
+ data-testid={testId}
248
+ width={size}
249
+ height={size}
250
+ title={title}
251
+ />
252
+ );
225
253
  }
226
254
  }
227
255
 
@@ -229,6 +257,7 @@ Icon.defaultProps = {
229
257
  size: 24,
230
258
  className: null,
231
259
  title: null,
260
+ testId: 'icon',
232
261
  };
233
262
 
234
263
  Icon.propTypes = {
@@ -236,6 +265,7 @@ Icon.propTypes = {
236
265
  className: PropTypes.string,
237
266
  icon: PropTypes.string.isRequired,
238
267
  title: PropTypes.string,
268
+ testId: PropTypes.string,
239
269
  };
240
270
  export default Object.assign(Icon, {
241
271
  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 { container } = render(<Icon icon="home" size={64} />);
9
- expect(container.firstChild).toHaveClass('icon');
10
- expect(container.firstChild).toHaveAttribute('width', '64');
11
- expect(container.firstChild).toHaveTextContent('home');
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 && <span className="label__name">{label}</span>}
38
- {closable && <Button type="link-flex" iconSize={12} icon="close-thick" onClick={closeCb} />}
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([
@@ -84,6 +84,46 @@ export const woosmapBoundsFromViewport = function woosmapBoundsFromViewport(view
84
84
  );
85
85
  };
86
86
 
87
+ export const createWoosmapMap = (node) =>
88
+ new window.woosmap.map.Map(node, {
89
+ styles: [
90
+ {
91
+ featureType: 'administrative',
92
+ elementType: 'all',
93
+ stylers: [{ visibility: 'on' }, { saturation: -100 }, { lightness: 20 }],
94
+ },
95
+ {
96
+ featureType: 'road',
97
+ elementType: 'all',
98
+ stylers: [{ visibility: 'on' }, { saturation: -100 }, { lightness: 40 }],
99
+ },
100
+ {
101
+ featureType: 'water',
102
+ elementType: 'all',
103
+ stylers: [{ visibility: 'on' }, { saturation: -10 }, { lightness: 30 }],
104
+ },
105
+ {
106
+ featureType: 'landscape.man_made',
107
+ elementType: 'all',
108
+ stylers: [{ visibility: 'simplified' }, { saturation: -60 }, { lightness: 10 }],
109
+ },
110
+ {
111
+ featureType: 'landscape.natural',
112
+ elementType: 'all',
113
+ stylers: [{ visibility: 'simplified' }, { saturation: -60 }, { lightness: 60 }],
114
+ },
115
+ {
116
+ featureType: 'poi',
117
+ elementType: 'all',
118
+ stylers: [{ visibility: 'off' }, { saturation: -100 }, { lightness: 60 }],
119
+ },
120
+ {
121
+ featureType: 'transit',
122
+ elementType: 'all',
123
+ stylers: [{ visibility: 'off' }, { saturation: -100 }, { lightness: 60 }],
124
+ },
125
+ ],
126
+ });
87
127
  export class WoosmapMapBoundingBox {
88
128
  constructor(bounds, padding) {
89
129
  this.overlayView = new window.woosmap.map.OverlayView();
@@ -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
  };