@reltio/components 1.4.2050 → 1.4.2052

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 (187) hide show
  1. package/AttributeListItem/AttributeListItem.d.ts +1 -1
  2. package/ChartTooltip/ChartTooltip.js +3 -3
  3. package/ColumnsSettings/ColumnsSettings.d.ts +2 -1
  4. package/ColumnsSettings/ColumnsSettings.js +2 -2
  5. package/ColumnsSettings/ColumnsSettings.test.js +14 -0
  6. package/ColumnsSettings/components/ColumnListItem/ColumnListItem.d.ts +11 -26
  7. package/ColumnsSettings/components/ColumnListItem/ColumnListItem.js +0 -14
  8. package/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.d.ts +2 -1
  9. package/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.js +2 -2
  10. package/DropDownMenuButton/DropDownMenuButton.js +1 -1
  11. package/HOCs/withAsyncMount/withAsyncMount.test.js +52 -52
  12. package/IgnoreButton/IgnoreButton.spec.js +109 -20
  13. package/Image/Image.d.ts +1 -1
  14. package/Image/Image.js +8 -8
  15. package/Image/Image.test.js +46 -51
  16. package/ImageActionsOverlay/ImageActionsOverlay.js +2 -1
  17. package/ImageActionsOverlay/ImageActionsOverlay.test.js +207 -125
  18. package/ImageActionsOverlay/components/CheckedIcon/CheckedIcon.js +1 -1
  19. package/ImageAttributesGallery/ImageAttributesGallery.test.js +525 -281
  20. package/ImageAttributesLine/ImageAttributesLine.js +1 -1
  21. package/ImageAttributesLine/ImageAttributesLine.test.js +187 -193
  22. package/ImageAttributesLine/imageAttributeValues.test-data.d.ts +10 -0
  23. package/ImageAttributesLine/imageAttributeValues.test-data.js +22 -0
  24. package/ImageAttributesLineEditor/ImageAttributesLineEditor.test.js +315 -298
  25. package/ImageDetailsView/ImageDetailsView.test.js +529 -55
  26. package/ImageDetailsView/attributes.test-data.d.ts +4 -1
  27. package/ImageDetailsView/attributes.test-data.js +98 -1
  28. package/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.js +2 -2
  29. package/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.js +1 -1
  30. package/ImageDetailsView/components/MetaInfoList/MetaInfoList.js +1 -1
  31. package/ImageDetailsView/components/Thumbnails/Thumbnails.js +1 -1
  32. package/ImageDetailsView/helpers.test.js +4 -4
  33. package/ImageGalleryDialog/ImageGalleryDialog.test.js +89 -46
  34. package/ImportButton/ImportButton.test.js +94 -24
  35. package/InlineAttributesList/InlineAttributesList.test.js +22 -62
  36. package/InlineAttributesList/attributes.test-data.d.ts +4 -2
  37. package/InlineAttributesList/attributes.test-data.js +40 -1
  38. package/InlineAttributesPager/InlineAttributesPager.d.ts +1 -2
  39. package/InlineAttributesPager/InlineAttributesPager.js +1 -4
  40. package/InlineAttributesPager/InlineAttributesPager.test.js +393 -183
  41. package/InlineComplexAttribute/InlineComplexAttribute.js +1 -1
  42. package/InlineComplexAttribute/InlineComplexAttribute.test.js +396 -182
  43. package/InlineImageAttribute/InlineImageAttribute.test.js +103 -55
  44. package/InlineNestedAttribute/InlineNestedAttribute.test.js +105 -43
  45. package/InlineReferenceAttribute/InlineReferenceAttribute.test.js +165 -107
  46. package/InlineSimpleAttribute/InlineSimpleAttribute.spec.js +352 -346
  47. package/InlineSimpleAttributeEditor/InlineSimpleAttributeEditor.test.js +285 -194
  48. package/InternalLink/InternalLink.test.js +41 -11
  49. package/LookupEditor/LookupEditor.test.js +180 -44
  50. package/LookupEditor/components/GroupedDropDownEditor/helpers.test.js +1 -1
  51. package/MapChart/MapChart.js +3 -8
  52. package/MapChart/MapChart.test.js +152 -188
  53. package/MapChart/components/Legend/Legend.js +3 -3
  54. package/MaskingSwitcher/MaskingSwitcher.js +1 -1
  55. package/MatchRulesBadge/MatchRulesBadge.test.js +93 -24
  56. package/SelectEditor/SelectEditor.d.ts +4 -10
  57. package/SelectEditor/SelectEditor.js +0 -4
  58. package/SelectEditor/SelectEditor.test.js +79 -9
  59. package/SelectionPopup/SelectionPopup.d.ts +2 -1
  60. package/SelectionPopup/SelectionPopup.js +3 -3
  61. package/SelectionPopup/SelectionPopup.spec.js +90 -30
  62. package/cjs/AttributeListItem/AttributeListItem.d.ts +1 -1
  63. package/cjs/ChartTooltip/ChartTooltip.js +3 -3
  64. package/cjs/ColumnsSettings/ColumnsSettings.d.ts +2 -1
  65. package/cjs/ColumnsSettings/ColumnsSettings.js +2 -2
  66. package/cjs/ColumnsSettings/ColumnsSettings.test.js +14 -0
  67. package/cjs/ColumnsSettings/components/ColumnListItem/ColumnListItem.d.ts +11 -26
  68. package/cjs/ColumnsSettings/components/ColumnListItem/ColumnListItem.js +0 -14
  69. package/cjs/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.d.ts +2 -1
  70. package/cjs/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.js +2 -2
  71. package/cjs/DropDownMenuButton/DropDownMenuButton.js +1 -1
  72. package/cjs/HOCs/withAsyncMount/withAsyncMount.test.js +56 -56
  73. package/cjs/IgnoreButton/IgnoreButton.spec.js +109 -20
  74. package/cjs/Image/Image.d.ts +1 -1
  75. package/cjs/Image/Image.js +8 -8
  76. package/cjs/Image/Image.test.js +46 -51
  77. package/cjs/ImageActionsOverlay/ImageActionsOverlay.js +2 -1
  78. package/cjs/ImageActionsOverlay/ImageActionsOverlay.test.js +207 -125
  79. package/cjs/ImageActionsOverlay/components/CheckedIcon/CheckedIcon.js +1 -1
  80. package/cjs/ImageAttributesGallery/ImageAttributesGallery.test.js +525 -281
  81. package/cjs/ImageAttributesLine/ImageAttributesLine.js +1 -1
  82. package/cjs/ImageAttributesLine/ImageAttributesLine.test.js +195 -224
  83. package/cjs/ImageAttributesLine/imageAttributeValues.test-data.d.ts +10 -0
  84. package/cjs/ImageAttributesLine/imageAttributeValues.test-data.js +23 -1
  85. package/cjs/ImageAttributesLineEditor/ImageAttributesLineEditor.test.js +316 -299
  86. package/cjs/ImageDetailsView/ImageDetailsView.test.js +529 -55
  87. package/cjs/ImageDetailsView/attributes.test-data.d.ts +4 -1
  88. package/cjs/ImageDetailsView/attributes.test-data.js +99 -2
  89. package/cjs/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.js +2 -2
  90. package/cjs/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.js +1 -1
  91. package/cjs/ImageDetailsView/components/MetaInfoList/MetaInfoList.js +1 -1
  92. package/cjs/ImageDetailsView/components/Thumbnails/Thumbnails.js +1 -1
  93. package/cjs/ImageDetailsView/helpers.test.js +3 -3
  94. package/cjs/ImageGalleryDialog/ImageGalleryDialog.test.js +89 -46
  95. package/cjs/ImportButton/ImportButton.test.js +94 -24
  96. package/cjs/InlineAttributesList/InlineAttributesList.test.js +22 -62
  97. package/cjs/InlineAttributesList/attributes.test-data.d.ts +4 -2
  98. package/cjs/InlineAttributesList/attributes.test-data.js +41 -2
  99. package/cjs/InlineAttributesPager/InlineAttributesPager.d.ts +1 -2
  100. package/cjs/InlineAttributesPager/InlineAttributesPager.js +1 -4
  101. package/cjs/InlineAttributesPager/InlineAttributesPager.test.js +393 -183
  102. package/cjs/InlineComplexAttribute/InlineComplexAttribute.js +1 -1
  103. package/cjs/InlineComplexAttribute/InlineComplexAttribute.test.js +395 -204
  104. package/cjs/InlineImageAttribute/InlineImageAttribute.test.js +103 -55
  105. package/cjs/InlineNestedAttribute/InlineNestedAttribute.test.js +105 -43
  106. package/cjs/InlineReferenceAttribute/InlineReferenceAttribute.test.js +164 -106
  107. package/cjs/InlineSimpleAttribute/InlineSimpleAttribute.spec.js +351 -345
  108. package/cjs/InlineSimpleAttributeEditor/InlineSimpleAttributeEditor.test.js +307 -193
  109. package/cjs/InternalLink/InternalLink.test.js +40 -10
  110. package/cjs/LookupEditor/LookupEditor.test.js +178 -65
  111. package/cjs/LookupEditor/components/GroupedDropDownEditor/helpers.test.js +1 -1
  112. package/cjs/MapChart/MapChart.js +3 -8
  113. package/cjs/MapChart/MapChart.test.js +152 -188
  114. package/cjs/MapChart/components/Legend/Legend.js +3 -3
  115. package/cjs/MaskingSwitcher/MaskingSwitcher.js +1 -1
  116. package/cjs/MatchRulesBadge/MatchRulesBadge.test.js +93 -24
  117. package/cjs/SelectEditor/SelectEditor.d.ts +4 -10
  118. package/cjs/SelectEditor/SelectEditor.js +0 -4
  119. package/cjs/SelectEditor/SelectEditor.test.js +79 -9
  120. package/cjs/SelectionPopup/SelectionPopup.d.ts +2 -1
  121. package/cjs/SelectionPopup/SelectionPopup.js +3 -3
  122. package/cjs/SelectionPopup/SelectionPopup.spec.js +90 -30
  123. package/cjs/hooks/useAsyncMount/useAsyncMount.d.ts +1 -1
  124. package/cjs/hooks/useAsyncMount/useAsyncMount.js +1 -1
  125. package/hooks/useAsyncMount/useAsyncMount.d.ts +1 -1
  126. package/hooks/useAsyncMount/useAsyncMount.js +1 -1
  127. package/package.json +1 -1
  128. package/HOCs/withTableContext/withTableContext.test.d.ts +0 -1
  129. package/HOCs/withTableContext/withTableContext.test.js +0 -41
  130. package/ImageAttributesGallery/components/GalleryView/GalleryView.test.d.ts +0 -1
  131. package/ImageAttributesGallery/components/GalleryView/GalleryView.test.js +0 -98
  132. package/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.test.d.ts +0 -1
  133. package/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.test.js +0 -99
  134. package/ImageDetailsView/components/ImageDetailsViewSidebar/ImageDetailsViewSidebar.test.d.ts +0 -1
  135. package/ImageDetailsView/components/ImageDetailsViewSidebar/ImageDetailsViewSidebar.test.js +0 -65
  136. package/ImageDetailsView/components/MetaInfo/MetaInfo.test.d.ts +0 -1
  137. package/ImageDetailsView/components/MetaInfo/MetaInfo.test.js +0 -306
  138. package/ImageDetailsView/components/MetaInfoForm/MetaInfoForm.test.d.ts +0 -1
  139. package/ImageDetailsView/components/MetaInfoForm/MetaInfoForm.test.js +0 -134
  140. package/ImageDetailsView/components/MetaInfoHeader/MetaInfoHeader.test.d.ts +0 -1
  141. package/ImageDetailsView/components/MetaInfoHeader/MetaInfoHeader.test.js +0 -99
  142. package/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.test.d.ts +0 -1
  143. package/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.test.js +0 -36
  144. package/ImageDetailsView/components/MetaInfoList/MetaInfoList.test.d.ts +0 -1
  145. package/ImageDetailsView/components/MetaInfoList/MetaInfoList.test.js +0 -161
  146. package/ImageDetailsView/components/Thumbnails/Thumbnails.test.d.ts +0 -1
  147. package/ImageDetailsView/components/Thumbnails/Thumbnails.test.js +0 -76
  148. package/InlineAttributesPager/components/InlineImageAttributesBlock/InlineImageAttributesBlock.test.d.ts +0 -1
  149. package/InlineAttributesPager/components/InlineImageAttributesBlock/InlineImageAttributesBlock.test.js +0 -104
  150. package/InlineAttributesPager/components/InlineNestedAttributesBlock/InlineNestedAttributesBlock.test.d.ts +0 -1
  151. package/InlineAttributesPager/components/InlineNestedAttributesBlock/InlineNestedAttributesBlock.test.js +0 -114
  152. package/InlineAttributesPager/components/InlineReferenceAttributesBlock/InlineReferenceAttributesBlock.test.d.ts +0 -1
  153. package/InlineAttributesPager/components/InlineReferenceAttributesBlock/InlineReferenceAttributesBlock.test.js +0 -177
  154. package/InlineSimpleAttribute/components/CrosswalkMenuItem/CrosswalkMenuItem.spec.d.ts +0 -1
  155. package/InlineSimpleAttribute/components/CrosswalkMenuItem/CrosswalkMenuItem.spec.js +0 -52
  156. package/LookupEditor/components/GroupedDropDownEditor/GroupedDropDownEditor.test.d.ts +0 -1
  157. package/LookupEditor/components/GroupedDropDownEditor/GroupedDropDownEditor.test.js +0 -37
  158. package/cjs/HOCs/withTableContext/withTableContext.test.d.ts +0 -1
  159. package/cjs/HOCs/withTableContext/withTableContext.test.js +0 -46
  160. package/cjs/ImageAttributesGallery/components/GalleryView/GalleryView.test.d.ts +0 -1
  161. package/cjs/ImageAttributesGallery/components/GalleryView/GalleryView.test.js +0 -103
  162. package/cjs/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.test.d.ts +0 -1
  163. package/cjs/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.test.js +0 -104
  164. package/cjs/ImageDetailsView/components/ImageDetailsViewSidebar/ImageDetailsViewSidebar.test.d.ts +0 -1
  165. package/cjs/ImageDetailsView/components/ImageDetailsViewSidebar/ImageDetailsViewSidebar.test.js +0 -70
  166. package/cjs/ImageDetailsView/components/MetaInfo/MetaInfo.test.d.ts +0 -1
  167. package/cjs/ImageDetailsView/components/MetaInfo/MetaInfo.test.js +0 -311
  168. package/cjs/ImageDetailsView/components/MetaInfoForm/MetaInfoForm.test.d.ts +0 -1
  169. package/cjs/ImageDetailsView/components/MetaInfoForm/MetaInfoForm.test.js +0 -139
  170. package/cjs/ImageDetailsView/components/MetaInfoHeader/MetaInfoHeader.test.d.ts +0 -1
  171. package/cjs/ImageDetailsView/components/MetaInfoHeader/MetaInfoHeader.test.js +0 -104
  172. package/cjs/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.test.d.ts +0 -1
  173. package/cjs/ImageDetailsView/components/MetaInfoItem/MetaInfoItem.test.js +0 -41
  174. package/cjs/ImageDetailsView/components/MetaInfoList/MetaInfoList.test.d.ts +0 -1
  175. package/cjs/ImageDetailsView/components/MetaInfoList/MetaInfoList.test.js +0 -166
  176. package/cjs/ImageDetailsView/components/Thumbnails/Thumbnails.test.d.ts +0 -1
  177. package/cjs/ImageDetailsView/components/Thumbnails/Thumbnails.test.js +0 -81
  178. package/cjs/InlineAttributesPager/components/InlineImageAttributesBlock/InlineImageAttributesBlock.test.d.ts +0 -1
  179. package/cjs/InlineAttributesPager/components/InlineImageAttributesBlock/InlineImageAttributesBlock.test.js +0 -109
  180. package/cjs/InlineAttributesPager/components/InlineNestedAttributesBlock/InlineNestedAttributesBlock.test.d.ts +0 -1
  181. package/cjs/InlineAttributesPager/components/InlineNestedAttributesBlock/InlineNestedAttributesBlock.test.js +0 -119
  182. package/cjs/InlineAttributesPager/components/InlineReferenceAttributesBlock/InlineReferenceAttributesBlock.test.d.ts +0 -1
  183. package/cjs/InlineAttributesPager/components/InlineReferenceAttributesBlock/InlineReferenceAttributesBlock.test.js +0 -182
  184. package/cjs/InlineSimpleAttribute/components/CrosswalkMenuItem/CrosswalkMenuItem.spec.d.ts +0 -1
  185. package/cjs/InlineSimpleAttribute/components/CrosswalkMenuItem/CrosswalkMenuItem.spec.js +0 -57
  186. package/cjs/LookupEditor/components/GroupedDropDownEditor/GroupedDropDownEditor.test.d.ts +0 -1
  187. package/cjs/LookupEditor/components/GroupedDropDownEditor/GroupedDropDownEditor.test.js +0 -42
