@reltio/components 1.4.2051 → 1.4.2053

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 (171) hide show
  1. package/AttributeListItem/AttributeListItem.d.ts +1 -1
  2. package/ChartTooltip/ChartTooltip.js +3 -3
  3. package/ColumnsSettings/components/ColumnListItem/ColumnListItem.d.ts +11 -26
  4. package/ColumnsSettings/components/ColumnListItem/ColumnListItem.js +0 -14
  5. package/DropDownMenuButton/DropDownMenuButton.js +1 -1
  6. package/HOCs/withAsyncMount/withAsyncMount.test.js +52 -52
  7. package/IgnoreButton/IgnoreButton.spec.js +109 -20
  8. package/Image/Image.d.ts +1 -1
  9. package/Image/Image.js +8 -8
  10. package/Image/Image.test.js +46 -51
  11. package/ImageActionsOverlay/ImageActionsOverlay.js +2 -1
  12. package/ImageActionsOverlay/ImageActionsOverlay.test.js +207 -125
  13. package/ImageActionsOverlay/components/CheckedIcon/CheckedIcon.js +1 -1
  14. package/ImageAttributesGallery/ImageAttributesGallery.test.js +525 -281
  15. package/ImageAttributesLine/ImageAttributesLine.js +1 -1
  16. package/ImageAttributesLine/ImageAttributesLine.test.js +187 -193
  17. package/ImageAttributesLine/imageAttributeValues.test-data.d.ts +10 -0
  18. package/ImageAttributesLine/imageAttributeValues.test-data.js +22 -0
  19. package/ImageAttributesLineEditor/ImageAttributesLineEditor.test.js +315 -298
  20. package/ImageDetailsView/ImageDetailsView.test.js +529 -55
  21. package/ImageDetailsView/attributes.test-data.d.ts +4 -1
  22. package/ImageDetailsView/attributes.test-data.js +98 -1
  23. package/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.js +2 -2
  24. package/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.js +1 -1
  25. package/ImageDetailsView/components/MetaInfoList/MetaInfoList.js +1 -1
  26. package/ImageDetailsView/components/Thumbnails/Thumbnails.js +1 -1
  27. package/ImageDetailsView/helpers.test.js +4 -4
  28. package/ImageGalleryDialog/ImageGalleryDialog.test.js +89 -46
  29. package/ImportButton/ImportButton.test.js +94 -24
  30. package/InlineAttributesList/InlineAttributesList.test.js +22 -62
  31. package/InlineAttributesList/attributes.test-data.d.ts +4 -2
  32. package/InlineAttributesList/attributes.test-data.js +40 -1
  33. package/InlineAttributesPager/InlineAttributesPager.d.ts +1 -2
  34. package/InlineAttributesPager/InlineAttributesPager.js +1 -4
  35. package/InlineAttributesPager/InlineAttributesPager.test.js +393 -183
  36. package/InlineComplexAttribute/InlineComplexAttribute.js +1 -1
  37. package/InlineComplexAttribute/InlineComplexAttribute.test.js +396 -182
  38. package/InlineImageAttribute/InlineImageAttribute.test.js +103 -55
  39. package/InlineNestedAttribute/InlineNestedAttribute.test.js +105 -43
  40. package/InlineReferenceAttribute/InlineReferenceAttribute.test.js +165 -107
  41. package/InlineSimpleAttribute/InlineSimpleAttribute.spec.js +352 -346
  42. package/InlineSimpleAttributeEditor/InlineSimpleAttributeEditor.test.js +285 -194
  43. package/InternalLink/InternalLink.test.js +41 -11
  44. package/LookupEditor/LookupEditor.test.js +180 -44
  45. package/LookupEditor/components/GroupedDropDownEditor/helpers.test.js +1 -1
  46. package/MapChart/MapChart.js +3 -8
  47. package/MapChart/MapChart.test.js +152 -188
  48. package/MapChart/components/Legend/Legend.js +3 -3
  49. package/MaskingSwitcher/MaskingSwitcher.js +1 -1
  50. package/MatchRulesBadge/MatchRulesBadge.test.js +93 -24
  51. package/SelectEditor/SelectEditor.d.ts +4 -10
  52. package/SelectEditor/SelectEditor.js +0 -4
  53. package/SelectEditor/SelectEditor.test.js +79 -9
  54. package/cjs/AttributeListItem/AttributeListItem.d.ts +1 -1
  55. package/cjs/ChartTooltip/ChartTooltip.js +3 -3
  56. package/cjs/ColumnsSettings/components/ColumnListItem/ColumnListItem.d.ts +11 -26
  57. package/cjs/ColumnsSettings/components/ColumnListItem/ColumnListItem.js +0 -14
  58. package/cjs/DropDownMenuButton/DropDownMenuButton.js +1 -1
  59. package/cjs/HOCs/withAsyncMount/withAsyncMount.test.js +56 -56
  60. package/cjs/IgnoreButton/IgnoreButton.spec.js +109 -20
  61. package/cjs/Image/Image.d.ts +1 -1
  62. package/cjs/Image/Image.js +8 -8
  63. package/cjs/Image/Image.test.js +46 -51
  64. package/cjs/ImageActionsOverlay/ImageActionsOverlay.js +2 -1
  65. package/cjs/ImageActionsOverlay/ImageActionsOverlay.test.js +207 -125
  66. package/cjs/ImageActionsOverlay/components/CheckedIcon/CheckedIcon.js +1 -1
  67. package/cjs/ImageAttributesGallery/ImageAttributesGallery.test.js +525 -281
  68. package/cjs/ImageAttributesLine/ImageAttributesLine.js +1 -1
  69. package/cjs/ImageAttributesLine/ImageAttributesLine.test.js +195 -224
  70. package/cjs/ImageAttributesLine/imageAttributeValues.test-data.d.ts +10 -0
  71. package/cjs/ImageAttributesLine/imageAttributeValues.test-data.js +23 -1
  72. package/cjs/ImageAttributesLineEditor/ImageAttributesLineEditor.test.js +316 -299
  73. package/cjs/ImageDetailsView/ImageDetailsView.test.js +529 -55
  74. package/cjs/ImageDetailsView/attributes.test-data.d.ts +4 -1
  75. package/cjs/ImageDetailsView/attributes.test-data.js +99 -2
  76. package/cjs/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.js +2 -2
  77. package/cjs/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.js +1 -1
  78. package/cjs/ImageDetailsView/components/MetaInfoList/MetaInfoList.js +1 -1
  79. package/cjs/ImageDetailsView/components/Thumbnails/Thumbnails.js +1 -1
  80. package/cjs/ImageDetailsView/helpers.test.js +3 -3
  81. package/cjs/ImageGalleryDialog/ImageGalleryDialog.test.js +89 -46
  82. package/cjs/ImportButton/ImportButton.test.js +94 -24
  83. package/cjs/InlineAttributesList/InlineAttributesList.test.js +22 -62
  84. package/cjs/InlineAttributesList/attributes.test-data.d.ts +4 -2
  85. package/cjs/InlineAttributesList/attributes.test-data.js +41 -2
  86. package/cjs/InlineAttributesPager/InlineAttributesPager.d.ts +1 -2
  87. package/cjs/InlineAttributesPager/InlineAttributesPager.js +1 -4
  88. package/cjs/InlineAttributesPager/InlineAttributesPager.test.js +393 -183
  89. package/cjs/InlineComplexAttribute/InlineComplexAttribute.js +1 -1
  90. package/cjs/InlineComplexAttribute/InlineComplexAttribute.test.js +395 -204
  91. package/cjs/InlineImageAttribute/InlineImageAttribute.test.js +103 -55
  92. package/cjs/InlineNestedAttribute/InlineNestedAttribute.test.js +105 -43
  93. package/cjs/InlineReferenceAttribute/InlineReferenceAttribute.test.js +164 -106
  94. package/cjs/InlineSimpleAttribute/InlineSimpleAttribute.spec.js +351 -345
  95. package/cjs/InlineSimpleAttributeEditor/InlineSimpleAttributeEditor.test.js +307 -193
  96. package/cjs/InternalLink/InternalLink.test.js +40 -10
  97. package/cjs/LookupEditor/LookupEditor.test.js +178 -65
  98. package/cjs/LookupEditor/components/GroupedDropDownEditor/helpers.test.js +1 -1
  99. package/cjs/MapChart/MapChart.js +3 -8
  100. package/cjs/MapChart/MapChart.test.js +152 -188
  101. package/cjs/MapChart/components/Legend/Legend.js +3 -3
  102. package/cjs/MaskingSwitcher/MaskingSwitcher.js +1 -1
  103. package/cjs/MatchRulesBadge/MatchRulesBadge.test.js +93 -24
  104. package/cjs/SelectEditor/SelectEditor.d.ts +4 -10
  105. package/cjs/SelectEditor/SelectEditor.js +0 -4
  106. package/cjs/SelectEditor/SelectEditor.test.js +79 -9
  107. package/cjs/hooks/useAsyncMount/useAsyncMount.d.ts +1 -1
  108. package/cjs/hooks/useAsyncMount/useAsyncMount.js +1 -1
  109. package/hooks/useAsyncMount/useAsyncMount.d.ts +1 -1
  110. package/hooks/useAsyncMount/useAsyncMount.js +1 -1
  111. package/package.json +2 -2
  112. package/HOCs/withTableContext/withTableContext.test.d.ts +0 -1
  113. package/HOCs/withTableContext/withTableContext.test.js +0 -41
  114. package/ImageAttributesGallery/components/GalleryView/GalleryView.test.d.ts +0 -1
  115. package/ImageAttributesGallery/components/GalleryView/GalleryView.test.js +0 -98
  116. package/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.test.d.ts +0 -1
  117. package/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.test.js +0 -99
  118. package/ImageDetailsView/components/ImageDetailsViewSidebar/ImageDetailsViewSidebar.test.d.ts +0 -1
  119. package/ImageDetailsView/components/ImageDetailsViewSidebar/ImageDetailsViewSidebar.test.js +0 -65
  120. package/ImageDetailsView/components/MetaInfo/MetaInfo.test.d.ts +0 -1
  121. package/ImageDetailsView/components/MetaInfo/MetaInfo.test.js +0 -306
  122. package/ImageDetailsView/components/MetaInfoForm/MetaInfoForm.test.d.ts +0 -1
  123. package/ImageDetailsView/components/MetaInfoForm/MetaInfoForm.test.js +0 -134
  124. package/ImageDetailsView/components/MetaInfoHeader/MetaInfoHeader.test.d.ts +0 -1
  125. package/ImageDetailsView/components/MetaInfoHeader/MetaInfoHeader.test.js +0 -99
  126. package/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.test.d.ts +0 -1
  127. package/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.test.js +0 -36
  128. package/ImageDetailsView/components/MetaInfoList/MetaInfoList.test.d.ts +0 -1
  129. package/ImageDetailsView/components/MetaInfoList/MetaInfoList.test.js +0 -161
  130. package/ImageDetailsView/components/Thumbnails/Thumbnails.test.d.ts +0 -1
  131. package/ImageDetailsView/components/Thumbnails/Thumbnails.test.js +0 -76
  132. package/InlineAttributesPager/components/InlineImageAttributesBlock/InlineImageAttributesBlock.test.d.ts +0 -1
  133. package/InlineAttributesPager/components/InlineImageAttributesBlock/InlineImageAttributesBlock.test.js +0 -104
  134. package/InlineAttributesPager/components/InlineNestedAttributesBlock/InlineNestedAttributesBlock.test.d.ts +0 -1
  135. package/InlineAttributesPager/components/InlineNestedAttributesBlock/InlineNestedAttributesBlock.test.js +0 -114
  136. package/InlineAttributesPager/components/InlineReferenceAttributesBlock/InlineReferenceAttributesBlock.test.d.ts +0 -1
  137. package/InlineAttributesPager/components/InlineReferenceAttributesBlock/InlineReferenceAttributesBlock.test.js +0 -177
  138. package/InlineSimpleAttribute/components/CrosswalkMenuItem/CrosswalkMenuItem.spec.d.ts +0 -1
  139. package/InlineSimpleAttribute/components/CrosswalkMenuItem/CrosswalkMenuItem.spec.js +0 -52
  140. package/LookupEditor/components/GroupedDropDownEditor/GroupedDropDownEditor.test.d.ts +0 -1
  141. package/LookupEditor/components/GroupedDropDownEditor/GroupedDropDownEditor.test.js +0 -37
  142. package/cjs/HOCs/withTableContext/withTableContext.test.d.ts +0 -1
  143. package/cjs/HOCs/withTableContext/withTableContext.test.js +0 -46
  144. package/cjs/ImageAttributesGallery/components/GalleryView/GalleryView.test.d.ts +0 -1
  145. package/cjs/ImageAttributesGallery/components/GalleryView/GalleryView.test.js +0 -103
  146. package/cjs/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.test.d.ts +0 -1
  147. package/cjs/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.test.js +0 -104
  148. package/cjs/ImageDetailsView/components/ImageDetailsViewSidebar/ImageDetailsViewSidebar.test.d.ts +0 -1
  149. package/cjs/ImageDetailsView/components/ImageDetailsViewSidebar/ImageDetailsViewSidebar.test.js +0 -70
  150. package/cjs/ImageDetailsView/components/MetaInfo/MetaInfo.test.d.ts +0 -1
  151. package/cjs/ImageDetailsView/components/MetaInfo/MetaInfo.test.js +0 -311
  152. package/cjs/ImageDetailsView/components/MetaInfoForm/MetaInfoForm.test.d.ts +0 -1
  153. package/cjs/ImageDetailsView/components/MetaInfoForm/MetaInfoForm.test.js +0 -139
  154. package/cjs/ImageDetailsView/components/MetaInfoHeader/MetaInfoHeader.test.d.ts +0 -1
  155. package/cjs/ImageDetailsView/components/MetaInfoHeader/MetaInfoHeader.test.js +0 -104
  156. package/cjs/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.test.d.ts +0 -1
  157. package/cjs/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.test.js +0 -41
  158. package/cjs/ImageDetailsView/components/MetaInfoList/MetaInfoList.test.d.ts +0 -1
  159. package/cjs/ImageDetailsView/components/MetaInfoList/MetaInfoList.test.js +0 -166
  160. package/cjs/ImageDetailsView/components/Thumbnails/Thumbnails.test.d.ts +0 -1
  161. package/cjs/ImageDetailsView/components/Thumbnails/Thumbnails.test.js +0 -81
  162. package/cjs/InlineAttributesPager/components/InlineImageAttributesBlock/InlineImageAttributesBlock.test.d.ts +0 -1
  163. package/cjs/InlineAttributesPager/components/InlineImageAttributesBlock/InlineImageAttributesBlock.test.js +0 -109
  164. package/cjs/InlineAttributesPager/components/InlineNestedAttributesBlock/InlineNestedAttributesBlock.test.d.ts +0 -1
  165. package/cjs/InlineAttributesPager/components/InlineNestedAttributesBlock/InlineNestedAttributesBlock.test.js +0 -119
  166. package/cjs/InlineAttributesPager/components/InlineReferenceAttributesBlock/InlineReferenceAttributesBlock.test.d.ts +0 -1
  167. package/cjs/InlineAttributesPager/components/InlineReferenceAttributesBlock/InlineReferenceAttributesBlock.test.js +0 -182
  168. package/cjs/InlineSimpleAttribute/components/CrosswalkMenuItem/CrosswalkMenuItem.spec.d.ts +0 -1
  169. package/cjs/InlineSimpleAttribute/components/CrosswalkMenuItem/CrosswalkMenuItem.spec.js +0 -57
  170. package/cjs/LookupEditor/components/GroupedDropDownEditor/GroupedDropDownEditor.test.d.ts +0 -1
  171. package/cjs/LookupEditor/components/GroupedDropDownEditor/GroupedDropDownEditor.test.js +0 -42
