@reltio/components 1.4.2070 → 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 +1 -1
  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
@@ -9,182 +9,189 @@ 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 { act } from 'react-dom/test-utils';
14
- import { mount, shallow } from 'enzyme';
49
+ import userEvent from '@testing-library/user-event';
50
+ import { render, screen, within } from '@testing-library/react';
15
51
  import { SortingStrategy } from '@reltio/mdm-sdk';
52
+ import { MdmModuleProvider } from '../contexts/MdmModuleContext';
53
+ import { getMuiIconByName } from '../test-utils';
54
+ import { attributesList, parent } from './attributes.test-data';
16
55
  import { MoreAttributesButton } from './MoreAttributesButton';
17
- import Button from '@mui/material/Button';
18
- import MenuItem from '@mui/material/MenuItem';
19
- import AddIcon from '@mui/icons-material/Add';
20
- import { AttributeListItem } from '../AttributeListItem/';
21
- import { SelectionPopup } from '../SelectionPopup';
22
- import { Highlighter } from '../Highlighter';
23
- import { Marginator } from '../Marginator';
24
- import { useMdmAttributesSortingStrategy } from '../contexts/MdmModuleContext';
25
- import { attributesList, attributesListForParent, parent } from './attributes.test-data';
26
- jest.mock('../contexts/MdmModuleContext', function () { return (__assign(__assign({}, jest.requireActual('../contexts/MdmModuleContext')), { useMdmAttributesSortingStrategy: jest.fn() })); });
27
- describe('MoreAttributesButton tests', function () {
28
- var onApplyFn = jest.fn();
56
+ var defaultProps = { label: 'More attributes', data: attributesList, onApply: jest.fn() };
57
+ var setUp = function (_a) {
58
+ var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? defaultProps : _c, _d = _b.mdmValues, mdmValues = _d === void 0 ? {} : _d;
59
+ var user = userEvent.setup();
60
+ var Providers = function (_a) {
61
+ var children = _a.children;
62
+ return (React.createElement(MdmModuleProvider, { values: mdmValues }, children));
63
+ };
64
+ return __assign(__assign({}, render(React.createElement(MoreAttributesButton, __assign({}, props)), { wrapper: Providers })), { user: user });
65
+ };
66
+ describe('More attributes button tests', function () {
29
67
  afterEach(function () {
30
- onApplyFn.mockClear();
31
- });
32
- beforeEach(function () {
33
- useMdmAttributesSortingStrategy.mockReturnValue(undefined);
68
+ jest.clearAllMocks();
34
69
  });
35
70
  it('should render button with label and plus', function () {
36
- var label = 'More attributes';
37
- var component = shallow(React.createElement(MoreAttributesButton, { label: label, data: attributesList, onApply: onApplyFn }));
38
- var button = component.find(Button);
39
- expect(button.length).toBe(1);
40
- expect(button.text().includes(label)).toBe(true);
41
- expect(button.find(AddIcon)).toHaveLength(1);
42
- });
43
- it('should open popup onclicking the button', function () {
44
- var label = 'More attributes';
45
- var component = mount(React.createElement(MoreAttributesButton, { popupTitle: label, data: attributesList, onApply: onApplyFn }));
46
- var button = component.find(Button);
47
- button.find('button').simulate('click');
48
- component.update();
49
- var popup = component.find('Portal');
50
- var popupLabel = popup.findWhere(function (n) { return n.prop('className') === 'header'; });
51
- expect(popupLabel.text()).toBe(label);
52
- var listItems = popup.find(AttributeListItem);
53
- expect(listItems.length).toBe(attributesList.length);
54
- listItems.forEach(function (item, index) {
55
- var label = attributesList[index].required
56
- ? (attributesList[index].label || attributesList[index].name) + '*'
57
- : attributesList[index].label || attributesList[index].name;
58
- expect(item.text().includes(label)).toBeTruthy();
59
- expect(item.find('SvgSimpleAttribute').exists()).toBe(true);
60
- expect(item.find(Marginator).prop('level')).toBe(0);
61
- expect(item.find('input').prop('checked')).toBe(false);
62
- });
63
- });
64
- it('should render popup with groups, if parent is provided', function () {
65
- var label = 'More attributes';
66
- var parentAttributeType = parent;
67
- var component = mount(React.createElement(MoreAttributesButton, { popupTitle: label, data: attributesListForParent, parent: parentAttributeType, onApply: onApplyFn }));
68
- var button = component.find(Button);
69
- button.find('button').simulate('click');
70
- component.update();
71
- var popup = component.find('Portal');
72
- var popupLabel = popup.findWhere(function (n) { return n.hasClass('header'); });
73
- expect(popupLabel.text()).toBe(label);
74
- var groupLabels = popup.findWhere(function (n) { return n.type() === 'div' && n.hasClass('subHeader'); });
75
- expect(groupLabels.at(0).text().includes('Parent')).toBeTruthy();
76
- expect(groupLabels.at(1).text().includes('Attributes')).toBeTruthy();
77
- var listItems = popup.find(AttributeListItem);
78
- expect(listItems.length).toBe(attributesListForParent.length + 1);
79
- var item = listItems.at(0);
80
- expect(item.text().includes(parent.label)).toBeTruthy();
81
- expect(item.find('SvgNestedAttribute').exists()).toBeTruthy();
82
- expect(item.find('input').prop('checked')).toBeFalsy();
83
- var offsetSimpleItems = 1;
84
- var simpleItems = listItems.slice(offsetSimpleItems);
85
- simpleItems.forEach(function (item, index) {
86
- var label = attributesListForParent[index].required
87
- ? attributesListForParent[index].label + '*'
88
- : attributesListForParent[index].label;
89
- expect(item.text().includes(label)).toBeTruthy();
90
- expect(item.find('SvgSimpleAttribute').exists()).toBe(true);
91
- expect(item.find('input').prop('checked')).toBe(false);
92
- });
71
+ setUp();
72
+ expect(getMuiIconByName('Add', screen.getByRole('button', { name: 'More attributes' }))).toBeInTheDocument();
93
73
  });
94
- it('should set filter for attributes and provide filter to AttributeListItem', function () {
95
- var label = 'More attributes';
96
- var component = mount(React.createElement(MoreAttributesButton, { label: label, data: attributesList, onApply: onApplyFn }));
97
- var button = component.find(Button);
98
- button.find('button').simulate('click');
99
- component.update();
100
- var filterText = 'na';
101
- act(function () {
102
- component.find(SelectionPopup).prop('onSearch')(filterText);
74
+ it('should open and close popup correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
75
+ var user, popover, menuItems;
76
+ return __generator(this, function (_a) {
77
+ switch (_a.label) {
78
+ case 0:
79
+ user = setUp().user;
80
+ return [4 /*yield*/, user.click(screen.getByText('More attributes'))];
81
+ case 1:
82
+ _a.sent();
83
+ popover = screen.getByRole('presentation');
84
+ within(popover).getByText('More attributes');
85
+ within(popover).getByPlaceholderText('Search & add attributes');
86
+ menuItems = within(popover).getAllByRole('menuitem');
87
+ expect(menuItems).toHaveLength(4);
88
+ expect(menuItems[0]).toHaveTextContent('Role');
89
+ within(menuItems[0]).getByTestId('SvgSimpleAttribute');
90
+ expect(menuItems[1]).toHaveTextContent('Name*');
91
+ within(menuItems[1]).getByTestId('SvgSimpleAttribute');
92
+ expect(menuItems[2]).toHaveTextContent('Last name');
93
+ within(menuItems[2]).getByTestId('SvgSimpleAttribute');
94
+ expect(menuItems[3]).toHaveTextContent('Required*');
95
+ within(menuItems[3]).getByTestId('SvgSimpleAttribute');
96
+ return [4 /*yield*/, user.keyboard('{Escape}')];
97
+ case 2:
98
+ _a.sent();
99
+ expect(defaultProps.onApply).not.toHaveBeenCalled();
100
+ expect(popover).not.toBeInTheDocument();
101
+ return [2 /*return*/];
102
+ }
103
103
  });
104
- component.update();
105
- var popup = component.find('Portal');
106
- var listItems = popup.find(AttributeListItem);
107
- var filteredAttributes = attributesList.filter(function (attr) {
108
- return (attr.label || attr.name).toLowerCase().includes(filterText.toLowerCase());
104
+ }); });
105
+ it('should render popup with groups, if parent is provided', function () { return __awaiter(void 0, void 0, void 0, function () {
106
+ var props, user, menuItems;
107
+ return __generator(this, function (_a) {
108
+ switch (_a.label) {
109
+ case 0:
110
+ props = __assign(__assign({}, defaultProps), { parent: parent });
111
+ user = setUp({ props: props }).user;
112
+ return [4 /*yield*/, user.click(screen.getByText('More attributes'))];
113
+ case 1:
114
+ _a.sent();
115
+ screen.getAllByText('Attributes');
116
+ screen.getAllByText('Parent');
117
+ menuItems = screen.getAllByRole('menuitem');
118
+ expect(menuItems).toHaveLength(5);
119
+ expect(menuItems[0]).toHaveTextContent('Taxonomy');
120
+ within(menuItems[0]).getByTestId('SvgNestedAttribute');
121
+ expect(menuItems[1]).toHaveTextContent('Role');
122
+ within(menuItems[1]).getByTestId('SvgSimpleAttribute');
123
+ expect(menuItems[2]).toHaveTextContent('Name*');
124
+ within(menuItems[2]).getByTestId('SvgSimpleAttribute');
125
+ expect(menuItems[3]).toHaveTextContent('Last name');
126
+ within(menuItems[3]).getByTestId('SvgSimpleAttribute');
127
+ expect(menuItems[4]).toHaveTextContent('Required*');
128
+ within(menuItems[4]).getByTestId('SvgSimpleAttribute');
129
+ return [2 /*return*/];
130
+ }
109
131
  });
110
- expect(listItems.length).toBe(filteredAttributes.length);
111
- listItems.forEach(function (item, index) {
112
- var attribute = filteredAttributes[index];
113
- var label = attribute.label + (attribute.required ? '*' : '');
114
- expect(item.text().includes(label)).toBeTruthy();
115
- expect(item.find('SvgSimpleAttribute').exists()).toBe(true);
116
- expect(item.find('input').prop('checked')).toBe(false);
117
- expect(item.find(Highlighter).prop('text')).toBe(attribute.label);
118
- expect(item.find(Highlighter).prop('highlight')).toBe(filterText);
119
- expect(item.prop('labelInText')).toBe(attribute.label);
132
+ }); });
133
+ it('should filter attributes correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
134
+ var user, menuItems;
135
+ return __generator(this, function (_a) {
136
+ switch (_a.label) {
137
+ case 0:
138
+ user = setUp().user;
139
+ return [4 /*yield*/, user.click(screen.getByText('More attributes'))];
140
+ case 1:
141
+ _a.sent();
142
+ return [4 /*yield*/, user.type(screen.getByPlaceholderText('Search & add attributes'), 'na')];
143
+ case 2:
144
+ _a.sent();
145
+ menuItems = screen.getAllByRole('menuitem');
146
+ expect(menuItems).toHaveLength(2);
147
+ expect(menuItems[0]).toHaveTextContent('Name*');
148
+ expect(within(menuItems[0]).getByText('Na')).toHaveClass('highlight');
149
+ expect(menuItems[1]).toHaveTextContent('Last name');
150
+ expect(within(menuItems[1]).getByText('na')).toHaveClass('highlight');
151
+ return [2 /*return*/];
152
+ }
120
153
  });
121
- });
122
- it('should use case insensitive filter search', function () {
123
- var label = 'More attributes';
124
- var component = mount(React.createElement(MoreAttributesButton, { label: label, data: attributesList, onApply: onApplyFn }));
125
- var button = component.find(Button);
126
- button.find('button').simulate('click');
127
- component.update();
128
- var filterText = 'L';
129
- act(function () {
130
- component.find(SelectionPopup).prop('onSearch')(filterText);
131
- });
132
- component.update();
133
- var popup = component.find('Portal');
134
- var listItems = popup.find(AttributeListItem);
135
- expect(listItems.length).toBe(2);
136
- filterText = 'l';
137
- act(function () {
138
- component.find(SelectionPopup).prop('onSearch')(filterText);
139
- });
140
- component.update();
141
- popup = component.find('Portal');
142
- listItems = popup.find(AttributeListItem);
143
- expect(listItems.length).toBe(2);
144
- });
145
- it('should call props.onApply on popup close if some items selected', function () {
146
- var label = 'More attributes';
147
- var component = mount(React.createElement(MoreAttributesButton, { label: label, data: attributesList, onApply: onApplyFn }));
148
- var button = component.find(Button);
149
- act(function () {
150
- button.find('button').simulate('click');
151
- });
152
- component.update();
153
- var menuItem = component.find('Portal').find(MenuItem).at(0);
154
- act(function () {
155
- menuItem.find('div').at(0).simulate('click');
154
+ }); });
155
+ it('should call props.onApply on popup close if some items selected', function () { return __awaiter(void 0, void 0, void 0, function () {
156
+ var user, popover, backdrop;
157
+ return __generator(this, function (_a) {
158
+ switch (_a.label) {
159
+ case 0:
160
+ user = setUp().user;
161
+ return [4 /*yield*/, user.click(screen.getByText('More attributes'))];
162
+ case 1:
163
+ _a.sent();
164
+ return [4 /*yield*/, user.click(screen.getByText('Role'))];
165
+ case 2:
166
+ _a.sent();
167
+ popover = screen.getByRole('presentation');
168
+ backdrop = popover.children[0];
169
+ return [4 /*yield*/, user.click(backdrop)];
170
+ case 3:
171
+ _a.sent();
172
+ expect(defaultProps.onApply).toHaveBeenCalledWith([attributesList[0]]);
173
+ return [2 /*return*/];
174
+ }
156
175
  });
157
- component.update();
158
- act(function () {
159
- component.find('SelectionPopup').prop('onClose')();
176
+ }); });
177
+ it('should sort attributes if strategy is defined', function () { return __awaiter(void 0, void 0, void 0, function () {
178
+ var mdmValues, user, menuItems;
179
+ return __generator(this, function (_a) {
180
+ switch (_a.label) {
181
+ case 0:
182
+ mdmValues = { attributesSortingStrategy: SortingStrategy.ASC_BY_NAME };
183
+ user = setUp({ mdmValues: mdmValues }).user;
184
+ return [4 /*yield*/, user.click(screen.getByText('More attributes'))];
185
+ case 1:
186
+ _a.sent();
187
+ menuItems = screen.getAllByRole('menuitem');
188
+ expect(menuItems).toHaveLength(4);
189
+ expect(menuItems[0]).toHaveTextContent('Last name');
190
+ expect(menuItems[1]).toHaveTextContent('Name*');
191
+ expect(menuItems[2]).toHaveTextContent('Role');
192
+ expect(menuItems[3]).toHaveTextContent('Required*');
193
+ return [2 /*return*/];
194
+ }
160
195
  });
161
- expect(onApplyFn).toHaveBeenCalledWith([attributesList[0]]);
162
- });
163
- it('should not call props.onApply on popup close if no items selected', function () {
164
- var label = 'More attributes';
165
- var component = mount(React.createElement(MoreAttributesButton, { label: label, data: attributesList, onApply: onApplyFn }));
166
- var button = component.find(Button);
167
- act(function () {
168
- button.find('button').simulate('click');
169
- });
170
- component.update();
171
- act(function () {
172
- component.find('SelectionPopup').prop('onClose')();
173
- });
174
- expect(onApplyFn).not.toHaveBeenCalled();
175
- });
176
- it('should sort attributes if strategy is defined', function () {
177
- var label = 'More attributes';
178
- useMdmAttributesSortingStrategy.mockReturnValue(SortingStrategy.ASC_BY_NAME);
179
- var component = mount(React.createElement(MoreAttributesButton, { popupTitle: label, data: attributesList, onApply: onApplyFn }));
180
- var button = component.find(Button);
181
- button.find('button').simulate('click');
182
- component.update();
183
- var popup = component.find('Portal');
184
- var popupLabel = popup.findWhere(function (n) { return n.prop('className') === 'header'; });
185
- expect(popupLabel.text()).toBe(label);
186
- var listItems = popup.find(AttributeListItem);
187
- expect(listItems.length).toBe(attributesList.length);
188
- expect(listItems.map(function (item) { return item.text(); })).toEqual(['Last name', 'Name*', 'Role', 'Required*']);
189
- });
196
+ }); });
190
197
  });
@@ -9,56 +9,96 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
- if (ar || !(i in from)) {
15
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
16
- ar[i] = from[i];
17
- }
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 };
18
46
  }
19
- return to.concat(ar || Array.prototype.slice.call(from));
20
47
  };
21
48
  import React from 'react';
22
- import { shallow } from 'enzyme';
23
- import { act } from 'react-dom/test-utils';
24
- import { MultiSelect } from '../MultiSelect';
49
+ import { render, screen } from '@testing-library/react';
50
+ import userEvent from '@testing-library/user-event';
25
51
  import MultiValueSelector from './MultiValueSelector';
26
- describe('MultiValueSelector tests', function () {
52
+ describe('Multi value selector tests', function () {
27
53
  var defaultProps = {
28
54
  values: [],
29
55
  onChange: jest.fn(),
30
56
  options: [
31
- { value: '1', label: 'Test 1' },
32
- { value: '2', label: 'Test 2' }
57
+ { value: 'orange', label: 'Orange' },
58
+ { value: 'banana', label: 'Banana' },
59
+ { value: 'apple', label: 'Apple' }
33
60
  ]
34
61
  };
35
- it('should render MultiSelect with correct props', function () {
36
- var component = shallow(React.createElement(MultiValueSelector, __assign({}, defaultProps)));
37
- var selector = component.find(MultiSelect);
38
- expect(selector).toHaveLength(1);
39
- expect(selector.props()).toMatchObject({
40
- value: [],
41
- onChange: expect.any(Function),
42
- options: defaultProps.options
62
+ it('should render correctly in basic case', function () { return __awaiter(void 0, void 0, void 0, function () {
63
+ var user, options;
64
+ return __generator(this, function (_a) {
65
+ switch (_a.label) {
66
+ case 0:
67
+ user = userEvent.setup();
68
+ render(React.createElement(MultiValueSelector, __assign({}, defaultProps)));
69
+ return [4 /*yield*/, user.click(screen.getByRole('combobox'))];
70
+ case 1:
71
+ _a.sent();
72
+ options = screen.getAllByRole('option');
73
+ expect(options).toHaveLength(3);
74
+ expect(options[0]).toHaveTextContent('Orange');
75
+ expect(options[1]).toHaveTextContent('Banana');
76
+ expect(options[2]).toHaveTextContent('Apple');
77
+ return [2 /*return*/];
78
+ }
43
79
  });
44
- });
80
+ }); });
45
81
  it('should set correct value property', function () {
46
- var component = shallow(React.createElement(MultiValueSelector, __assign({}, defaultProps, { values: ['2'] })));
47
- var selector = component.find(MultiSelect);
48
- expect(selector).toHaveLength(1);
49
- expect(selector.props()).toMatchObject({
50
- value: [defaultProps.options[1]],
51
- onChange: expect.any(Function),
52
- options: defaultProps.options
53
- });
82
+ render(React.createElement(MultiValueSelector, __assign({}, defaultProps, { values: ['orange', 'apple'] })));
83
+ screen.getByText('Orange');
84
+ screen.getByText('Apple');
54
85
  });
55
- it('should call onChange', function () {
56
- var component = shallow(React.createElement(MultiValueSelector, __assign({}, defaultProps)));
57
- var selector = component.find(MultiSelect);
58
- expect(selector).toHaveLength(1);
59
- act(function () {
60
- selector.prop('onChange')(__spreadArray([], defaultProps.options, true));
86
+ it('should call onChange on item click', function () { return __awaiter(void 0, void 0, void 0, function () {
87
+ var user;
88
+ return __generator(this, function (_a) {
89
+ switch (_a.label) {
90
+ case 0:
91
+ user = userEvent.setup();
92
+ render(React.createElement(MultiValueSelector, __assign({}, defaultProps)));
93
+ return [4 /*yield*/, user.click(screen.getByRole('combobox'))];
94
+ case 1:
95
+ _a.sent();
96
+ return [4 /*yield*/, user.click(screen.getByText('Apple'))];
97
+ case 2:
98
+ _a.sent();
99
+ expect(defaultProps.onChange).toHaveBeenCalledWith(['apple']);
100
+ return [2 /*return*/];
101
+ }
61
102
  });
62
- expect(defaultProps.onChange).toHaveBeenCalledWith(['1', '2']);
63
- });
103
+ }); });
64
104
  });