@@ -74,36 +74,65 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
74
74
  };
75
75
  Object.defineProperty(exports, "__esModule", { value: true });
76
76
  var react_1 = __importDefault(require("react"));
77
- var enzyme_1 = require("enzyme");
78
- var test_utils_1 = require("react-dom/test-utils");
79
- var MoreVert_1 = __importDefault(require("@mui/icons-material/MoreVert"));
80
- var DataTypeValue_1 = require("../DataTypeValue");
81
- var DropDownMenuButton_1 = require("../DropDownMenuButton");
82
- var IgnoreButton_1 = require("../IgnoreButton");
83
- var PinButton_1 = require("../PinButton");
77
+ var react_2 = require("@testing-library/react");
78
+ var user_event_1 = __importDefault(require("@testing-library/user-event"));
84
79
  var InlineSimpleAttribute_1 = require("./InlineSimpleAttribute");
85
80
  var crosswalksDisplay = __importStar(require("../contexts/CrosswalksDisplayContext"));
86
- var InlineSimpleAttributeEditor_1 = require("../InlineSimpleAttributeEditor");
87
81
  var mdm_sdk_1 = require("@reltio/mdm-sdk");
88
82
  var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
89
- jest.mock('../InlineSimpleAttributeEditor', function () { return ({
90
- InlineSimpleAttributeEditor: jest.fn().mockReturnValue(react_1.default.createElement(react_1.default.Fragment, null))
91
- }); });
92
- jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { debounce: function (x) { return x; }, isCrosswalkDisabled: jest.fn() })); });
93
- var setUp = function (props) {
94
- var Component = function (props) {
95
- return (react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { values: {} },
96
- react_1.default.createElement(InlineSimpleAttribute_1.InlineSimpleAttribute, __assign({}, props))));
83
+ jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { debounce: function (x) { return x; } })); });
84
+ var defaultProps = {
85
+ attributeValue: {
86
+ type: 'configuration/entityTypes/Franchise/attributes/String',
87
+ ov: true,
88
+ value: 'Test',
89
+ uri: 'entities/123/attributes/String/123'
90
+ },
91
+ attributeType: {
92
+ label: 'String',
93
+ access: ['CREATE', 'UPDATE', 'DELETE', 'READ'],
94
+ type: 'String',
95
+ name: 'String',
96
+ uri: 'configuration/entityTypes/Franchise/attributes/String'
97
+ },
98
+ crosswalk: {
99
+ uri: 'entities/10wb4hEF/crosswalks/1PPwRPuk.3h28qA5Qw',
100
+ type: 'configuration/sources/Reltio',
101
+ value: '1PPwRPuk',
102
+ attributes: ['123/attributes/String/123']
103
+ },
104
+ isEmpty: false,
105
+ onIgnore: jest.fn(),
106
+ onEdit: jest.fn(),
107
+ onPin: jest.fn(),
108
+ onDelete: jest.fn()
109
+ };
110
+ var metadata = {
111
+ entityTypes: [],
112
+ sources: []
113
+ };
114
+ var setUp = function (props, skipHover) {
115
+ if (props === void 0) { props = {}; }
116
+ if (skipHover === void 0) { skipHover = false; }
117
+ var user = user_event_1.default.setup({ skipHover: skipHover });
118
+ var Providers = function (_a) {
119
+ var children = _a.children;
120
+ return (react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { values: { metadata: metadata } }, children));
97
121
  };
