@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.
- package/FacetViewHeader/FacetViewHeader.js +1 -1
- package/ImageAttributesLine/imageAttributeValues.test-data.js +8 -0
- package/ImageAttributesLine/index.d.ts +1 -1
- package/ImageAttributesLine/index.js +1 -1
- package/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.js +1 -1
- package/MergeButton/MergeButton.spec.js +55 -124
- package/MetadataTypesSelector/MetadataTypesSelector.js +1 -1
- package/MetadataTypesSelector/MetadataTypesSelector.test.js +193 -190
- package/MoreAttributesButton/MoreAttributesButton.test.js +173 -166
- package/MultiValueSelector/MultiValueSelector.test.js +78 -38
- package/MultipliableSelect/MultipliableSelect.test.js +111 -47
- package/NestedAttribute/NestedAttribute.test.js +121 -42
- package/NestedAttributeEditor/NestedAttributeEditor.test.js +95 -41
- package/NotMatchButton/NotMatchButton.spec.js +51 -100
- package/PieChart/PieChart.test.js +130 -114
- package/PinButton/PinButton.spec.js +89 -22
- package/PivotingTooltip/PivotingTooltip.test.js +338 -174
- package/PotentialMatchReviewCard/PotentialMatchReviewCard.spec.js +94 -29
- package/ProfileBand/ProfileBand.spec.js +60 -53
- package/ProfileCard/ProfileCard.test.js +109 -27
- package/ProfilesList/ProfilesList.d.ts +1 -3
- package/ProfilesList/ProfilesList.js +1 -1
- package/ProfilesList/ProfilesList.spec.js +226 -211
- package/QueryBuilderRow/QueryBuilderRow.spec.js +83 -90
- package/QueryBuilderRowsGroup/QueryBuilderRowsGroup.spec.js +195 -86
- package/ReactSelectLoadMoreButton/ReactSelectLoadMoreButton.test.js +73 -15
- package/ReactSelectMenuWithPopper/ReactSelectMenuWithPopper.test.js +71 -117
- package/ReadOnlyAttributeValuesBlock/ReadOnlyAttributeValuesBlock.test.js +128 -61
- package/ReadOnlyAttributesFactory/components/ReadOnlyAttribute/ReadOnlyAttribute.test.js +179 -44
- package/ReadOnlyAttributesList/ReadOnlyAttributesList.test.js +254 -211
- package/ReadOnlyAttributesList/attributes.test-data.js +4 -4
- package/ReadOnlyAttributesPager/ReadOnlyAttributesPager.test.js +75 -18
- package/ReadOnlyAttributesView/ReadOnlyAttributesView.test.js +187 -312
- package/ReadOnlyComplexAttribute/ReadOnlyComplexAttribute.test.js +210 -219
- package/ReadOnlyImageAttributesLine/ReadOnlyImageAttributesLine.test.js +89 -89
- package/ReferenceAttributeEditor/ReferenceAttributeEditor.test.js +556 -602
- package/ReferenceAttributeEditor/metadata.test-data.d.ts +13 -13
- package/ReferenceAttributeEditor/metadata.test-data.js +2 -2
- package/ReferenceAttributeEditor/styles.d.ts +1 -1
- package/RelationEditor/RelationEditor.test.js +1448 -1392
- package/RelationTypeSelector/RelationTypeSelector.test.js +99 -17
- package/RelationTypesSelector/RelationTypesSelector.test.js +73 -22
- package/ReltioMap/ReltioMap.spec.js +51 -25
- package/Roles/Roles.test.js +54 -10
- package/ScreenProfileBand/ScreenProfileBand.test.js +142 -72
- package/cjs/FacetViewHeader/FacetViewHeader.js +1 -1
- package/cjs/ImageAttributesLine/imageAttributeValues.test-data.js +8 -0
- package/cjs/ImageAttributesLine/index.d.ts +1 -1
- package/cjs/ImageAttributesLine/index.js +2 -1
- package/cjs/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.js +1 -1
- package/cjs/MergeButton/MergeButton.spec.js +55 -124
- package/cjs/MetadataTypesSelector/MetadataTypesSelector.js +1 -1
- package/cjs/MetadataTypesSelector/MetadataTypesSelector.test.js +193 -190
- package/cjs/MoreAttributesButton/MoreAttributesButton.test.js +172 -165
- package/cjs/MultiValueSelector/MultiValueSelector.test.js +78 -38
- package/cjs/MultipliableSelect/MultipliableSelect.test.js +111 -47
- package/cjs/NestedAttribute/NestedAttribute.test.js +121 -42
- package/cjs/NestedAttributeEditor/NestedAttributeEditor.test.js +94 -40
- package/cjs/NotMatchButton/NotMatchButton.spec.js +51 -100
- package/cjs/PieChart/PieChart.test.js +130 -114
- package/cjs/PinButton/PinButton.spec.js +89 -22
- package/cjs/PivotingTooltip/PivotingTooltip.test.js +338 -174
- package/cjs/PotentialMatchReviewCard/PotentialMatchReviewCard.spec.js +94 -29
- package/cjs/ProfileBand/ProfileBand.spec.js +60 -53
- package/cjs/ProfileCard/ProfileCard.test.js +109 -27
- package/cjs/ProfilesList/ProfilesList.d.ts +1 -3
- package/cjs/ProfilesList/ProfilesList.js +1 -1
- package/cjs/ProfilesList/ProfilesList.spec.js +226 -211
- package/cjs/QueryBuilderRow/QueryBuilderRow.spec.js +83 -90
- package/cjs/QueryBuilderRowsGroup/QueryBuilderRowsGroup.spec.js +195 -86
- package/cjs/ReactSelectLoadMoreButton/ReactSelectLoadMoreButton.test.js +73 -15
- package/cjs/ReactSelectMenuWithPopper/ReactSelectMenuWithPopper.test.js +71 -117
- package/cjs/ReadOnlyAttributeValuesBlock/ReadOnlyAttributeValuesBlock.test.js +128 -61
- package/cjs/ReadOnlyAttributesFactory/components/ReadOnlyAttribute/ReadOnlyAttribute.test.js +179 -44
- package/cjs/ReadOnlyAttributesList/ReadOnlyAttributesList.test.js +254 -211
- package/cjs/ReadOnlyAttributesList/attributes.test-data.js +4 -4
- package/cjs/ReadOnlyAttributesPager/ReadOnlyAttributesPager.test.js +75 -18
- package/cjs/ReadOnlyAttributesView/ReadOnlyAttributesView.test.js +185 -310
- package/cjs/ReadOnlyComplexAttribute/ReadOnlyComplexAttribute.test.js +209 -218
- package/cjs/ReadOnlyImageAttributesLine/ReadOnlyImageAttributesLine.test.js +89 -89
- package/cjs/ReferenceAttributeEditor/ReferenceAttributeEditor.test.js +555 -601
- package/cjs/ReferenceAttributeEditor/metadata.test-data.d.ts +13 -13
- package/cjs/ReferenceAttributeEditor/metadata.test-data.js +2 -2
- package/cjs/ReferenceAttributeEditor/styles.d.ts +1 -1
- package/cjs/RelationEditor/RelationEditor.test.js +1446 -1390
- package/cjs/RelationTypeSelector/RelationTypeSelector.test.js +99 -17
- package/cjs/RelationTypesSelector/RelationTypesSelector.test.js +73 -22
- package/cjs/ReltioMap/ReltioMap.spec.js +51 -25
- package/cjs/Roles/Roles.test.js +54 -10
- package/cjs/ScreenProfileBand/ScreenProfileBand.test.js +141 -71
- package/package.json +1 -1
- package/MetadataTypesSelector/components/ListLabel/ListLabel.test.d.ts +0 -1
- package/MetadataTypesSelector/components/ListLabel/ListLabel.test.js +0 -24
- package/PivotingTooltip/IntegrationPivotingTooltip.test.d.ts +0 -1
- package/PivotingTooltip/IntegrationPivotingTooltip.test.js +0 -356
- package/PivotingTooltip/components/PivotingTooltipContent/PivotingTooltipContent.test.d.ts +0 -1
- package/PivotingTooltip/components/PivotingTooltipContent/PivotingTooltipContent.test.js +0 -201
- package/ProfileCard/components/ProfileCardContent/ProfileCardContent.test.d.ts +0 -1
- package/ProfileCard/components/ProfileCardContent/ProfileCardContent.test.js +0 -43
- package/QueryBuilderRow/components/ReadOnlyFilter/ReadOnlyFilter.spec.d.ts +0 -1
- package/QueryBuilderRow/components/ReadOnlyFilter/ReadOnlyFilter.spec.js +0 -31
- package/QueryBuilderRow/components/ReadOnlyLogicOperator/ReadOnlyLogicOperator.spec.d.ts +0 -1
- package/QueryBuilderRow/components/ReadOnlyLogicOperator/ReadOnlyLogicOperator.spec.js +0 -31
- package/ReadOnlyAttributesPager/components/ImageLineRenderer/ImageLineRenderer.test.d.ts +0 -1
- package/ReadOnlyAttributesPager/components/ImageLineRenderer/ImageLineRenderer.test.js +0 -45
- package/ReadOnlyAttributesPager/components/MultiLineRenderer/MultiLineRenderer.test.d.ts +0 -1
- package/ReadOnlyAttributesPager/components/MultiLineRenderer/MultiLineRenderer.test.js +0 -114
- package/ReadOnlyAttributesPager/components/OneLineRenderer/OneLineRenderer.test.d.ts +0 -1
- package/ReadOnlyAttributesPager/components/OneLineRenderer/OneLineRenderer.test.js +0 -107
- package/ReadOnlyAttributesPager/components/SpecialRenderer/SpecialRenderer.test.d.ts +0 -1
- package/ReadOnlyAttributesPager/components/SpecialRenderer/SpecialRenderer.test.js +0 -72
- package/RelationEditor/IntegrationRelationEditor.test.d.ts +0 -1
- package/RelationEditor/IntegrationRelationEditor.test.js +0 -337
- package/ReltioMap/components/MapControlContainer/MapControlContainer.d.ts +0 -10
- package/ReltioMap/components/MapControlContainer/MapControlContainer.js +0 -24
- package/ReltioMap/components/MapControlContainer/MapControlContainer.spec.d.ts +0 -1
- package/ReltioMap/components/MapControlContainer/MapControlContainer.spec.js +0 -33
- package/ReltioMap/components/MapControlContainer/index.d.ts +0 -1
- package/ReltioMap/components/MapControlContainer/index.js +0 -1
- package/ReltioMap/components/TopCenterMapControls/TopCenterMapControls.spec.d.ts +0 -1
- package/ReltioMap/components/TopCenterMapControls/TopCenterMapControls.spec.js +0 -36
- package/ReltioMap/components/TopRightMapControls/TopRightMapControls.spec.d.ts +0 -1
- package/ReltioMap/components/TopRightMapControls/TopRightMapControls.spec.js +0 -60
- package/Roles/components/Role/Role.test.d.ts +0 -1
- package/Roles/components/Role/Role.test.js +0 -55
- package/cjs/MetadataTypesSelector/components/ListLabel/ListLabel.test.d.ts +0 -1
- package/cjs/MetadataTypesSelector/components/ListLabel/ListLabel.test.js +0 -52
- package/cjs/PivotingTooltip/IntegrationPivotingTooltip.test.d.ts +0 -1
- package/cjs/PivotingTooltip/IntegrationPivotingTooltip.test.js +0 -361
- package/cjs/PivotingTooltip/components/PivotingTooltipContent/PivotingTooltipContent.test.d.ts +0 -1
- package/cjs/PivotingTooltip/components/PivotingTooltipContent/PivotingTooltipContent.test.js +0 -206
- package/cjs/ProfileCard/components/ProfileCardContent/ProfileCardContent.test.d.ts +0 -1
- package/cjs/ProfileCard/components/ProfileCardContent/ProfileCardContent.test.js +0 -48
- package/cjs/QueryBuilderRow/components/ReadOnlyFilter/ReadOnlyFilter.spec.d.ts +0 -1
- package/cjs/QueryBuilderRow/components/ReadOnlyFilter/ReadOnlyFilter.spec.js +0 -36
- package/cjs/QueryBuilderRow/components/ReadOnlyLogicOperator/ReadOnlyLogicOperator.spec.d.ts +0 -1
- package/cjs/QueryBuilderRow/components/ReadOnlyLogicOperator/ReadOnlyLogicOperator.spec.js +0 -36
- package/cjs/ReadOnlyAttributesPager/components/ImageLineRenderer/ImageLineRenderer.test.d.ts +0 -1
- package/cjs/ReadOnlyAttributesPager/components/ImageLineRenderer/ImageLineRenderer.test.js +0 -50
- package/cjs/ReadOnlyAttributesPager/components/MultiLineRenderer/MultiLineRenderer.test.d.ts +0 -1
- package/cjs/ReadOnlyAttributesPager/components/MultiLineRenderer/MultiLineRenderer.test.js +0 -119
- package/cjs/ReadOnlyAttributesPager/components/OneLineRenderer/OneLineRenderer.test.d.ts +0 -1
- package/cjs/ReadOnlyAttributesPager/components/OneLineRenderer/OneLineRenderer.test.js +0 -112
- package/cjs/ReadOnlyAttributesPager/components/SpecialRenderer/SpecialRenderer.test.d.ts +0 -1
- package/cjs/ReadOnlyAttributesPager/components/SpecialRenderer/SpecialRenderer.test.js +0 -77
- package/cjs/RelationEditor/IntegrationRelationEditor.test.d.ts +0 -1
- package/cjs/RelationEditor/IntegrationRelationEditor.test.js +0 -342
- package/cjs/ReltioMap/components/MapControlContainer/MapControlContainer.d.ts +0 -10
- package/cjs/ReltioMap/components/MapControlContainer/MapControlContainer.js +0 -28
- package/cjs/ReltioMap/components/MapControlContainer/MapControlContainer.spec.d.ts +0 -1
- package/cjs/ReltioMap/components/MapControlContainer/MapControlContainer.spec.js +0 -38
- package/cjs/ReltioMap/components/MapControlContainer/index.d.ts +0 -1
- package/cjs/ReltioMap/components/MapControlContainer/index.js +0 -5
- package/cjs/ReltioMap/components/TopCenterMapControls/TopCenterMapControls.spec.d.ts +0 -1
- package/cjs/ReltioMap/components/TopCenterMapControls/TopCenterMapControls.spec.js +0 -41
- package/cjs/ReltioMap/components/TopRightMapControls/TopRightMapControls.spec.d.ts +0 -1
- package/cjs/ReltioMap/components/TopRightMapControls/TopRightMapControls.spec.js +0 -65
- package/cjs/Roles/components/Role/Role.test.d.ts +0 -1
- 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
|
|
14
|
-
import {
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
describe('
|
|
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
|
-
|
|
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
|
-
|
|
37
|
-
|
|
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
|
|
95
|
-
var
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
var
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
|
123
|
-
var
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
-
|
|
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
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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 {
|
|
23
|
-
import
|
|
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('
|
|
52
|
+
describe('Multi value selector tests', function () {
|
|
27
53
|
var defaultProps = {
|
|
28
54
|
values: [],
|
|
29
55
|
onChange: jest.fn(),
|
|
30
56
|
options: [
|
|
31
|
-
{ value: '
|
|
32
|
-
{ value: '
|
|
57
|
+
{ value: 'orange', label: 'Orange' },
|
|
58
|
+
{ value: 'banana', label: 'Banana' },
|
|
59
|
+
{ value: 'apple', label: 'Apple' }
|
|
33
60
|
]
|
|
34
61
|
};
|
|
35
|
-
it('should render
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
63
|
-
});
|
|
103
|
+
}); });
|
|
64
104
|
});
|