@reltio/components 1.4.2069 → 1.4.2071

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 (159) hide show
  1. package/FacetViewHeader/FacetViewHeader.js +1 -1
  2. package/ImageAttributesLine/imageAttributeValues.test-data.js +8 -0
  3. package/ImageAttributesLine/index.d.ts +1 -1
  4. package/ImageAttributesLine/index.js +1 -1
  5. package/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.js +1 -1
  6. package/MergeButton/MergeButton.spec.js +55 -124
  7. package/MetadataTypesSelector/MetadataTypesSelector.js +1 -1
  8. package/MetadataTypesSelector/MetadataTypesSelector.test.js +193 -190
  9. package/MoreAttributesButton/MoreAttributesButton.test.js +173 -166
  10. package/MultiValueSelector/MultiValueSelector.test.js +78 -38
  11. package/MultipliableSelect/MultipliableSelect.test.js +111 -47
  12. package/NestedAttribute/NestedAttribute.test.js +121 -42
  13. package/NestedAttributeEditor/NestedAttributeEditor.test.js +95 -41
  14. package/NotMatchButton/NotMatchButton.spec.js +51 -100
  15. package/PieChart/PieChart.test.js +130 -114
  16. package/PinButton/PinButton.spec.js +89 -22
  17. package/PivotingTooltip/PivotingTooltip.test.js +338 -174
  18. package/PotentialMatchReviewCard/PotentialMatchReviewCard.spec.js +94 -29
  19. package/ProfileBand/ProfileBand.spec.js +60 -53
  20. package/ProfileCard/ProfileCard.test.js +109 -27
  21. package/ProfilesList/ProfilesList.d.ts +1 -3
  22. package/ProfilesList/ProfilesList.js +1 -1
  23. package/ProfilesList/ProfilesList.spec.js +226 -211
  24. package/QueryBuilderRow/QueryBuilderRow.spec.js +83 -90
  25. package/QueryBuilderRowsGroup/QueryBuilderRowsGroup.spec.js +195 -86
  26. package/ReactSelectLoadMoreButton/ReactSelectLoadMoreButton.test.js +73 -15
  27. package/ReactSelectMenuWithPopper/ReactSelectMenuWithPopper.test.js +71 -117
  28. package/ReadOnlyAttributeValuesBlock/ReadOnlyAttributeValuesBlock.test.js +128 -61
  29. package/ReadOnlyAttributesFactory/components/ReadOnlyAttribute/ReadOnlyAttribute.test.js +179 -44
  30. package/ReadOnlyAttributesList/ReadOnlyAttributesList.test.js +254 -211
  31. package/ReadOnlyAttributesList/attributes.test-data.js +4 -4
  32. package/ReadOnlyAttributesPager/ReadOnlyAttributesPager.test.js +75 -18
  33. package/ReadOnlyAttributesView/ReadOnlyAttributesView.test.js +187 -312
  34. package/ReadOnlyComplexAttribute/ReadOnlyComplexAttribute.test.js +210 -219
  35. package/ReadOnlyImageAttributesLine/ReadOnlyImageAttributesLine.test.js +89 -89
  36. package/ReferenceAttributeEditor/ReferenceAttributeEditor.test.js +556 -602
  37. package/ReferenceAttributeEditor/metadata.test-data.d.ts +13 -13
  38. package/ReferenceAttributeEditor/metadata.test-data.js +2 -2
  39. package/ReferenceAttributeEditor/styles.d.ts +1 -1
  40. package/RelationEditor/RelationEditor.test.js +1448 -1392
  41. package/RelationTypeSelector/RelationTypeSelector.test.js +99 -17
  42. package/RelationTypesSelector/RelationTypesSelector.test.js +73 -22
  43. package/ReltioMap/ReltioMap.spec.js +51 -25
  44. package/Roles/Roles.test.js +54 -10
  45. package/ScreenProfileBand/ScreenProfileBand.test.js +142 -72
  46. package/cjs/FacetViewHeader/FacetViewHeader.js +1 -1
  47. package/cjs/ImageAttributesLine/imageAttributeValues.test-data.js +8 -0
  48. package/cjs/ImageAttributesLine/index.d.ts +1 -1
  49. package/cjs/ImageAttributesLine/index.js +2 -1
  50. package/cjs/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.js +1 -1
  51. package/cjs/MergeButton/MergeButton.spec.js +55 -124
  52. package/cjs/MetadataTypesSelector/MetadataTypesSelector.js +1 -1
  53. package/cjs/MetadataTypesSelector/MetadataTypesSelector.test.js +193 -190
  54. package/cjs/MoreAttributesButton/MoreAttributesButton.test.js +172 -165
  55. package/cjs/MultiValueSelector/MultiValueSelector.test.js +78 -38
  56. package/cjs/MultipliableSelect/MultipliableSelect.test.js +111 -47
  57. package/cjs/NestedAttribute/NestedAttribute.test.js +121 -42
  58. package/cjs/NestedAttributeEditor/NestedAttributeEditor.test.js +94 -40
  59. package/cjs/NotMatchButton/NotMatchButton.spec.js +51 -100
  60. package/cjs/PieChart/PieChart.test.js +130 -114
  61. package/cjs/PinButton/PinButton.spec.js +89 -22
  62. package/cjs/PivotingTooltip/PivotingTooltip.test.js +338 -174
  63. package/cjs/PotentialMatchReviewCard/PotentialMatchReviewCard.spec.js +94 -29
  64. package/cjs/ProfileBand/ProfileBand.spec.js +60 -53
  65. package/cjs/ProfileCard/ProfileCard.test.js +109 -27
  66. package/cjs/ProfilesList/ProfilesList.d.ts +1 -3
  67. package/cjs/ProfilesList/ProfilesList.js +1 -1
  68. package/cjs/ProfilesList/ProfilesList.spec.js +226 -211
  69. package/cjs/QueryBuilderRow/QueryBuilderRow.spec.js +83 -90
  70. package/cjs/QueryBuilderRowsGroup/QueryBuilderRowsGroup.spec.js +195 -86
  71. package/cjs/ReactSelectLoadMoreButton/ReactSelectLoadMoreButton.test.js +73 -15
  72. package/cjs/ReactSelectMenuWithPopper/ReactSelectMenuWithPopper.test.js +71 -117
  73. package/cjs/ReadOnlyAttributeValuesBlock/ReadOnlyAttributeValuesBlock.test.js +128 -61
  74. package/cjs/ReadOnlyAttributesFactory/components/ReadOnlyAttribute/ReadOnlyAttribute.test.js +179 -44
  75. package/cjs/ReadOnlyAttributesList/ReadOnlyAttributesList.test.js +254 -211
  76. package/cjs/ReadOnlyAttributesList/attributes.test-data.js +4 -4
  77. package/cjs/ReadOnlyAttributesPager/ReadOnlyAttributesPager.test.js +75 -18
  78. package/cjs/ReadOnlyAttributesView/ReadOnlyAttributesView.test.js +185 -310
  79. package/cjs/ReadOnlyComplexAttribute/ReadOnlyComplexAttribute.test.js +209 -218
  80. package/cjs/ReadOnlyImageAttributesLine/ReadOnlyImageAttributesLine.test.js +89 -89
  81. package/cjs/ReferenceAttributeEditor/ReferenceAttributeEditor.test.js +555 -601
  82. package/cjs/ReferenceAttributeEditor/metadata.test-data.d.ts +13 -13
  83. package/cjs/ReferenceAttributeEditor/metadata.test-data.js +2 -2
  84. package/cjs/ReferenceAttributeEditor/styles.d.ts +1 -1
  85. package/cjs/RelationEditor/RelationEditor.test.js +1446 -1390
  86. package/cjs/RelationTypeSelector/RelationTypeSelector.test.js +99 -17
  87. package/cjs/RelationTypesSelector/RelationTypesSelector.test.js +73 -22
  88. package/cjs/ReltioMap/ReltioMap.spec.js +51 -25
  89. package/cjs/Roles/Roles.test.js +54 -10
  90. package/cjs/ScreenProfileBand/ScreenProfileBand.test.js +141 -71
  91. package/package.json +2 -2
  92. package/MetadataTypesSelector/components/ListLabel/ListLabel.test.d.ts +0 -1
  93. package/MetadataTypesSelector/components/ListLabel/ListLabel.test.js +0 -24
  94. package/PivotingTooltip/IntegrationPivotingTooltip.test.d.ts +0 -1
  95. package/PivotingTooltip/IntegrationPivotingTooltip.test.js +0 -356
  96. package/PivotingTooltip/components/PivotingTooltipContent/PivotingTooltipContent.test.d.ts +0 -1
  97. package/PivotingTooltip/components/PivotingTooltipContent/PivotingTooltipContent.test.js +0 -201
  98. package/ProfileCard/components/ProfileCardContent/ProfileCardContent.test.d.ts +0 -1
  99. package/ProfileCard/components/ProfileCardContent/ProfileCardContent.test.js +0 -43
  100. package/QueryBuilderRow/components/ReadOnlyFilter/ReadOnlyFilter.spec.d.ts +0 -1
  101. package/QueryBuilderRow/components/ReadOnlyFilter/ReadOnlyFilter.spec.js +0 -31
  102. package/QueryBuilderRow/components/ReadOnlyLogicOperator/ReadOnlyLogicOperator.spec.d.ts +0 -1
  103. package/QueryBuilderRow/components/ReadOnlyLogicOperator/ReadOnlyLogicOperator.spec.js +0 -31
  104. package/ReadOnlyAttributesPager/components/ImageLineRenderer/ImageLineRenderer.test.d.ts +0 -1
  105. package/ReadOnlyAttributesPager/components/ImageLineRenderer/ImageLineRenderer.test.js +0 -45
  106. package/ReadOnlyAttributesPager/components/MultiLineRenderer/MultiLineRenderer.test.d.ts +0 -1
  107. package/ReadOnlyAttributesPager/components/MultiLineRenderer/MultiLineRenderer.test.js +0 -114
  108. package/ReadOnlyAttributesPager/components/OneLineRenderer/OneLineRenderer.test.d.ts +0 -1
  109. package/ReadOnlyAttributesPager/components/OneLineRenderer/OneLineRenderer.test.js +0 -107
  110. package/ReadOnlyAttributesPager/components/SpecialRenderer/SpecialRenderer.test.d.ts +0 -1
  111. package/ReadOnlyAttributesPager/components/SpecialRenderer/SpecialRenderer.test.js +0 -72
  112. package/RelationEditor/IntegrationRelationEditor.test.d.ts +0 -1
  113. package/RelationEditor/IntegrationRelationEditor.test.js +0 -337
  114. package/ReltioMap/components/MapControlContainer/MapControlContainer.d.ts +0 -10
  115. package/ReltioMap/components/MapControlContainer/MapControlContainer.js +0 -24
  116. package/ReltioMap/components/MapControlContainer/MapControlContainer.spec.d.ts +0 -1
  117. package/ReltioMap/components/MapControlContainer/MapControlContainer.spec.js +0 -33
  118. package/ReltioMap/components/MapControlContainer/index.d.ts +0 -1
  119. package/ReltioMap/components/MapControlContainer/index.js +0 -1
  120. package/ReltioMap/components/TopCenterMapControls/TopCenterMapControls.spec.d.ts +0 -1
  121. package/ReltioMap/components/TopCenterMapControls/TopCenterMapControls.spec.js +0 -36
  122. package/ReltioMap/components/TopRightMapControls/TopRightMapControls.spec.d.ts +0 -1
  123. package/ReltioMap/components/TopRightMapControls/TopRightMapControls.spec.js +0 -60
  124. package/Roles/components/Role/Role.test.d.ts +0 -1
  125. package/Roles/components/Role/Role.test.js +0 -55
  126. package/cjs/MetadataTypesSelector/components/ListLabel/ListLabel.test.d.ts +0 -1
  127. package/cjs/MetadataTypesSelector/components/ListLabel/ListLabel.test.js +0 -52
  128. package/cjs/PivotingTooltip/IntegrationPivotingTooltip.test.d.ts +0 -1
  129. package/cjs/PivotingTooltip/IntegrationPivotingTooltip.test.js +0 -361
  130. package/cjs/PivotingTooltip/components/PivotingTooltipContent/PivotingTooltipContent.test.d.ts +0 -1
  131. package/cjs/PivotingTooltip/components/PivotingTooltipContent/PivotingTooltipContent.test.js +0 -206
  132. package/cjs/ProfileCard/components/ProfileCardContent/ProfileCardContent.test.d.ts +0 -1
  133. package/cjs/ProfileCard/components/ProfileCardContent/ProfileCardContent.test.js +0 -48
  134. package/cjs/QueryBuilderRow/components/ReadOnlyFilter/ReadOnlyFilter.spec.d.ts +0 -1
  135. package/cjs/QueryBuilderRow/components/ReadOnlyFilter/ReadOnlyFilter.spec.js +0 -36
  136. package/cjs/QueryBuilderRow/components/ReadOnlyLogicOperator/ReadOnlyLogicOperator.spec.d.ts +0 -1
  137. package/cjs/QueryBuilderRow/components/ReadOnlyLogicOperator/ReadOnlyLogicOperator.spec.js +0 -36
  138. package/cjs/ReadOnlyAttributesPager/components/ImageLineRenderer/ImageLineRenderer.test.d.ts +0 -1
  139. package/cjs/ReadOnlyAttributesPager/components/ImageLineRenderer/ImageLineRenderer.test.js +0 -50
  140. package/cjs/ReadOnlyAttributesPager/components/MultiLineRenderer/MultiLineRenderer.test.d.ts +0 -1
  141. package/cjs/ReadOnlyAttributesPager/components/MultiLineRenderer/MultiLineRenderer.test.js +0 -119
  142. package/cjs/ReadOnlyAttributesPager/components/OneLineRenderer/OneLineRenderer.test.d.ts +0 -1
  143. package/cjs/ReadOnlyAttributesPager/components/OneLineRenderer/OneLineRenderer.test.js +0 -112
  144. package/cjs/ReadOnlyAttributesPager/components/SpecialRenderer/SpecialRenderer.test.d.ts +0 -1
  145. package/cjs/ReadOnlyAttributesPager/components/SpecialRenderer/SpecialRenderer.test.js +0 -77
  146. package/cjs/RelationEditor/IntegrationRelationEditor.test.d.ts +0 -1
  147. package/cjs/RelationEditor/IntegrationRelationEditor.test.js +0 -342
  148. package/cjs/ReltioMap/components/MapControlContainer/MapControlContainer.d.ts +0 -10
  149. package/cjs/ReltioMap/components/MapControlContainer/MapControlContainer.js +0 -28
  150. package/cjs/ReltioMap/components/MapControlContainer/MapControlContainer.spec.d.ts +0 -1
  151. package/cjs/ReltioMap/components/MapControlContainer/MapControlContainer.spec.js +0 -38
  152. package/cjs/ReltioMap/components/MapControlContainer/index.d.ts +0 -1
  153. package/cjs/ReltioMap/components/MapControlContainer/index.js +0 -5
  154. package/cjs/ReltioMap/components/TopCenterMapControls/TopCenterMapControls.spec.d.ts +0 -1
  155. package/cjs/ReltioMap/components/TopCenterMapControls/TopCenterMapControls.spec.js +0 -41
  156. package/cjs/ReltioMap/components/TopRightMapControls/TopRightMapControls.spec.d.ts +0 -1
  157. package/cjs/ReltioMap/components/TopRightMapControls/TopRightMapControls.spec.js +0 -65
  158. package/cjs/Roles/components/Role/Role.test.d.ts +0 -1
  159. package/cjs/Roles/components/Role/Role.test.js +0 -60