98
- return (0, enzyme_1.mount)(react_1.default.createElement(Component, __assign({}, props)));
122
+ return __assign({ user: user }, (0, react_2.render)(react_1.default.createElement(InlineSimpleAttribute_1.InlineSimpleAttribute, __assign({}, defaultProps, props)), { wrapper: Providers }));
99
123
  };
100
124
  describe('Inline simple attribute tests', function () {
101
- var actions, value, attributeType;
102
125
  var color = '#ff00ff';
103
126
  var highlightCrosswalk = jest.fn();
104
127
  var removeHighlight = jest.fn();
105
- beforeAll(function () {
128
+ var toggleCrosswalkFocus = jest.fn();
129
+ beforeEach(function () {
130
+ jest.clearAllMocks();
106
131
  jest.spyOn(crosswalksDisplay, 'useCrosswalkColor').mockReturnValue(color);
132
+ jest.spyOn(crosswalksDisplay, 'useCrosswalkFocus').mockReturnValue({
133
+ isFocused: false,
134
+ toggleCrosswalkFocus: toggleCrosswalkFocus
135
+ });
107
136
  jest.spyOn(crosswalksDisplay, 'useCrosswalkHighlight').mockReturnValue({
108
137
  isHighlighted: true,
109
138
  isDimmed: true,
@@ -111,372 +140,349 @@ describe('Inline simple attribute tests', function () {
111
140
  removeHighlight: removeHighlight
112
141
  });
113
142
  });
114
- beforeEach(function () {
115
- actions = {
116
- onIgnore: jest.fn(),
117
- onEdit: jest.fn(),
118
- onPin: jest.fn(),
119
- onDelete: jest.fn()
120
- };
121
- value = {
122
- type: 'configuration/entityTypes/Franchise/attributes/String',
123
- ov: true,
124
- value: 'Test',
125
- uri: 'entities/123/attributes/String/123'
126
- };
127
- attributeType = {
128
- label: 'String',
129
- access: ['CREATE', 'UPDATE', 'DELETE', 'READ'],
130
- type: 'String',
131
- name: 'String',
132
- uri: 'configuration/entityTypes/Franchise/attributes/String'
133
- };
134
- mdm_sdk_1.isCrosswalkDisabled.mockReturnValue(false);
135
- });
136
- var crosswalk = {
137
- uri: 'entities/10wb4hEF/crosswalks/1PPwRPuk.3h28qA5Qw',
138
- type: 'configuration/sources/Reltio',
139
- value: '1PPwRPuk',
140
- createDate: '2021-05-14T05:21:14.532Z',
141
- updateDate: '2021-05-14T05:21:14.532Z',
142
- reltioLoadDate: '2019-07-24T06:18:18.041Z',
143
- singleAttributeUpdateDates: {
144
- '123/attributes/String/123': '2021-07-08T07:09:14.781Z'
145
- },
146
- attributes: ['123/attributes/String/123']
147
- };
148
143
  it('should render attribute and hide actions', function () {
149
- var props = __assign({ attributeValue: value, attributeType: attributeType, crosswalk: crosswalk }, actions);
150
- var wrapper = setUp(props);
151
- expect(wrapper.find(DataTypeValue_1.DataTypeValue).prop('value')).toBe('Test');
152
- expect(wrapper.find(PinButton_1.PinButton).length).toBe(0);
153
- expect(wrapper.find(IgnoreButton_1.IgnoreButton).length).toBe(0);
154
- expect(wrapper.find(DropDownMenuButton_1.DropDownMenuButton).length).toBe(0);
155
- expect(crosswalksDisplay.useCrosswalkColor).toHaveBeenCalledWith(crosswalk);
156
- expect(wrapper.find(InlineSimpleAttributeEditor_1.InlineSimpleAttributeEditor)).toHaveLength(0);
157
- });
158
- it('should render actions on hover', function () {
159
- var props = __assign({ attributeValue: value, attributeType: attributeType, crosswalk: crosswalk, className: 'simpleAttribute' }, actions);
160
- var wrapper = setUp(props);
161
- (0, test_utils_1.act)(function () {
162
- wrapper.find('.root').simulate('mouseenter');
163
- });
164
- wrapper.update();
165
- expect(wrapper.find(DataTypeValue_1.DataTypeValue).prop('value')).toBe('Test');
166
- expect(wrapper.find(PinButton_1.PinButton).length).toBe(1);
167
- expect(wrapper.find(IgnoreButton_1.IgnoreButton).length).toBe(1);
168
- expect(wrapper.find(DropDownMenuButton_1.DropDownMenuButton).prop('buttonProps')).toMatchObject({
169
- icon: MoreVert_1.default,
170
- tooltipTitle: 'More actions'
171
- });
172
- expect(highlightCrosswalk).toHaveBeenCalledTimes(1);
144
+ setUp();
145
+ expect(react_2.screen.getByText('Test')).toBeInTheDocument();
146
+ expect(react_2.screen.queryByLabelText('Pin')).not.toBeInTheDocument();
147
+ expect(react_2.screen.queryByLabelText('Ignore')).not.toBeInTheDocument();
148
+ expect(react_2.screen.queryByLabelText('More actions')).not.toBeInTheDocument();
149
+ expect(react_2.screen.queryByTestId('masking-switcher')).not.toBeInTheDocument();
150
+ expect(crosswalksDisplay.useCrosswalkColor).toHaveBeenCalledWith(defaultProps.crosswalk);
151
+ expect(react_2.screen.queryByTestId('inline-simple-attribute-editor')).not.toBeInTheDocument();
173
152
  });
174
- it('should hide actions on mouse leave', function () {
175
- var props = __assign({ attributeValue: value, attributeType: attributeType, crosswalk: crosswalk, className: 'simpleAttribute' }, actions);
176
- var wrapper = setUp(props);
177
- (0, test_utils_1.act)(function () {
178
- wrapper.find('.root').simulate('mouseenter');
153
+ it('should render actions on hover', function () { return __awaiter(void 0, void 0, void 0, function () {
154
+ var user;
155
+ return __generator(this, function (_a) {
156
+ switch (_a.label) {
157
+ case 0:
158
+ user = setUp().user;
159
+ return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
160
+ case 1:
161
+ _a.sent();
162
+ expect(react_2.screen.getByText('Test')).toBeInTheDocument();
163
+ expect(react_2.screen.getByLabelText('Pin')).toBeInTheDocument();
164
+ expect(react_2.screen.getByTestId('SvgPinOutlined')).toBeInTheDocument();
165
+ expect(react_2.screen.getByLabelText('Ignore')).toBeInTheDocument();
166
+ expect(react_2.screen.getByTestId('SvgIgnoredOutlined')).toBeInTheDocument();
167
+ expect(react_2.screen.getByLabelText('More actions')).toBeInTheDocument();
168
+ expect(highlightCrosswalk).toHaveBeenCalledTimes(1);
169
+ return [2 /*return*/];
170
+ }
179
171
  });
180
- wrapper.update();
181
- (0, test_utils_1.act)(function () {
182
- wrapper.find('.root').simulate('mouseleave');
172
+ }); });
173
+ it('should hide actions on mouse leave', function () { return __awaiter(void 0, void 0, void 0, function () {
174
+ var user;
175
+ return __generator(this, function (_a) {
176
+ switch (_a.label) {
177
+ case 0:
178
+ user = setUp().user;
179
+ return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
180
+ case 1:
181
+ _a.sent();
182
+ expect(react_2.screen.getByLabelText('Pin')).toBeInTheDocument();
183
+ expect(highlightCrosswalk).toHaveBeenCalledTimes(1);
184
+ return [4 /*yield*/, user.unhover(react_2.screen.getByText('Test'))];
185
+ case 2:
186
+ _a.sent();
187
+ expect(react_2.screen.queryByLabelText('Pin')).not.toBeInTheDocument();
188
+ expect(removeHighlight).toHaveBeenCalledTimes(1);
189
+ return [2 /*return*/];
190
+ }
183
191
  });
184
- wrapper.update();
185
- expect(wrapper.find(PinButton_1.PinButton).length).toBe(0);
186
- expect(wrapper.find(IgnoreButton_1.IgnoreButton).length).toBe(0);
187
- expect(wrapper.find(DropDownMenuButton_1.DropDownMenuButton).length).toBe(0);
188
- expect(removeHighlight).toHaveBeenCalledTimes(1);
189
- });
192
+ }); });
190
193
  it('should show pin in pinned state even if no hover', function () {
191
- value.pin = true;
192
- var props = __assign({ attributeValue: value, attributeType: attributeType, crosswalk: crosswalk, className: 'simpleAttribute' }, actions);
193
- var wrapper = setUp(props);
194
- expect(wrapper.find(PinButton_1.PinButton).length).toBe(1);
195
- expect(wrapper.find(PinButton_1.PinButton).prop('isPinned')).toBeTruthy();
196
- expect(wrapper.find(PinButton_1.PinButton).prop('disabled')).toBeFalsy();
194
+ setUp({ attributeValue: __assign(__assign({}, defaultProps.attributeValue), { pin: true }) });
195
+ expect(react_2.screen.getByLabelText('Pin')).not.toBeDisabled();
196
+ expect(react_2.screen.getByTestId('SvgPin')).toBeInTheDocument();
197
197
  });
198
198
  it('should show ignore in ignored state even if no hover', function () {
199
- value.ignored = true;
200
- var props = __assign({ attributeValue: value, attributeType: attributeType, crosswalk: crosswalk, className: 'simpleAttribute' }, actions);
201
- var wrapper = setUp(props);
202
- expect(wrapper.find(IgnoreButton_1.IgnoreButton).length).toBe(1);
203
- expect(wrapper.find(IgnoreButton_1.IgnoreButton).prop('isIgnored')).toBeTruthy();
204
- expect(wrapper.find(IgnoreButton_1.IgnoreButton).prop('disabled')).toBeFalsy();
205
- });
206
- it('should show actions with all actions if attribute type allows actions', function () {
207
- var props = __assign({ attributeValue: value, attributeType: attributeType, crosswalk: crosswalk, className: 'simpleAttribute' }, actions);
208
- var wrapper = setUp(props);
209
- var event = {};
210
- (0, test_utils_1.act)(function () {
211
- var _a;
212
- (_a = wrapper.find('.simpleAttribute').at(2).prop('onMouseEnter')) === null || _a === void 0 ? void 0 : _a(event);
213
- });
214
- wrapper.update();
215
- var actionsItems = wrapper.find(DropDownMenuButton_1.DropDownMenuButton).prop('menuItems');
216
- expect(actionsItems === null || actionsItems === void 0 ? void 0 : actionsItems[1]).toMatchObject({
217
- disabled: false,
218
- text: 'Edit',
219
- tooltip: null
220
- });
221
- expect(actionsItems === null || actionsItems === void 0 ? void 0 : actionsItems[2]).toMatchObject({
222
- disabled: false,
223
- text: 'Delete',
224
- tooltip: null
225
- });
226
- expect(actionsItems === null || actionsItems === void 0 ? void 0 : actionsItems[0]).toStrictEqual({
227
- color: color,
228
- crosswalk: crosswalk
229
- });
230
- });
231
- it('should disable actions based on attribute type permissions', function () {
232
- attributeType.access = ['READ'];
233
- var props = __assign({ attributeValue: value, attributeType: attributeType, crosswalk: crosswalk, className: 'simpleAttribute' }, actions);
234
- var wrapper = setUp(props);
235
- var event = {};
236
- (0, test_utils_1.act)(function () {
237
- var _a;
238
- (_a = wrapper.find('.simpleAttribute').at(2).prop('onMouseEnter')) === null || _a === void 0 ? void 0 : _a(event);
239
- });
240
- wrapper.update();
241
- var actionsItems = wrapper.find(DropDownMenuButton_1.DropDownMenuButton).prop('menuItems');
242
- expect(actionsItems === null || actionsItems === void 0 ? void 0 : actionsItems[1]).toMatchObject({
243
- disabled: true,
244
- text: 'Edit',
245
- tooltip: "You don't have permissions to edit"
246
- });
247
- expect(actionsItems === null || actionsItems === void 0 ? void 0 : actionsItems[2]).toMatchObject({
248
- disabled: true,
249
- text: 'Delete',
250
- tooltip: "You don't have permissions to delete"
251
- });
252
- expect(wrapper.find(IgnoreButton_1.IgnoreButton).length).toBe(0);
253
- expect(wrapper.find(PinButton_1.PinButton).length).toBe(0);
254
- wrapper.setProps({
255
- attributeValue: __assign(__assign({}, value), { pin: true, ignored: true })
256
- });
257
- expect(wrapper.find(IgnoreButton_1.IgnoreButton).prop('disabled')).toBe(true);
258
- expect(wrapper.find(PinButton_1.PinButton).prop('disabled')).toBe(true);
259
- });
260
- it('should disable delete action if props.disableDelete is true', function () {
261
- var props = __assign({ attributeValue: value, attributeType: attributeType, crosswalk: crosswalk, className: 'simpleAttribute', disableDelete: true }, actions);
262
- var wrapper = setUp(props);
263
- var event = {};
264
- (0, test_utils_1.act)(function () {
265
- var _a;
266
- (_a = wrapper.find('.simpleAttribute').at(2).prop('onMouseEnter')) === null || _a === void 0 ? void 0 : _a(event);
267
- });
268
- wrapper.update();
269
- var actionsItems = wrapper.find(DropDownMenuButton_1.DropDownMenuButton).prop('menuItems');
270
- expect(actionsItems === null || actionsItems === void 0 ? void 0 : actionsItems[1]).toMatchObject({
271
- disabled: false,
272
- text: 'Edit',
273
- tooltip: null
274
- });
275
- expect(actionsItems === null || actionsItems === void 0 ? void 0 : actionsItems[2]).toMatchObject({
276
- disabled: true,
277
- text: 'Delete',
278
- tooltip: "You don't have permissions to delete"
279
- });
280
- expect(wrapper.find(IgnoreButton_1.IgnoreButton).length).toBe(1);
281
- expect(wrapper.find(PinButton_1.PinButton).length).toBe(1);
199
+ setUp({ attributeValue: __assign(__assign({}, defaultProps.attributeValue), { ignored: true }) });
200
+ expect(react_2.screen.getByLabelText('Ignore')).not.toBeDisabled();
201
+ expect(react_2.screen.getByTestId('SvgIgnored')).toBeInTheDocument();
282
202
  });
283
- it('should disable edit, pin and ignore actions if props.disableEdit is true', function () {
284
- var props = __assign({ attributeValue: value, attributeType: attributeType, crosswalk: crosswalk, className: 'simpleAttribute', disableEdit: true }, actions);
285
- var wrapper = setUp(props);
286
- var event = {};
287
- (0, test_utils_1.act)(function () {
288
- var _a;
289
- (_a = wrapper.find('.simpleAttribute').at(2).prop('onMouseEnter')) === null || _a === void 0 ? void 0 : _a(event);
290
- });
291
- wrapper.update();
292
- var actionsItems = wrapper.find(DropDownMenuButton_1.DropDownMenuButton).prop('menuItems');
293
- expect(actionsItems === null || actionsItems === void 0 ? void 0 : actionsItems[1]).toMatchObject({
294
- disabled: true,
295
- text: 'Edit',
296
- tooltip: "You don't have permissions to edit"
203
+ it('should show actions with all actions if attribute type allows actions', function () { return __awaiter(void 0, void 0, void 0, function () {
204
+ var user;
205
+ return __generator(this, function (_a) {
206
+ switch (_a.label) {
207
+ case 0:
208
+ user = setUp({}, true).user;
209
+ return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
210
+ case 1:
211
+ _a.sent();
212
+ return [4 /*yield*/, user.click(react_2.screen.getByLabelText('More actions'))];
213
+ case 2:
214
+ _a.sent();
215
+ expect(react_2.screen.getByLabelText('Focus')).toBeInTheDocument();
216
+ expect(react_2.screen.getByText('Edit')).not.toBeDisabled();
217
+ expect(react_2.screen.getByText('Delete')).not.toBeDisabled();
218
+ return [2 /*return*/];
219
+ }
297
220
  });
298
- expect(actionsItems === null || actionsItems === void 0 ? void 0 : actionsItems[2]).toMatchObject({
299
- disabled: false,
300
- text: 'Delete',
301
- tooltip: null
221
+ }); });
222
+ it('should disable actions based on attribute type permissions', function () { return __awaiter(void 0, void 0, void 0, function () {
223
+ var _a, user, rerender, editButton, deleteButton;
224
+ return __generator(this, function (_b) {
225
+ switch (_b.label) {
226
+ case 0:
227
+ _a = setUp({ attributeType: __assign(__assign({}, defaultProps.attributeType), { access: ['READ'] }) }, true), user = _a.user, rerender = _a.rerender;
228
+ return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
229
+ case 1:
230
+ _b.sent();
231
+ return [4 /*yield*/, user.click(react_2.screen.getByLabelText('More actions'))];
232
+ case 2:
233
+ _b.sent();
234
+ editButton = react_2.screen.getByLabelText("You don't have permissions to edit");
235
+ expect(editButton.children[0]).toHaveAttribute('aria-disabled', 'true');
236
+ expect(editButton).toHaveTextContent('Edit');
237
+ deleteButton = react_2.screen.getByLabelText("You don't have permissions to delete");
238
+ expect(deleteButton.children[0]).toHaveAttribute('aria-disabled', 'true');
239
+ expect(deleteButton).toHaveTextContent('Delete');
240
+ rerender(react_1.default.createElement(InlineSimpleAttribute_1.InlineSimpleAttribute, __assign({}, defaultProps, { attributeValue: __assign(__assign({}, defaultProps.attributeValue), { pin: true, ignored: true }), attributeType: __assign(__assign({}, defaultProps.attributeType), { access: ['CREATE'] }) })));
241
+ expect(react_2.screen.getByLabelText("You don't have permissions to pin").children[0]).toBeDisabled();
242
+ expect(react_2.screen.getByLabelText("You don't have permissions to ignore").children[0]).toBeDisabled();
243
+ return [2 /*return*/];
244
+ }
302
245
  });
303
- expect(wrapper.find(IgnoreButton_1.IgnoreButton).length).toBe(0);
304
- expect(wrapper.find(PinButton_1.PinButton).length).toBe(0);
305
- });
306
- it('should call props.onDelete on Delete button click correctly', function () {
307
- var _a, _b;
308
- var props = __assign({ attributeValue: value, attributeType: attributeType, crosswalk: crosswalk, className: 'simpleAttribute' }, actions);
309
- var wrapper = setUp(props);
310
- var event = {};
311
- (0, test_utils_1.act)(function () {
312
- var _a;
313
- (_a = wrapper.find('.simpleAttribute').at(2).prop('onMouseEnter')) === null || _a === void 0 ? void 0 : _a(event);
246
+ }); });
247
+ it('should disable delete action if props.disableDelete is true', function () { return __awaiter(void 0, void 0, void 0, function () {
248
+ var user, deleteButton;
249
+ return __generator(this, function (_a) {
250
+ switch (_a.label) {
251
+ case 0:
252
+ user = setUp({ disableDelete: true }, true).user;
253
+ return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
254
+ case 1:
255
+ _a.sent();
256
+ return [4 /*yield*/, user.click(react_2.screen.getByLabelText('More actions'))];
257
+ case 2:
258
+ _a.sent();
259
+ deleteButton = react_2.screen.getByLabelText("You don't have permissions to delete");
260
+ expect(deleteButton.children[0]).toHaveAttribute('aria-disabled', 'true');
261
+ expect(deleteButton).toHaveTextContent('Delete');
262
+ expect(react_2.screen.getByText('Edit').parentElement).not.toHaveAttribute('aria-disabled', 'true');
263
+ return [2 /*return*/];
264
+ }
314
265
  });
315
- wrapper.update();
316
- var actionItems = wrapper.find(DropDownMenuButton_1.DropDownMenuButton).prop('menuItems');
317
- (_b = (_a = actionItems[2]).onClick) === null || _b === void 0 ? void 0 : _b.call(_a);
318
- expect(actions.onDelete).toHaveBeenCalledWith({
319
- attributeType: attributeType,
320
- attributeValue: value,
321
- crosswalks: [crosswalk]
266
+ }); });
267
+ it('should disable edit, pin and ignore actions if props.disableEdit is true', function () { return __awaiter(void 0, void 0, void 0, function () {
268
+ var user, editButton;
269
+ return __generator(this, function (_a) {
270
+ switch (_a.label) {
271
+ case 0:
272
+ user = setUp({ disableEdit: true }, true).user;
273
+ return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
274
+ case 1:
275
+ _a.sent();
276
+ expect(react_2.screen.queryByLabelText('Ignore')).not.toBeInTheDocument();
277
+ expect(react_2.screen.queryByLabelText('Pin')).not.toBeInTheDocument();
278
+ return [4 /*yield*/, user.click(react_2.screen.getByLabelText('More actions'))];
279
+ case 2:
280
+ _a.sent();
281
+ editButton = react_2.screen.getByLabelText("You don't have permissions to edit");
282
+ expect(editButton.children[0]).toHaveAttribute('aria-disabled', 'true');
283
+ expect(editButton).toHaveTextContent('Edit');
284
+ expect(react_2.screen.getByText('Delete').parentElement).not.toHaveAttribute('aria-disabled', 'true');
285
+ return [2 /*return*/];
286
+ }
322
287
  });
323
- });
324
- it('should call props.onPin on Pin button click correctly', function () {
325
- var props = __assign({ attributeValue: value, attributeType: attributeType, crosswalk: crosswalk, className: 'simpleAttribute' }, actions);
326
- var wrapper = setUp(props);
327
- var event = {};
328
- (0, test_utils_1.act)(function () {
329
- var _a;
330
- (_a = wrapper.find('.simpleAttribute').at(2).prop('onMouseEnter')) === null || _a === void 0 ? void 0 : _a(event);
288
+ }); });
289
+ it('should toggle crosswalk focus on click Focus', function () { return __awaiter(void 0, void 0, void 0, function () {
290
+ var user;
291
+ return __generator(this, function (_a) {
292
+ switch (_a.label) {
293
+ case 0:
294
+ user = setUp({}, true).user;
295
+ return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
296
+ case 1:
297
+ _a.sent();
298
+ return [4 /*yield*/, user.click(react_2.screen.getByLabelText('More actions'))];
299
+ case 2:
300
+ _a.sent();
301
+ return [4 /*yield*/, user.click(react_2.screen.getByLabelText('Focus'))];
302
+ case 3:
303
+ _a.sent();
304
+ expect(toggleCrosswalkFocus).toHaveBeenCalledWith();
305
+ return [2 /*return*/];
306
+ }
331
307
  });
332
- wrapper.update();
333
- wrapper.find(PinButton_1.PinButton).prop('onClick')();
334
- expect(actions.onPin).toHaveBeenCalledWith({
335
- attributeValue: value
308
+ }); });
309
+ it('should call props.onDelete on Delete button click correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
310
+ var user;
311
+ return __generator(this, function (_a) {
312
+ switch (_a.label) {
313
+ case 0:
314
+ user = setUp({}, true).user;
315
+ return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
316
+ case 1:
317
+ _a.sent();
318
+ return [4 /*yield*/, user.click(react_2.screen.getByLabelText('More actions'))];
319
+ case 2:
320
+ _a.sent();
321
+ return [4 /*yield*/, user.click(react_2.screen.getByText('Delete'))];
322
+ case 3:
323
+ _a.sent();
324
+ expect(defaultProps.onDelete).toHaveBeenCalledWith({
325
+ attributeType: defaultProps.attributeType,
326
+ attributeValue: defaultProps.attributeValue,
327
+ crosswalks: [defaultProps.crosswalk]
328
+ });
329
+ return [2 /*return*/];
330
+ }
336
331
  });
337
- });
338
- it('should call props.onIgnore on Ignore button click correctly', function () {
339
- var props = __assign({ attributeValue: value, attributeType: attributeType, crosswalk: crosswalk, className: 'simpleAttribute' }, actions);
340
- var wrapper = setUp(props);
341
- var event = {};
342
- (0, test_utils_1.act)(function () {
343
- var _a;
344
- (_a = wrapper.find('.simpleAttribute').at(2).prop('onMouseEnter')) === null || _a === void 0 ? void 0 : _a(event);
332
+ }); });
333
+ it('should call props.onPin on Pin button click correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
334
+ var user;
335
+ return __generator(this, function (_a) {
336
+ switch (_a.label) {
337
+ case 0:
338
+ user = setUp({}, true).user;
339
+ return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
340
+ case 1:
341
+ _a.sent();
342
+ return [4 /*yield*/, user.click(react_2.screen.getByLabelText('Pin').childNodes[0])];
343
+ case 2:
344
+ _a.sent();
345
+ expect(defaultProps.onPin).toHaveBeenCalledWith({
346
+ attributeValue: defaultProps.attributeValue
347
+ });
348
+ return [2 /*return*/];
349
+ }
345
350
  });
346
- wrapper.update();
347
- wrapper.find(IgnoreButton_1.IgnoreButton).prop('onClick')();
348
- expect(actions.onIgnore).toHaveBeenCalledWith({
349
- attributeValue: value
351
+ }); });
352
+ it('should call props.onIgnore on Ignore button click correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
353
+ var user;
354
+ return __generator(this, function (_a) {
355
+ switch (_a.label) {
356
+ case 0:
357
+ user = setUp({}, true).user;
358
+ return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
359
+ case 1:
360
+ _a.sent();
361
+ return [4 /*yield*/, user.click(react_2.screen.getByLabelText('Ignore').childNodes[0])];
362
+ case 2:
363
+ _a.sent();
364
+ expect(defaultProps.onIgnore).toHaveBeenCalledWith({
365
+ attributeValue: defaultProps.attributeValue
366
+ });
367
+ return [2 /*return*/];
368
+ }
350
369
  });
351
- });
370
+ }); });
352
371
  it('should render InlineSimpleAttributeEditor on Edit menu item click', function () { return __awaiter(void 0, void 0, void 0, function () {
353
- var props, wrapper, onMouseEnter, actionItems;
372
+ var user;
354
373
  return __generator(this, function (_a) {
355
374
  switch (_a.label) {
356
375
  case 0:
357
- props = __assign({ attributeValue: value, attributeType: attributeType, crosswalk: crosswalk, className: 'simpleAttribute' }, actions);
358
- wrapper = setUp(props);
359
- onMouseEnter = wrapper.find('.simpleAttribute').at(2).prop('onMouseEnter');
360
- (0, test_utils_1.act)(function () {
361
- onMouseEnter();
362
- });
363
- wrapper.update();
364
- actionItems = wrapper.find(DropDownMenuButton_1.DropDownMenuButton).prop('menuItems');
365
- return [4 /*yield*/, (0, test_utils_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
366
- var _a, _b;
367
- return __generator(this, function (_c) {
368
- (_b = (_a = actionItems[1]).onClick) === null || _b === void 0 ? void 0 : _b.call(_a);
369
- return [2 /*return*/];
370
- });
371
- }); })];
376
+ user = setUp({}, true).user;
377
+ return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
372
378
  case 1:
373
379
  _a.sent();
374
- wrapper.update();
375
- expect(wrapper.find(InlineSimpleAttributeEditor_1.InlineSimpleAttributeEditor)).toHaveLength(1);
380
+ return [4 /*yield*/, user.click(react_2.screen.getByLabelText('More actions'))];
381
+ case 2:
382
+ _a.sent();
383
+ return [4 /*yield*/, user.click(react_2.screen.getByText('Edit'))];
384
+ case 3:
385
+ _a.sent();
386
+ expect(react_2.screen.getByTestId('inline-simple-attribute-editor')).toBeInTheDocument();
376
387
  return [2 /*return*/];
377
388
  }
378
389
  });
379
390
  }); });
380
391
  it('should call props.onEdit when call onEdit prop of InlineSimpleAttributeEditor', function () { return __awaiter(void 0, void 0, void 0, function () {
381
- var props, wrapper, event, actionItems, newAttributeValue;
392
+ var user, backdrop;
382
393
  return __generator(this, function (_a) {
383
394
  switch (_a.label) {
384
395
  case 0:
385
- props = __assign({ attributeValue: value, attributeType: attributeType, crosswalk: crosswalk, className: 'simpleAttribute' }, actions);
386
- wrapper = setUp(props);
387
- event = {};
388
- (0, test_utils_1.act)(function () {
389
- var _a;
390
- (_a = wrapper.find('.simpleAttribute').at(2).prop('onMouseEnter')) === null || _a === void 0 ? void 0 : _a(event);
391
- });
392
- wrapper.update();
393
- actionItems = wrapper.find(DropDownMenuButton_1.DropDownMenuButton).prop('menuItems');
394
- return [4 /*yield*/, (0, test_utils_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
395
- var _a, _b;
396
- return __generator(this, function (_c) {
397
- (_b = (_a = actionItems[1]).onClick) === null || _b === void 0 ? void 0 : _b.call(_a);
398
- return [2 /*return*/];
399
- });
400
- }); })];
396
+ user = setUp({}, true).user;
397
+ return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
401
398
  case 1:
402
399
  _a.sent();
403
- wrapper.update();
404
- newAttributeValue = {
405
- uri: 'entities/123/attributes/String/123',
406
- value: 'Test update'
407
- };
408
- return [4 /*yield*/, (0, test_utils_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
409
- return __generator(this, function (_a) {
410
- wrapper.find(InlineSimpleAttributeEditor_1.InlineSimpleAttributeEditor).prop('onEdit')(newAttributeValue);
411
- return [2 /*return*/];
412
- });
413
- }); })];
400
+ return [4 /*yield*/, user.click(react_2.screen.getByLabelText('More actions'))];
414
401
  case 2:
415
402
  _a.sent();
416
- expect(actions.onEdit).toHaveBeenCalledWith({
417
- attributeType: attributeType,
418
- attributeValue: newAttributeValue,
419
- crosswalk: crosswalk
403
+ return [4 /*yield*/, user.click(react_2.screen.getByText('Edit'))];
404
+ case 3:
405
+ _a.sent();
406
+ expect(react_2.screen.getByTestId('inline-simple-attribute-editor')).toBeInTheDocument();
407
+ return [4 /*yield*/, user.type(react_2.screen.getByRole('textbox'), ' update')];
408
+ case 4:
409
+ _a.sent();
410
+ backdrop = react_2.screen.getByRole('presentation').childNodes[0];
411
+ return [4 /*yield*/, user.click(backdrop)];
412
+ case 5:
413
+ _a.sent();
414
+ expect(defaultProps.onEdit).toHaveBeenCalledWith({
415
+ attributeType: defaultProps.attributeType,
416
+ attributeValue: __assign(__assign({}, defaultProps.attributeValue), { uri: defaultProps.attributeValue.uri, value: 'Test update' }),
417
+ crosswalk: defaultProps.crosswalk
420
418
  });
421
419
  return [2 /*return*/];
422
420
  }
423
421
  });
424
422
  }); });
425
- it('should disable edit, pin, delete and ignore actions if it is system attribute', function () {
426
- var props = __assign({ attributeValue: value, attributeType: __assign(__assign({}, attributeType), { system: true }), crosswalk: crosswalk, className: 'simpleAttribute' }, actions);
427
- var wrapper = setUp(props);
428
- var event = {};
429
- (0, test_utils_1.act)(function () {
430
- var _a;
431
- (_a = wrapper.find('.simpleAttribute').at(2).prop('onMouseEnter')) === null || _a === void 0 ? void 0 : _a(event);
432
- });
433
- wrapper.update();
434
- var actionsItems = wrapper.find(DropDownMenuButton_1.DropDownMenuButton).prop('menuItems');
435
- expect(actionsItems === null || actionsItems === void 0 ? void 0 : actionsItems[1]).toMatchObject({
436
- disabled: true,
437
- text: 'Edit',
438
- tooltip: "You don't have permissions to edit"
439
- });
440
- expect(actionsItems === null || actionsItems === void 0 ? void 0 : actionsItems[2]).toMatchObject({
441
- disabled: true,
442
- text: 'Delete',
443
- tooltip: "You don't have permissions to delete"
444
- });
445
- expect(wrapper.find(IgnoreButton_1.IgnoreButton).length).toBe(0);
446
- expect(wrapper.find(PinButton_1.PinButton).length).toBe(0);
447
- });
448
- it('should hide pin and ignore button for temporary attribute', function () {
449
- var props = __assign({ attributeValue: (0, mdm_sdk_1.createNewAttribute)({ parentUri: 'entities/123', attributeType: attributeType }), attributeType: attributeType, crosswalk: crosswalk, className: 'simpleAttribute' }, actions);
450
- var wrapper = setUp(props);
451
- (0, test_utils_1.act)(function () {
452
- wrapper.find('.root').simulate('mouseenter');
453
- });
454
- wrapper.update();
455
- expect(wrapper.find(IgnoreButton_1.IgnoreButton).length).toBe(0);
456
- expect(wrapper.find(PinButton_1.PinButton).length).toBe(0);
457
- });
458
- it('should disable edit, pin, delete and ignore actions if crosswalk is disabled', function () {
459
- mdm_sdk_1.isCrosswalkDisabled.mockReturnValue(true);
460
- var props = __assign({ attributeValue: value, attributeType: attributeType, crosswalk: crosswalk, className: 'simpleAttribute' }, actions);
461
- var wrapper = setUp(props);
462
- var event = {};
463
- (0, test_utils_1.act)(function () {
464
- var _a;
465
- (_a = wrapper.find('.simpleAttribute').at(2).prop('onMouseEnter')) === null || _a === void 0 ? void 0 : _a(event);
423
+ it('should disable edit, pin, delete and ignore actions if it is system attribute', function () { return __awaiter(void 0, void 0, void 0, function () {
424
+ var user, editButton, deleteButton;
425
+ return __generator(this, function (_a) {
426
+ switch (_a.label) {
427
+ case 0:
428
+ user = setUp({ attributeType: __assign(__assign({}, defaultProps.attributeType), { system: true }) }, true).user;
429
+ return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
430
+ case 1:
431
+ _a.sent();
432
+ expect(react_2.screen.queryByLabelText('Ignore')).not.toBeInTheDocument();
433
+ expect(react_2.screen.queryByLabelText('Pin')).not.toBeInTheDocument();
434
+ return [4 /*yield*/, user.click(react_2.screen.getByLabelText('More actions'))];
435
+ case 2:
436
+ _a.sent();
437
+ editButton = react_2.screen.getByLabelText("You don't have permissions to edit");
438
+ expect(editButton.children[0]).toHaveAttribute('aria-disabled', 'true');
439
+ expect(editButton).toHaveTextContent('Edit');
440
+ deleteButton = react_2.screen.getByLabelText("You don't have permissions to delete");
441
+ expect(deleteButton.children[0]).toHaveAttribute('aria-disabled', 'true');
442
+ expect(deleteButton).toHaveTextContent('Delete');
443
+ return [2 /*return*/];
444
+ }
466
445
  });
467
- wrapper.update();
468
- var actionsItems = wrapper.find(DropDownMenuButton_1.DropDownMenuButton).prop('menuItems');
469
- expect(actionsItems === null || actionsItems === void 0 ? void 0 : actionsItems[1]).toMatchObject({
470
- disabled: true,
471
- text: 'Edit',
472
- tooltip: "You don't have permissions to edit"
446
+ }); });
447
+ it('should hide pin and ignore button for temporary attribute', function () { return __awaiter(void 0, void 0, void 0, function () {
448
+ var user;
449
+ return __generator(this, function (_a) {
450
+ switch (_a.label) {
451
+ case 0:
452
+ user = setUp({
453
+ attributeValue: __assign(__assign({}, (0, mdm_sdk_1.createNewAttribute)({ parentUri: 'entities/123', attributeType: defaultProps.attributeType })), { value: 'Test' })
454
+ }).user;
455
+ return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
456
+ case 1:
457
+ _a.sent();
458
+ expect(react_2.screen.queryByLabelText('Ignore')).not.toBeInTheDocument();
459
+ expect(react_2.screen.queryByLabelText('Pin')).not.toBeInTheDocument();
460
+ return [2 /*return*/];
461
+ }
473
462
  });
474
- expect(actionsItems === null || actionsItems === void 0 ? void 0 : actionsItems[2]).toMatchObject({
475
- disabled: true,
476
- text: 'Delete',
477
- tooltip: "You don't have permissions to delete"
463
+ }); });
464
+ it('should disable edit, pin, delete and ignore actions if crosswalk is disabled', function () { return __awaiter(void 0, void 0, void 0, function () {
465
+ var user, editButton, deleteButton;
466
+ return __generator(this, function (_a) {
467
+ switch (_a.label) {
468
+ case 0:
469
+ user = setUp({ crosswalk: __assign(__assign({}, defaultProps.crosswalk), { deleteDate: Date.now() - 2000 }) }, true).user;
470
+ return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
471
+ case 1:
472
+ _a.sent();
473
+ expect(react_2.screen.queryByLabelText('Ignore')).not.toBeInTheDocument();
474
+ expect(react_2.screen.queryByLabelText('Pin')).not.toBeInTheDocument();
475
+ return [4 /*yield*/, user.click(react_2.screen.getByLabelText('More actions'))];
476
+ case 2:
477
+ _a.sent();
478
+ editButton = react_2.screen.getByLabelText("You don't have permissions to edit");
479
+ expect(editButton.children[0]).toHaveAttribute('aria-disabled', 'true');
480
+ expect(editButton).toHaveTextContent('Edit');
481
+ deleteButton = react_2.screen.getByLabelText("You don't have permissions to delete");
482
+ expect(deleteButton.children[0]).toHaveAttribute('aria-disabled', 'true');
483
+ expect(deleteButton).toHaveTextContent('Delete');
484
+ return [2 /*return*/];
485
+ }
478
486
  });
479
- expect(wrapper.find(IgnoreButton_1.IgnoreButton).length).toBe(0);
480
- expect(wrapper.find(PinButton_1.PinButton).length).toBe(0);
481
- });
487
+ }); });
482
488
  });