@@ -6,7 +6,7 @@ export declare const RecommendedIconWithTooltip: React.ForwardRefExoticComponent
6
6
  tooltipPlacement?: import("@mui/material").TooltipProps["placement"];
7
7
  showForDisabled?: boolean;
8
8
  } & React.SVGProps<SVGSVGElement>, "ref"> & React.RefAttributes<HTMLElement>>;
9
- type Data = {
9
+ type Data = Record<string, unknown> & {
10
10
  attrType?: AttributeType;
11
11
  };
12
12
  type Props = {
@@ -9,11 +9,11 @@ export var ChartTooltip = function (_a) {
9
9
  var localizedValue = (tooltipPayload === null || tooltipPayload === void 0 ? void 0 : tooltipPayload.localizedValue) || (tooltipPayload === null || tooltipPayload === void 0 ? void 0 : tooltipPayload.value);
10
10
  var tooltipLabel = tooltipPayload === null || tooltipPayload === void 0 ? void 0 : tooltipPayload.label;
11
11
  var percent = tooltipPayload === null || tooltipPayload === void 0 ? void 0 : tooltipPayload.percent;
12
- return (active && (React.createElement("div", { className: styles.tooltipWrapper },
12
+ return (active && (React.createElement("div", { "data-reltio-id": "chart-tooltip", className: styles.tooltipWrapper },
13
13
  React.createElement("p", { className: styles.tooltipTitle }, tooltipLabel),
14
- isNil(percent) ? (React.createElement("p", { className: styles.tooltipValue },
14
+ isNil(percent) ? (React.createElement("p", { "data-reltio-id": "chart-tooltip-value", className: styles.tooltipValue },
15
15
  "Value: ",
16
- localizedValue)) : (React.createElement("p", { className: styles.tooltipValueBold },
16
+ localizedValue)) : (React.createElement("p", { "data-reltio-id": "chart-tooltip-value", className: styles.tooltipValueBold },
17
17
  localizedValue,
18
18
  React.createElement("span", { className: styles.tooltipPercent },
19
19
  " (",
@@ -1,27 +1,12 @@
1
- export function ColumnListItem({ item, onClick, checked, level, style, isFocused, isGroupItem, hideCheckBox }: {
2
- item: any;
3
- onClick: any;
4
- checked: any;
5
- level: any;
6
- style: any;
7
- isFocused: any;
8
- isGroupItem: any;
9
- hideCheckBox: any;
10
- }): React.JSX.Element;
11
- export namespace ColumnListItem {
12
- namespace propTypes {
13
- let item: PropTypes.Requireable<PropTypes.InferProps<{
14
- label: PropTypes.Requireable<string>;
15
- filterText: PropTypes.Requireable<string>;
16
- }>>;
17
- let level: PropTypes.Requireable<number>;
18
- let onClick: PropTypes.Requireable<(...args: any[]) => any>;
19
- let checked: PropTypes.Requireable<boolean>;
20
- let style: PropTypes.Requireable<object>;
21
- let isGroupItem: PropTypes.Requireable<boolean>;
22
- let isFocused: PropTypes.Requireable<boolean>;
23
- let hideCheckBox: PropTypes.Requireable<boolean>;
24
- }
25
- }
26
1
  import React from 'react';
27
- import PropTypes from 'prop-types';
2
+ import { AttributeListItem } from '../../../AttributeListItem';
3
+ type Props = Pick<React.ComponentProps<typeof AttributeListItem>, 'hideCheckBox' | 'onClick' | 'checked' | 'level' | 'style' | 'isFocused'> & {
4
+ item: {
5
+ id: string;
6
+ label: string;
7
+ filterText?: string;
8
+ };
9
+ isGroupItem?: boolean;
10
+ };
11
+ export declare const ColumnListItem: ({ item, onClick, checked, level, style, isFocused, isGroupItem, hideCheckBox }: Props) => React.JSX.Element;
12
+ export {};
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
3
2
  import classnames from 'classnames';
4
3
  import { AttributeListItem } from '../../../AttributeListItem';
5
4
  import { Highlighter } from '../../../Highlighter';
@@ -10,16 +9,3 @@ export var ColumnListItem = function (_a) {
10
9
  var styles = useStyles();
11
10
  return (React.createElement(AttributeListItem, { hideCheckBox: hideCheckBox, key: item.id, onClick: onClick, checked: checked, level: level, data: item, label: React.createElement(Highlighter, { text: item.label, highlight: item.filterText }), labelInText: item.label, style: style, isFocused: isFocused, hideIcon: isGroupItem, className: classnames((_b = {}, _b[styles.groupItem] = isGroupItem, _b)) }));
12
11
  };
13
- ColumnListItem.propTypes = {
14
- item: PropTypes.shape({
15
- label: PropTypes.string,
16
- filterText: PropTypes.string
17
- }),
18
- level: PropTypes.number,
19
- onClick: PropTypes.func,
20
- checked: PropTypes.bool,
21
- style: PropTypes.object,
22
- isGroupItem: PropTypes.bool,
23
- isFocused: PropTypes.bool,
24
- hideCheckBox: PropTypes.bool
25
- };
@@ -40,7 +40,7 @@ export function DropDownMenuButton(_a) {
40
40
  return React.createElement(MenuItemRenderer, { item: item, key: index, onMenuClose: handleToggle });
41
41
  };
42
42
  return (React.createElement(React.Fragment, null,
43
- React.createElement(ButtonComponent, __assign({ "data-reltio-id": 'drop-down-menu-button', ref: buttonRef, className: classnames(styles.buttonRoot, (_b = {},
43
+ React.createElement(ButtonComponent, __assign({ "data-reltio-id": "drop-down-menu-button", ref: buttonRef, className: classnames(styles.buttonRoot, (_b = {},
44
44
  _b[styles.selected] = isOpen,
45
45
  _b), className), onClick: handleToggle, "aria-pressed": isOpen, "aria-controls": isOpen ? menuId : undefined, "aria-haspopup": "true" }, buttonProps), buttonContent),
46
46
  React.createElement(Menu, __assign({ id: menuId, variant: "menu", open: isOpen, autoFocus: false, classes: { paper: styles.paper }, anchorEl: buttonRef.current, onClose: handleToggle, anchorOrigin: {
@@ -1,90 +1,90 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  import React from 'react';
2
- import { mount } from 'enzyme';
3
- import { act } from 'react-dom/test-utils';
13
+ import { render, screen, act } from '@testing-library/react';
4
14
  import { AsyncMountContext } from '../../contexts/AsyncMountContext';
5
15
  import { withAsyncMount } from './withAsyncMount';
6
16
  describe('withAsyncMount tests', function () {
7
17
  beforeAll(function () {
8
18
  jest.useFakeTimers();
9
19
  });
20
+ var defaultContextValue = { enabled: true, queueSizeThreshold: 0 };
10
21
  var Component = function (_a) {
11
22
  var value = _a.value;
12
- return React.createElement("div", { "data-id": value });
13
- }; //eslint-disable-line
23
+ return React.createElement("div", { "data-reltio-id": value });
24
+ };
25
+ var Placeholder = function () { return React.createElement("span", { "data-reltio-id": "placeholder" }); };
26
+ var setUp = function (_a) {
27
+ var _b = _a === void 0 ? {} : _a, _c = _b.contextValue, contextValue = _c === void 0 ? {} : _c, _d = _b.withProvider, withProvider = _d === void 0 ? true : _d, _e = _b.withPlaceholder, withPlaceholder = _e === void 0 ? false : _e;
28
+ var Providers = function (_a) {
29
+ var children = _a.children;
30
+ return (React.createElement(AsyncMountContext.Provider, { value: __assign(__assign({}, defaultContextValue), contextValue) }, children));
31
+ };
32
+ var AsyncMountedComponent = withAsyncMount(Component, withPlaceholder ? Placeholder : undefined);
33
+ return render(React.createElement(AsyncMountedComponent, { value: "test-value" }), { wrapper: withProvider ? Providers : undefined });
34
+ };
14
35
  it('should mount wrapped component in sync way without AsyncMountContext.Provider', function () {
15
- var AsyncMountedComponent = withAsyncMount(Component);
16
- var component = mount(React.createElement(AsyncMountedComponent, { value: "123" }));
17
- expect(component.find(Component).exists()).toBe(true);
36
+ setUp({ withProvider: false });
37
+ expect(screen.getByTestId('test-value')).toBeInTheDocument();
18
38
  });
19
39
  it('should mount wrapped component in sync way with AsyncMountContext.Provider if value.enabled = false', function () {
20
- var AsyncMountedComponent = withAsyncMount(Component);
21
- var component = mount(React.createElement(AsyncMountContext.Provider, { value: { enabled: false, queueSizeThreshold: 0 } },
22
- React.createElement(AsyncMountedComponent, { value: "123" })));
23
- expect(component.find(Component).exists()).toBe(true);
40
+ setUp({ contextValue: { enabled: false } });
41
+ expect(screen.getByTestId('test-value')).toBeInTheDocument();
24
42
  });
25
43
  it('should mount wrapped component in async way with AsyncMountContext.Provider if value.enabled = true', function () {
26
- var AsyncMountedComponent = withAsyncMount(Component);
27
- var component = mount(React.createElement(AsyncMountContext.Provider, { value: { enabled: true, queueSizeThreshold: 0 } },
28
- React.createElement(AsyncMountedComponent, { value: "123" })));
29
- expect(component.find(Component).exists()).toBe(false);
30
- expect(component.isEmptyRender()).toBe(true);
44
+ setUp({ contextValue: { enabled: true } });
45
+ expect(screen.queryByTestId('test-value')).not.toBeInTheDocument();
31
46
  act(function () {
32
47
  jest.runOnlyPendingTimers();
33
48
  });
34
- component.update();
35
- expect(component.find(Component).exists()).toBe(true);
36
- expect(component.find(Component).prop('value')).toBe('123');
37
- expect(component.isEmptyRender()).toBe(false);
49
+ expect(screen.getByTestId('test-value')).toBeInTheDocument();
38
50
  });
39
51
  it('should render PlaceholderComponent instead of Component before mounting if its passed as second argument', function () {
40
- var Placeholder = function () { return React.createElement("span", null); };
41
- var AsyncMountedComponent = withAsyncMount(Component, Placeholder);
42
- var component = mount(React.createElement(AsyncMountContext.Provider, { value: { enabled: true, queueSizeThreshold: 0 } },
43
- React.createElement(AsyncMountedComponent, { value: "123" })));
44
- expect(component.find(Component).exists()).toBe(false);
45
- expect(component.find(Placeholder).exists()).toBe(true);
52
+ setUp({ withPlaceholder: true });
53
+ expect(screen.queryByTestId('test-value')).not.toBeInTheDocument();
54
+ expect(screen.getByTestId('placeholder')).toBeInTheDocument();
46
55
  act(function () {
47
56
  jest.runOnlyPendingTimers();
48
57
  });
49
- component.update();
50
- expect(component.find(Component).exists()).toBe(true);
51
- expect(component.find(Component).prop('value')).toBe('123');
52
- expect(component.find(Placeholder).exists()).toBe(false);
58
+ expect(screen.getByTestId('test-value')).toBeInTheDocument();
59
+ expect(screen.queryByTestId('placeholder')).not.toBeInTheDocument();
53
60
  });
54
61
  describe('queueSizeThreshold behavior', function () {
55
62
  it('should not use context value.queueSizeThreshold by default', function () {
56
63
  var AsyncMountedComponent = withAsyncMount(Component);
57
- var component = mount(React.createElement(AsyncMountContext.Provider, { value: { enabled: true, queueSizeThreshold: 0 } },
58
- React.createElement(AsyncMountedComponent, { value: "123" }),
59
- React.createElement(AsyncMountedComponent, { value: "123" })));
60
- expect(component.find(Component).length).toBe(0);
64
+ render(React.createElement(AsyncMountContext.Provider, { value: { enabled: true, queueSizeThreshold: 0 } },
65
+ React.createElement(AsyncMountedComponent, { value: "test-value" }),
66
+ React.createElement(AsyncMountedComponent, { value: "test-value" })));
67
+ expect(screen.queryAllByTestId('test-value').length).toBe(0);
61
68
  act(function () {
62
69
  jest.runOnlyPendingTimers();
63
70
  });
64
- component.update();
65
- expect(component.find(Component).length).toBe(2);
71
+ expect(screen.queryAllByTestId('test-value').length).toBe(2);
66
72
  });
67
73
  it('should use async mount only after exceeding of "value.queueSizeThreshold" number of component mounts', function () {
68
74
  var AsyncMountedComponent = withAsyncMount(Component);
69
- var component = mount(React.createElement(AsyncMountContext.Provider, { value: { enabled: true, queueSizeThreshold: 2 } },
70
- React.createElement(AsyncMountedComponent, { value: "123" }),
71
- React.createElement(AsyncMountedComponent, { value: "123" })));
72
- expect(component.find(Component).length).toBe(2);
75
+ var Providers = function (_a) {
76
+ var children = _a.children;
77
+ return (React.createElement(AsyncMountContext.Provider, { value: { enabled: true, queueSizeThreshold: 2 } }, children));
78
+ };
79
+ render(React.createElement(React.Fragment, null,
80
+ React.createElement(AsyncMountedComponent, { value: "test-value" }),
81
+ React.createElement(AsyncMountedComponent, { value: "test-value" }),
82
+ React.createElement(AsyncMountedComponent, { value: "test-value" })), { wrapper: Providers });
83
+ expect(screen.queryAllByTestId('test-value').length).toBe(2);
73
84
  act(function () {
74
85
  jest.runOnlyPendingTimers();
75
86
  });
76
- component.update();
77
- expect(component.find(Component).length).toBe(2);
78
- component = mount(React.createElement(AsyncMountContext.Provider, { value: { enabled: true, queueSizeThreshold: 2 } },
79
- React.createElement(AsyncMountedComponent, { value: "123" }),
80
- React.createElement(AsyncMountedComponent, { value: "123" }),
81
- React.createElement(AsyncMountedComponent, { value: "123" })));
82
- expect(component.find(Component).length).toBe(2);
83
- act(function () {
84
- jest.runOnlyPendingTimers();
85
- });
86
- component.update();
87
- expect(component.find(Component).length).toBe(3);
87
+ expect(screen.queryAllByTestId('test-value').length).toBe(3);
88
88
  });
89
89
  });
90
90
  });
@@ -1,29 +1,118 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
23
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
1
48
  import React from 'react';
2
- import { mount } from 'enzyme';
3
- import { SmallIconButtonWithTooltip } from '../SmallIconButton';
4
- import IgnoredIcon from '../icons/Ignored';
5
- import IgnoredOutlinedIcon from '../icons/IgnoredOutlined';
49
+ import { render, screen } from '@testing-library/react';
50
+ import userEvent from '@testing-library/user-event';
6
51
  import { IgnoreButton } from './IgnoreButton';
7
52
  describe('Ignore button test', function () {
8
- var component, onClickFn;
9
- var getButton = function (component) { return component.find(SmallIconButtonWithTooltip); };
53
+ var onClickSpy = jest.fn();
10
54
  beforeEach(function () {
11
- onClickFn = jest.fn();
12
- component = mount(React.createElement(IgnoreButton, { isIgnored: false, onClick: onClickFn }));
13
- });
14
- it('should pass button props correctly', function () {
15
- expect(getButton(component).prop('onClick')).toBe(onClickFn);
16
- component.setProps({ disabled: true });
17
- expect(getButton(component).prop('disabled')).toBe(true);
55
+ jest.clearAllMocks();
18
56
  });
57
+ var setUp = function (props) {
58
+ if (props === void 0) { props = {}; }
59
+ var user = userEvent.setup();
60
+ render(React.createElement(IgnoreButton, __assign({ isIgnored: false, onClick: onClickSpy }, props)));
61
+ return { user: user };
62
+ };
63
+ it('should pass button props correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
64
+ var user, button;
65
+ return __generator(this, function (_a) {
66
+ switch (_a.label) {
67
+ case 0:
68
+ user = setUp().user;
69
+ button = screen.getByRole('button');
70
+ expect(button).toBeEnabled();
71
+ return [4 /*yield*/, user.click(button)];
72
+ case 1:
73
+ _a.sent();
74
+ expect(onClickSpy).toHaveBeenCalledTimes(1);
75
+ return [2 /*return*/];
76
+ }
77
+ });
78
+ }); });
19
79
  it('should show correct icon', function () {
20
- expect(getButton(component).prop('icon')).toBe(IgnoredOutlinedIcon);
21
- component.setProps({ isIgnored: true });
22
- expect(getButton(component).prop('icon')).toBe(IgnoredIcon);
80
+ setUp();
81
+ expect(screen.getByTestId('SvgIgnoredOutlined')).toBeInTheDocument();
23
82
  });
24
- it('should show correct tooltip', function () {
25
- expect(getButton(component).prop('tooltipTitle')).toBe('Ignore');
26
- component.setProps({ disabled: true });
27
- expect(getButton(component).prop('tooltipTitle')).toBe("You don't have permissions to ignore");
83
+ it('should show correct icon when ignored', function () {
84
+ setUp({ isIgnored: true });
85
+ expect(screen.getByTestId('SvgIgnored')).toBeInTheDocument();
28
86
  });
87
+ it('should show correct tooltip', function () { return __awaiter(void 0, void 0, void 0, function () {
88
+ var user, button;
89
+ return __generator(this, function (_a) {
90
+ switch (_a.label) {
91
+ case 0:
92
+ user = setUp().user;
93
+ button = screen.getByRole('button');
94
+ return [4 /*yield*/, user.hover(button)];
95
+ case 1:
96
+ _a.sent();
97
+ expect(screen.getByText('Ignore')).toBeInTheDocument();
98
+ return [2 /*return*/];
99
+ }
100
+ });
101
+ }); });
102
+ it('should show correct tooltip when disabled', function () { return __awaiter(void 0, void 0, void 0, function () {
103
+ var user, button;
104
+ return __generator(this, function (_a) {
105
+ switch (_a.label) {
106
+ case 0:
107
+ user = setUp({ disabled: true }).user;
108
+ button = screen.getByRole('button');
109
+ return [4 /*yield*/, user.hover(button)];
110
+ case 1:
111
+ _a.sent();
112
+ expect(button).toBeDisabled();
113
+ expect(screen.getByText("You don't have permissions to ignore")).toBeInTheDocument();
114
+ return [2 /*return*/];
115
+ }
116
+ });
117
+ }); });
29
118
  });
package/Image/Image.d.ts CHANGED
@@ -8,5 +8,5 @@ type Props = {
8
8
  overlay?: React.ReactNode;
9
9
  onClick?: () => void;
10
10
  };
11
- declare const _default: React.MemoExoticComponent<(props: Props) => React.JSX.Element>;
11
+ declare const _default: React.MemoExoticComponent<({ src, className, containerClassName, size, overlay, ...otherProps }: Props) => React.JSX.Element>;
12
12
  export default _default;
package/Image/Image.js CHANGED
@@ -28,12 +28,12 @@ import { isEmptyValue } from '@reltio/mdm-sdk';
28
28
  import { ImageSizesStyles } from './constants';
29
29
  import { RequestStates } from '../types';
30
30
  import { useStyles } from './styles';
31
- var Image = function (props) {
32
- var _a;
33
- var src = props.src, className = props.className, containerClassName = props.containerClassName, _b = props.size, size = _b === void 0 ? ImageSizesStyles.SMALL : _b, _c = props.overlay, overlay = _c === void 0 ? null : _c, otherProps = __rest(props, ["src", "className", "containerClassName", "size", "overlay"]);
31
+ var Image = function (_a) {
32
+ var _b;
33
+ var src = _a.src, className = _a.className, containerClassName = _a.containerClassName, _c = _a.size, size = _c === void 0 ? ImageSizesStyles.SMALL : _c, _d = _a.overlay, overlay = _d === void 0 ? null : _d, otherProps = __rest(_a, ["src", "className", "containerClassName", "size", "overlay"]);
34
34
  var sizeStyles = size || ImageSizesStyles.SMALL;
35
35
  var styles = useStyles(sizeStyles);
36
- var _d = useState(RequestStates.LOADING), imageLoadingState = _d[0], setImageLoadingState = _d[1];
36
+ var _e = useState(RequestStates.LOADING), imageLoadingState = _e[0], setImageLoadingState = _e[1];
37
37
  useEffect(function () {
38
38
  setImageLoadingState(RequestStates.LOADING);
39
39
  }, [src]);
@@ -47,10 +47,10 @@ var Image = function (props) {
47
47
  var imageIsLoaded = imageLoadingState === RequestStates.LOADED;
48
48
  var imageLoadingError = imageLoadingState === RequestStates.ERROR;
49
49
  return imageLoadingError ? (React.createElement("div", __assign({ className: classnames(styles.defaultContainer, styles.image, className) }, otherProps),
50
- React.createElement(NotAvailableImage, { className: styles.defaultImage }))) : (React.createElement("div", { className: classnames(styles.root, containerClassName) },
51
- !isEmptyValue(src) && (React.createElement("img", __assign({ src: src, className: classnames(styles.image, className, (_a = {},
52
- _a[styles.hideImage] = imageIsLoading,
53
- _a)), onLoad: onImageLoad, onError: onImageLoadFail, alt: 'image' }, otherProps))),
50
+ React.createElement(NotAvailableImage, { "data-reltio-id": "not-available-image", className: styles.defaultImage }))) : (React.createElement("div", { className: classnames(styles.root, containerClassName) },
51
+ !isEmptyValue(src) && (React.createElement("img", __assign({ src: src, className: classnames(styles.image, className, (_b = {},
52
+ _b[styles.hideImage] = imageIsLoading,
53
+ _b)), onLoad: onImageLoad, onError: onImageLoadFail, alt: 'image' }, otherProps))),
54
54
  imageIsLoading && (React.createElement("div", __assign({ className: classnames(styles.defaultContainer, styles.image, className) }, otherProps),
55
55
  React.createElement(DefaultImage, { className: styles.defaultImage }))),
56
56
  imageIsLoaded && overlay));
@@ -1,65 +1,60 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  import React from 'react';
2
- import { shallow } from 'enzyme';
3
- import { act } from 'react-dom/test-utils';
4
- import DefaultImage from '../icons/DefaultImage';
5
- import NotAvailableImage from '@mui/icons-material/BrokenImage';
6
- import { rerenderWrapper } from '../test-utils';
13
+ import { render, screen, fireEvent } from '@testing-library/react';
7
14
  import Image from './Image';
15
+ var setUp = function (props) {
16
+ if (props === void 0) { props = {}; }
17
+ return render(React.createElement(Image, __assign({ src: 'path' }, props)));
18
+ };
8
19
  describe('Image tests', function () {
9
20
  it('should render main parts', function () {
10
- var component = shallow(React.createElement(Image, { src: 'path' }));
11
- expect(component.find('img')).toHaveLength(1);
21
+ setUp();
22
+ expect(screen.getByRole('img')).toBeInTheDocument();
12
23
  });
13
24
  it('should render default image', function () {
14
- var component = shallow(React.createElement(Image, { src: '' }));
15
- expect(component.find('img')).toHaveLength(0);
16
- expect(component.find('.defaultContainer')).toHaveLength(1);
17
- expect(component.find(DefaultImage)).toHaveLength(1);
25
+ setUp({ src: '' });
26
+ expect(screen.queryByRole('img')).not.toBeInTheDocument();
27
+ expect(screen.getByTestId('SvgDefaultImage')).toBeInTheDocument();
18
28
  });
19
29
  it('should reset "default image" state after src prop changing', function () {
20
- var component = shallow(React.createElement(Image, { src: '' }));
21
- expect(component.find('img')).toHaveLength(0);
22
- expect(component.find('.defaultContainer')).toHaveLength(1);
23
- expect(component.find(DefaultImage)).toHaveLength(1);
24
- component.setProps({ src: '123' });
25
- component.update();
26
- var image = component.find('img');
27
- expect(image).toHaveLength(1);
28
- expect(image.prop('className')).toContain('hideImage');
29
- expect(component.find('.defaultContainer')).toHaveLength(1);
30
- expect(component.find(DefaultImage)).toHaveLength(1);
31
- act(function () {
32
- component.find('img').simulate('load');
33
- });
34
- rerenderWrapper(component);
35
- expect(component.find('img')).toHaveLength(1);
36
- expect(component.find('.defaultContainer')).toHaveLength(0);
30
+ var rerender = setUp({ src: '' }).rerender;
31
+ expect(screen.queryByRole('img')).not.toBeInTheDocument();
32
+ expect(screen.getByTestId('SvgDefaultImage')).toBeInTheDocument();
33
+ rerender(React.createElement(Image, { src: '123' }));
34
+ var image = screen.getByRole('img');
35
+ expect(image).toBeInTheDocument();
36
+ expect(image).toHaveClass('hideImage');
37
+ fireEvent.load(image);
38
+ expect(screen.queryByTestId('default-container')).not.toBeInTheDocument();
37
39
  });
38
40
  it('should reset "default image" state when image loading was unsuccessful', function () {
39
- var component = shallow(React.createElement(Image, { src: '123' }));
40
- var image = component.find('img');
41
- expect(image).toHaveLength(1);
42
- expect(image.prop('className')).toContain('hideImage');
43
- expect(component.find('.defaultContainer')).toHaveLength(1);
44
- expect(component.find(DefaultImage)).toHaveLength(1);
45
- expect(component.find(NotAvailableImage)).toHaveLength(0);
46
- act(function () {
47
- image.simulate('error');
48
- });
49
- rerenderWrapper(component);
50
- expect(component.find('img')).toHaveLength(0);
51
- expect(component.find('.defaultContainer')).toHaveLength(1);
52
- expect(component.find(NotAvailableImage)).toHaveLength(1);
53
- expect(component.find(DefaultImage)).toHaveLength(0);
41
+ setUp({ src: '123' });
42
+ var image = screen.getByRole('img');
43
+ expect(image).toBeInTheDocument();
44
+ expect(image).toHaveClass('hideImage');
45
+ expect(screen.getByTestId('SvgDefaultImage')).toBeInTheDocument();
46
+ expect(screen.queryByTestId('not-available-image')).not.toBeInTheDocument();
47
+ fireEvent.error(image);
48
+ expect(screen.queryByRole('img')).not.toBeInTheDocument();
49
+ expect(screen.getByTestId('not-available-image')).toBeInTheDocument();
50
+ expect(screen.queryByTestId('SvgDefaultImage')).not.toBeInTheDocument();
54
51
  });
55
52
  it('should render overlay if image is loaded', function () {
56
- var overlay = React.createElement("div", { className: "overlay" });
57
- var component = shallow(React.createElement(Image, { src: '123', overlay: overlay }));
58
- expect(component.find('.overlay')).toHaveLength(0);
59
- act(function () {
60
- component.find('img').simulate('load');
61
- });
62
- rerenderWrapper(component);
63
- expect(component.find('.overlay')).toHaveLength(1);
53
+ var overlay = React.createElement("div", { "data-reltio-id": "overlay" });
54
+ setUp({ src: '123', overlay: overlay });
55
+ expect(screen.queryByTestId('overlay')).not.toBeInTheDocument();
56
+ var image = screen.getByRole('img');
57
+ fireEvent.load(image);
58
+ expect(screen.getByTestId('overlay')).toBeInTheDocument();
64
59
  });
65
60
  });
@@ -48,8 +48,9 @@ var ImageActionsOverlay = function (props) {
48
48
  _a)), onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onClick: selectionMode ? toggleSelected(selected) : handleClick, "data-reltio-id": "image-actions-overlay" },
49
49
  showCheckBox && (React.createElement(CheckedIcon, { className: styles.checkedIcon, checked: selected, onClick: toggleSelected(selected) })),
50
50
  showActions && (React.createElement("div", { className: styles.actions },
51
- React.createElement(SmallIconButton, { onClick: onDownload, className: styles.actionButton, icon: DownloadIcon }),
51
+ React.createElement(SmallIconButton, { "data-reltio-id": "download-button", onClick: onDownload, className: styles.actionButton, icon: DownloadIcon }),
52
52
  React.createElement(DropDownMenuButton, { menuId: "image-overlay-actions-".concat(id), buttonComponent: SmallIconButton, buttonProps: {
53
+ 'data-reltio-id': 'image-overlay-actions',
53
54
  icon: MoreVertIcon,
54
55
  className: classnames(styles.actionButton, styles.dropDownMenuButton)
55
56
  }, menuItems: menuItems }))),