@@ -1,53 +1,117 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ 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);
12
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ 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;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
1
37
  import React from 'react';
2
- import { mount, shallow } from 'enzyme';
3
- import TextField from '@mui/material/TextField';
38
+ import { render, screen, within } from '@testing-library/react';
39
+ import userEvent from '@testing-library/user-event';
4
40
  import MenuItem from '@mui/material/MenuItem';
5
- import { ValueChip } from '../ValueChip';
6
41
  import { MultipliableSelect } from './MultipliableSelect';
7
- describe('MultipliableSelect', function () {
8
- describe('single mode', function () {
9
- it('should render MUI TextField with string value', function () {
10
- var value = '1';
11
- var wrapper = mount(React.createElement(MultipliableSelect, { value: value },
12
- React.createElement(MenuItem, { value: "1" })));
13
- expect(wrapper.find(TextField)).toHaveLength(1);
14
- expect(wrapper.text()).toBe(value);
15
- });
16
- it('should call props.onChange on select change', function () {
17
- var onChange = jest.fn();
18
- var value = '1';
19
- var wrapper = shallow(React.createElement(MultipliableSelect, { onChange: onChange },
20
- React.createElement("div", null)));
21
- wrapper.find(TextField).simulate('change', { target: { value: value } });
22
- expect(onChange).toHaveBeenCalledWith(value);
23
- });
24
- });
25
- describe('multiple mode', function () {
26
- it('should render MUI TextField with chip values', function () {
27
- var value = ['1', '2', '3'];
28
- var wrapper = mount(React.createElement(MultipliableSelect, { multiple: true, value: value },
29
- React.createElement("div", null)));
30
- expect(wrapper.find(TextField).prop('SelectProps').multiple).toBe(true);
31
- expect(wrapper.find(ValueChip)).toHaveLength(value.length);
32
- wrapper.find(ValueChip).forEach(function (n, i) {
33
- expect(n.prop('label')).toBe(value[i]);
34
- });
35
- });
36
- it('should call props.onChange on select change', function () {
37
- var onChange = jest.fn();
38
- var value = ['1'];
39
- var wrapper = shallow(React.createElement(MultipliableSelect, { multiple: true, onChange: onChange },
40
- React.createElement("div", null)));
41
- wrapper.find(TextField).simulate('change', { target: { value: value } });
42
- expect(onChange).toHaveBeenCalledWith(value);
42
+ import { getMuiIconByName } from '../test-utils';
43
+ describe('Multipliable select tests', function () {
44
+ it('should render and work correctly in single mode', function () { return __awaiter(void 0, void 0, void 0, function () {
45
+ var user, onChange, popover, options;
46
+ return __generator(this, function (_a) {
47
+ switch (_a.label) {
48
+ case 0:
49
+ user = userEvent.setup();
50
+ onChange = jest.fn();
51
+ render(React.createElement(MultipliableSelect, { value: "orange", onChange: onChange },
52
+ React.createElement(MenuItem, { value: "orange" }, "Orange"),
53
+ React.createElement(MenuItem, { value: "lemon" }, "Lemon")));
54
+ return [4 /*yield*/, user.click(screen.getByRole('button', { name: 'orange' }))];
55
+ case 1:
56
+ _a.sent();
57
+ popover = screen.getByRole('presentation');
58
+ options = screen.getAllByRole('option');
59
+ expect(options).toHaveLength(2);
60
+ expect(options[0]).toHaveTextContent('Orange');
61
+ expect(options[1]).toHaveTextContent('Lemon');
62
+ return [4 /*yield*/, user.click(options[1])];
63
+ case 2:
64
+ _a.sent();
65
+ expect(onChange).toHaveBeenCalledWith('lemon');
66
+ expect(popover).not.toBeInTheDocument();
67
+ return [2 /*return*/];
68
+ }
43
69
  });
44
- it('should call props.onChange on Chip deletion', function () {
45
- var value = ['1', '2', '3'];
46
- var onChange = jest.fn();
47
- var wrapper = mount(React.createElement(MultipliableSelect, { multiple: true, value: value, onChange: onChange },
48
- React.createElement("div", null)));
49
- wrapper.find(ValueChip).at(1).prop('onDelete')();
50
- expect(onChange).toHaveBeenCalledWith(['1', '3']);
70
+ }); });
71
+ it('should render and work correctly in multiple mode', function () { return __awaiter(void 0, void 0, void 0, function () {
72
+ var user, onChange, button, chips, popover, options;
73
+ return __generator(this, function (_a) {
74
+ switch (_a.label) {
75
+ case 0:
76
+ user = userEvent.setup();
77
+ onChange = jest.fn();
78
+ render(React.createElement(MultipliableSelect, { multiple: true, value: ['orange', 'apple'], onChange: onChange },
79
+ React.createElement(MenuItem, { value: "orange" }, "Orange"),
80
+ React.createElement(MenuItem, { value: "lemon" }, "Lemon"),
81
+ React.createElement(MenuItem, { value: "kiwi" }, "Kiwi"),
82
+ React.createElement(MenuItem, { value: "apple" }, "Apple"),
83
+ React.createElement(MenuItem, { value: "banana" }, "Banana")));
84
+ button = screen.getAllByRole('button')[0];
85
+ chips = within(button).getAllByRole('button');
86
+ expect(chips).toHaveLength(2);
87
+ expect(chips[0]).toHaveTextContent('orange');
88
+ expect(chips[1]).toHaveTextContent('apple');
89
+ return [4 /*yield*/, user.click(getMuiIconByName('Cancel', chips[1]))];
90
+ case 1:
91
+ _a.sent();
92
+ expect(onChange).toHaveBeenCalledWith(['orange']);
93
+ return [4 /*yield*/, user.click(button)];
94
+ case 2:
95
+ _a.sent();
96
+ popover = screen.getByRole('presentation');
97
+ options = screen.getAllByRole('option');
98
+ expect(options).toHaveLength(5);
99
+ expect(options[0]).toHaveTextContent('Orange');
100
+ expect(options[1]).toHaveTextContent('Lemon');
101
+ expect(options[2]).toHaveTextContent('Kiwi');
102
+ expect(options[3]).toHaveTextContent('Apple');
103
+ expect(options[4]).toHaveTextContent('Banana');
104
+ return [4 /*yield*/, user.click(options[4])];
105
+ case 3:
106
+ _a.sent();
107
+ expect(onChange).toHaveBeenCalledWith(['orange', 'apple', 'banana']);
108
+ expect(popover).toBeInTheDocument();
109
+ return [4 /*yield*/, user.keyboard('{Escape}')];
110
+ case 4:
111
+ _a.sent();
112
+ expect(popover).not.toBeInTheDocument();
113
+ return [2 /*return*/];
114
+ }
51
115
  });
52
- });
116
+ }); });
53
117
  });
@@ -9,68 +9,147 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
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
+ };
12
48
  import React from 'react';
13
- import { mount } from 'enzyme';
49
+ import { render, screen, within } from '@testing-library/react';
50
+ import userEvent from '@testing-library/user-event';
51
+ import { getFilteredEntities, getTotals } from '@reltio/mdm-sdk';
14
52
  import NestedAttribute from './NestedAttribute';
15
53
  import { nestedAttributeType } from './nestedAttrType.test-data';
16
54
  import { nestedAttributeValue } from './nestedAttrValue.test-data';
17
- import { ReadOnlyComplexAttribute } from '../ReadOnlyComplexAttribute';
18
55
  import { HistoryDiffContext } from '../contexts/HistoryAppearanceContext';
19
56
  import { SearchValueContext } from '../contexts/SearchValueContext';
20
57
  import { MdmModuleProvider } from '../contexts/MdmModuleContext';
21
- import { PivotingTooltip } from '../PivotingTooltip';
22
- import { SearchHighlighter } from '../SearchHighlighter';
58
+ import { PivotingAttributeContext } from '../contexts/PivotingAttributeContext';
59
+ jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { getFilteredEntities: jest.fn(), getTotals: jest.fn() })); });
23
60
  var mdmValues = {
24
61
  collaborationPath: 'https://cservice-dev.reltio.com/reltio-collaboration/tst-01',
25
62
  uiPath: 'https://localhost:3000/ui/aleant',
26
- metadata: {}
27
- };
28
- var mdmActions = {
29
- openPivotingPerspective: function () { }
63
+ metadata: {
64
+ entityTypes: [],
65
+ relationTypes: [
66
+ {
67
+ uri: 'configuration/relationTypes/InternalHCPtoHCP',
68
+ label: 'HCP to HCP',
69
+ attributes: [nestedAttributeType]
70
+ }
71
+ ]
72
+ }
30
73
  };
31
74
  var defaultProps = {
32
75
  attributeValue: nestedAttributeValue,
33
76
  attributeType: nestedAttributeType
34
77
  };
35
78
  var setUp = function (_a) {
36
- var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? defaultProps : _c, _d = _b.CustomProviders, CustomProviders = _d === void 0 ? React.Fragment : _d;
37
- return mount(React.createElement(CustomProviders, null,
38
- React.createElement(MdmModuleProvider, { values: mdmValues, actions: mdmActions },
39
- React.createElement(NestedAttribute, __assign({}, props)))));
79
+ var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? defaultProps : _c, _d = _b.pivotingAttributeContextValue, pivotingAttributeContextValue = _d === void 0 ? [] : _d, _e = _b.searchValueContextValue, searchValueContextValue = _e === void 0 ? '' : _e, _f = _b.historyDiffContext, historyDiffContext = _f === void 0 ? { appearance: {}, attributes: {}, roles: [], tags: [] } : _f;
80
+ var user = userEvent.setup();
81
+ var Providers = function (_a) {
82
+ var children = _a.children;
83
+ return (React.createElement(HistoryDiffContext.Provider, { value: historyDiffContext },
84
+ React.createElement(PivotingAttributeContext.Provider, { value: pivotingAttributeContextValue },
85
+ React.createElement(SearchValueContext.Provider, { value: searchValueContextValue },
86
+ React.createElement(MdmModuleProvider, { values: mdmValues }, children)))));
87
+ };
88
+ return __assign(__assign({}, render(React.createElement(NestedAttribute, __assign({}, props)), { wrapper: Providers })), { user: user });
40
89
  };
41
- describe('read mode NestedAttribute', function () {
42
- var getComplexAttribute = function (component) { return component.find(ReadOnlyComplexAttribute); };
43
- it('should provide props to ComplexAttribute correctly', function () {
44
- var component = setUp();
45
- var complexAttribute = getComplexAttribute(component);
46
- expect(component.find(PivotingTooltip).text()).toBe(nestedAttributeValue.label);
47
- expect(complexAttribute.prop('attributeValue')).toBe(nestedAttributeValue);
48
- expect(complexAttribute.prop('attributeTypesList')).toBe(nestedAttributeType.attributes);
90
+ describe('read mode nested attribute', function () {
91
+ beforeEach(function () {
92
+ getFilteredEntities.mockResolvedValue([]);
93
+ getTotals.mockRejectedValue({ total: 0 });
49
94
  });
95
+ it('should render correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
96
+ var user, nestedAttribute, subNestedAttribute;
97
+ return __generator(this, function (_a) {
98
+ switch (_a.label) {
99
+ case 0:
100
+ user = setUp().user;
101
+ screen.getByText('Nested 1 Label');
102
+ return [4 /*yield*/, user.click(screen.getByTestId('arrow-expand-button'))];
103
+ case 1:
104
+ _a.sent();
105
+ nestedAttribute = screen.getByTestId('branch-decorator');
106
+ within(nestedAttribute).getByText('Sub Nested');
107
+ within(nestedAttribute).getByText('SubNested 1 Label');
108
+ return [4 /*yield*/, user.click(within(nestedAttribute).getByTestId('arrow-expand-button'))];
109
+ case 2:
110
+ _a.sent();
111
+ subNestedAttribute = within(nestedAttribute).getByTestId('branch-decorator');
112
+ within(subNestedAttribute).getByText('Sub Sub Nested');
113
+ within(subNestedAttribute).getByText('SubSubNested 1 Label');
114
+ return [4 /*yield*/, user.click(within(subNestedAttribute).getByTestId('arrow-expand-button'))];
115
+ case 3:
116
+ _a.sent();
117
+ within(subNestedAttribute).getByText('Attribute Value');
118
+ within(subNestedAttribute).getByText('12321');
119
+ return [2 /*return*/];
120
+ }
121
+ });
122
+ }); });
50
123
  it('should provide history className', function () {
51
124
  var _a;
52
- var appearance = (_a = {},
53
- _a[nestedAttributeValue.value.SubNested[0].uri] = 'INSERT_ATTRIBUTE',
54
- _a);
55
- var Providers = function (_a) {
56
- var children = _a.children;
57
- return (React.createElement(HistoryDiffContext.Provider, { value: { appearance: appearance } }, children));
58
- };
59
- var component = setUp({ CustomProviders: Providers });
60
- expect(component.find(PivotingTooltip).find('.updateAttribute').length).toBeTruthy();
61
- });
62
- it('should render PivotingTooltip', function () {
63
- var component = setUp();
64
- expect(component.find(PivotingTooltip).length).toEqual(1);
125
+ var appearance = (_a = {}, _a[nestedAttributeValue.value.SubNested[0].uri] = 'INSERT_ATTRIBUTE', _a);
126
+ var historyDiffContext = { appearance: appearance, attributes: {}, roles: [], tags: [] };
127
+ setUp({ historyDiffContext: historyDiffContext });
128
+ expect(screen.getByText('Nested 1 Label')).toHaveClass('updateAttribute');
65
129
  });
66
- it('should render PivotingTooltip with highlights', function () {
67
- var highlightedValue = '1';
68
- var Providers = function (_a) {
69
- var children = _a.children;
70
- return (React.createElement(SearchValueContext.Provider, { value: highlightedValue }, children));
71
- };
72
- var component = setUp({ CustomProviders: Providers });
73
- expect(component.find(SearchHighlighter).prop('text')).toBe('Nested 1 Label');
74
- expect(component.find(PivotingTooltip).length).toEqual(1);
130
+ it('should render pivoting tooltip correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
131
+ var pivotingAttributeContextValue, user, popper;
132
+ return __generator(this, function (_a) {
133
+ switch (_a.label) {
134
+ case 0:
135
+ pivotingAttributeContextValue = [
136
+ { uri: 'configuration/relationTypes/InternalHCPtoHCP/attributes/AdditionalAttributes' }
137
+ ];
138
+ user = setUp({ pivotingAttributeContextValue: pivotingAttributeContextValue }).user;
139
+ return [4 /*yield*/, user.hover(screen.getByText('Nested 1 Label'))];
140
+ case 1:
141
+ _a.sent();
142
+ popper = screen.getByRole('tooltip');
143
+ within(popper).getByText('Pivot profiles');
144
+ within(popper).getByText('0 items');
145
+ return [2 /*return*/];
146
+ }
147
+ });
148
+ }); });
149
+ it('should render label with highlights', function () {
150
+ setUp({ searchValueContextValue: 'ted' });
151
+ var label = screen.getByTestId('reltio-attribute-complex-label');
152
+ expect(label).toHaveTextContent('Nested 1 Label');
153
+ expect(within(label).getByText('ted')).toHaveClass('highlightedText');
75
154
  });
76
155
  });
@@ -10,56 +10,110 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import React from 'react';
13
- import { shallow } from 'enzyme';
13
+ import { render, screen } from '@testing-library/react';
14
14
  import { NestedAttributeEditor } from './NestedAttributeEditor';
15
- import { EditModeComplexAttribute } from '../EditModeComplexAttribute';
16
- import { evaluateDeepEntityLabel, getLabel } from '@reltio/mdm-sdk';
15
+ import { Mode } from '@reltio/mdm-sdk';
16
+ import { MdmModuleProvider } from '../contexts/MdmModuleContext';
17
17
  jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { evaluateDeepEntityLabel: jest.fn(), getLabel: jest.fn() })); });
18
- describe('NestedAttributeEditor', function () {
19
- it('should render EditModeComplexAttribute with specified label and attributes', function () {
20
- var props = {
21
- attributeType: {
22
- type: 'Nested',
23
- attributes: [{}, {}]
24
- },
25
- attributeValue: {}
18
+ var mdmValues = {
19
+ dependentLookups: { editors: {}, structure: {}, initedTypeUris: [] }
20
+ };
21
+ var setUp = function (props) {
22
+ var Providers = function (_a) {
23
+ var children = _a.children;
24
+ return (React.createElement(MdmModuleProvider, { values: mdmValues }, children));
25
+ };
26
+ return render(React.createElement(NestedAttributeEditor, __assign({}, props)), { wrapper: Providers });
27
+ };
28
+ describe('Nested attribute editor tests', function () {
29
+ it('should render correctly with attributes', function () {
30
+ var attributeType = {
31
+ uri: 'configuration/entityTypes/HCP/attributes/NestedTest',
32
+ type: 'Nested',
33
+ name: 'NestedTest',
34
+ label: 'Nested Test',
35
+ attributes: [
36
+ {
37
+ uri: 'configuration/entityTypes/HCP/attributes/NestedTest/attributes/FirstName',
38
+ type: 'String',
39
+ name: 'FirstName',
40
+ label: 'First Name'
41
+ }
42
+ ]
26
43
  };
27
- var label = 'Label123';
28
- evaluateDeepEntityLabel.mockReturnValue(label);
29
- getLabel.mockReturnValue(label);
30
- var component = shallow(React.createElement(NestedAttributeEditor, __assign({}, props)));
31
- var complex = component.find(EditModeComplexAttribute);
32
- expect(complex.length).toBe(1);
33
- expect(complex.prop('label')).toBe(label);
34
- expect(complex.prop('attributeValue')).toBe(props.attributeValue);
35
- expect(complex.prop('attributeType')).toBe(props.attributeType);
36
- expect(complex.prop('attributeTypesList')).toBe(props.attributeType.attributes);
37
- });
38
- it('should use analyticsAttributes if there are no attributes in attribute type', function () {
39
44
  var props = {
40
- attributeType: {
41
- type: 'Nested',
42
- analyticsAttributes: [{}, {}]
45
+ mode: Mode.Editing,
46
+ expanded: true,
47
+ metadata: {
48
+ entityTypes: [{ uri: 'configuration/entityTypes/HCP', label: 'HCP', attributes: [attributeType] }]
49
+ },
50
+ onAddAttributes: jest.fn(),
51
+ onDeleteAttribute: jest.fn(),
52
+ onChangeAttribute: jest.fn(),
53
+ additionalControlsRenderer: function () { return null; },
54
+ attributeValue: {
55
+ uri: 'entities/rhW31Ms7/attributes/NestedTest/72NsbAsm9',
56
+ type: 'configuration/entityTypes/HCP/attributes/NestedTest',
57
+ value: {
58
+ FirstName: [
59
+ {
60
+ uri: 'entities/rhW31Ms7/attributes/NestedTest/72NsbAsm9/FirstName/91NsaK26',
61
+ value: 'first name value'
62
+ }
63
+ ]
64
+ }
43
65
  },
44
- attributeValue: {}
66
+ attributeType: attributeType
45
67
  };
46
- var component = shallow(React.createElement(NestedAttributeEditor, __assign({}, props)));
47
- var complex = component.find(EditModeComplexAttribute);
48
- expect(complex.length).toBe(1);
49
- expect(complex.prop('attributeTypesList')).toBe(props.attributeType.analyticsAttributes);
50
- expect(complex.prop('expanded')).toBeFalsy();
68
+ setUp(props);
69
+ screen.getByText('More attributes');
70
+ screen.getByText('First Name');
71
+ expect(screen.getByRole('textbox')).toHaveValue('first name value');
51
72
  });
52
- it('should pass extended prop to ComplexAttribute', function () {
73
+ it('should render correctly with analytics attributes', function () {
74
+ var attributeType = {
75
+ uri: 'configuration/entityTypes/HCP/analyticsAttributes/IQ',
76
+ type: 'Nested',
77
+ name: 'IQ',
78
+ label: 'IQ',
79
+ analyticsAttributes: [
80
+ {
81
+ uri: 'configuration/entityTypes/HCP/analyticsAttributes/IQ/analyticsAttributes/score',
82
+ type: 'Int',
83
+ name: 'score',
84
+ label: 'IQ Score'
85
+ }
86
+ ]
87
+ };
53
88
  var props = {
54
- attributeType: {
55
- type: 'Nested'
89
+ mode: Mode.Editing,
90
+ expanded: true,
91
+ metadata: {
92
+ entityTypes: [
93
+ { uri: 'configuration/entityTypes/HCP', label: 'HCP', analyticsAttributes: [attributeType] }
94
+ ]
95
+ },
96
+ onAddAttributes: jest.fn(),
97
+ onDeleteAttribute: jest.fn(),
98
+ onChangeAttribute: jest.fn(),
99
+ additionalControlsRenderer: function () { return null; },
100
+ attributeValue: {
101
+ uri: 'entities/rhW31Ms7/analyticsAttributes/IQ/72NsbAsm9',
102
+ type: 'configuration/entityTypes/HCP/attributes/IQ',
103
+ value: {
104
+ score: [
105
+ {
106
+ uri: 'entities/rhW31Ms7/attributes/IQ/72NsbAsm9/score/91NsaK26',
107
+ value: 100
108
+ }
109
+ ]
110
+ }
56
111
  },
57
- attributeValue: {},
58
- expanded: true
112
+ attributeType: attributeType
59
113
  };
60
- var component = shallow(React.createElement(NestedAttributeEditor, __assign({}, props)));
61
- var complex = component.find(EditModeComplexAttribute);
62
- expect(complex.length).toBe(1);
63
- expect(complex.prop('expanded')).toBeTruthy();
114
+ setUp(props);
115
+ expect(screen.queryByText('More attributes')).not.toBeInTheDocument();
116
+ screen.getByText('IQ Score');
117
+ screen.getByText('100');
64
118
  });
65
119
  });