@reltio/components 1.4.2044 → 1.4.2046
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/AttributesFiltersBuilder/AttributesFiltersBuilder.test.js +72 -50
- package/BasicTable/BasicTable.test.js +232 -278
- package/BlobRenderer/BlobRenderer.js +1 -1
- package/ConnectionRelationTypeSelector/ConnectionRelationTypeSelector.test.js +125 -111
- package/DateIntervalSelector/DateIntervalSelector.test.js +87 -65
- package/DefaultCellValueRenderer/DefaultCellValueRenderer.js +1 -1
- package/DefaultCellValueRenderer/DefaultCellValueRenderer.test.js +16 -46
- package/DeleteButton/DeleteButton.spec.js +53 -15
- package/DependentLookupEditor/DependentLookupEditor.test.js +555 -807
- package/Drawer/Drawer.test.js +9 -20
- package/DropDownEditor/DropDownEditor.test.js +81 -29
- package/DropDownMenuButton/DropDownMenuButton.spec.js +101 -70
- package/DropDownSelector/DropDownSelector.test.js +159 -30
- package/EditModeAttributesFactory/EditModeAttributesFactory.test.js +143 -0
- package/EditModeAttributesList/EditModeAttributesList.test.js +277 -224
- package/EditModeAttributesList/attributes.test-data.d.ts +0 -11
- package/EditModeAttributesList/attributes.test-data.js +1 -1
- package/EditModeAttributesPager/EditModeAttributesPager.test.js +698 -234
- package/EditModeAttributesPager/helpers.test.js +2 -12
- package/EditModeAttributesView/EditModeAttributesView.test.js +263 -157
- package/EditModeComplexAttribute/EditModeComplexAttribute.js +1 -1
- package/EditModeComplexAttribute/EditModeComplexAttribute.test.js +313 -298
- package/EditModeComplexAttribute/nestedAttrType.test-data.d.ts +0 -5
- package/EditModeComplexAttribute/nestedAttrType.test-data.js +3 -44
- package/EmptyState/EmptyState.test.js +99 -38
- package/EntityCreator/EntityCreator.test.js +68 -35
- package/EntitySelector/EntitySelector.js +1 -1
- package/EntitySelector/EntitySelector.test.js +275 -422
- package/EntityTypeIcon/EntityTypeIcon.test.js +16 -16
- package/EntityTypesSelector/EntityTypesSelector.test.js +62 -21
- package/ErrorBoundary/ErrorBoundary.test.js +19 -17
- package/ErrorMessage/ErrorMessage.js +1 -1
- package/ErrorPopup/ErrorPopup.test.js +72 -25
- package/ErrorWrapper/ErrorWrapper.test.js +10 -9
- package/ExpandedValueTooltip/ExpandedValueTooltip.test.js +111 -37
- package/FileTypeEditor/FileTypeEditor.test.js +95 -64
- package/FilterValueEditor/FilterValueEditor.test.js +183 -157
- package/FilterValueEditor/components/RangeDataTypeValueEditor/RangeDataTypeValueEditor.js +2 -2
- package/HierarchicalAttributeTooltip/HierarchicalAttributeTooltip.test.js +114 -24
- package/HierarchyNodeTitle/HierarchyNodeTitle.test.js +61 -100
- package/OvIcon/OvIcon.js +2 -2
- package/ProfileCard/components/ProfileCardPlaceholder/ProfileCardPlaceholder.js +2 -2
- package/ShowLess/ShowLess.js +1 -1
- package/SimpleAttributeEditor/SimpleAttributeEditor.js +2 -2
- package/UploadFileButton/components/UploadMode/UploadMode.js +1 -1
- package/cjs/AttributesFiltersBuilder/AttributesFiltersBuilder.test.js +72 -50
- package/cjs/BasicTable/BasicTable.test.js +230 -299
- package/cjs/BlobRenderer/BlobRenderer.js +1 -1
- package/cjs/ConnectionRelationTypeSelector/ConnectionRelationTypeSelector.test.js +125 -111
- package/cjs/DateIntervalSelector/DateIntervalSelector.test.js +87 -65
- package/cjs/DefaultCellValueRenderer/DefaultCellValueRenderer.js +1 -1
- package/cjs/DefaultCellValueRenderer/DefaultCellValueRenderer.test.js +16 -46
- package/cjs/DeleteButton/DeleteButton.spec.js +53 -15
- package/cjs/DependentLookupEditor/DependentLookupEditor.test.js +569 -821
- package/cjs/Drawer/Drawer.test.js +10 -21
- package/cjs/DropDownEditor/DropDownEditor.test.js +81 -29
- package/cjs/DropDownMenuButton/DropDownMenuButton.spec.js +102 -71
- package/cjs/DropDownSelector/DropDownSelector.test.js +159 -30
- package/cjs/EditModeAttributesFactory/EditModeAttributesFactory.test.js +148 -0
- package/cjs/EditModeAttributesList/EditModeAttributesList.test.js +277 -224
- package/cjs/EditModeAttributesList/attributes.test-data.d.ts +0 -11
- package/cjs/EditModeAttributesList/attributes.test-data.js +1 -1
- package/cjs/EditModeAttributesPager/EditModeAttributesPager.test.js +696 -232
- package/cjs/EditModeAttributesPager/helpers.test.js +2 -12
- package/cjs/EditModeAttributesView/EditModeAttributesView.test.js +262 -156
- package/cjs/EditModeComplexAttribute/EditModeComplexAttribute.js +1 -1
- package/cjs/EditModeComplexAttribute/EditModeComplexAttribute.test.js +312 -297
- package/cjs/EditModeComplexAttribute/nestedAttrType.test-data.d.ts +0 -5
- package/cjs/EditModeComplexAttribute/nestedAttrType.test-data.js +3 -44
- package/cjs/EmptyState/EmptyState.test.js +98 -37
- package/cjs/EntityCreator/EntityCreator.test.js +69 -36
- package/cjs/EntitySelector/EntitySelector.js +1 -1
- package/cjs/EntitySelector/EntitySelector.test.js +274 -421
- package/cjs/EntityTypeIcon/EntityTypeIcon.test.js +17 -17
- package/cjs/EntityTypesSelector/EntityTypesSelector.test.js +62 -21
- package/cjs/ErrorBoundary/ErrorBoundary.test.js +19 -17
- package/cjs/ErrorMessage/ErrorMessage.js +1 -1
- package/cjs/ErrorPopup/ErrorPopup.test.js +71 -24
- package/cjs/ErrorWrapper/ErrorWrapper.test.js +10 -9
- package/cjs/ExpandedValueTooltip/ExpandedValueTooltip.test.js +111 -37
- package/cjs/FileTypeEditor/FileTypeEditor.test.js +95 -64
- package/cjs/FilterValueEditor/FilterValueEditor.test.js +182 -156
- package/cjs/FilterValueEditor/components/RangeDataTypeValueEditor/RangeDataTypeValueEditor.js +2 -2
- package/cjs/HierarchicalAttributeTooltip/HierarchicalAttributeTooltip.test.js +114 -24
- package/cjs/HierarchyNodeTitle/HierarchyNodeTitle.test.js +61 -100
- package/cjs/OvIcon/OvIcon.js +2 -2
- package/cjs/ProfileCard/components/ProfileCardPlaceholder/ProfileCardPlaceholder.js +2 -2
- package/cjs/ShowLess/ShowLess.js +1 -1
- package/cjs/SimpleAttributeEditor/SimpleAttributeEditor.js +2 -2
- package/cjs/UploadFileButton/components/UploadMode/UploadMode.js +1 -1
- package/cjs/contexts/ExpandedAttributesContext/useAttributeExpanded.test.js +25 -18
- package/cjs/contexts/MdmModuleContext/hooks.d.ts +2 -2
- package/cjs/contexts/ReloadDataContext/ReloadDataContext.spec.js +16 -53
- package/cjs/test-utils/TestStylesProvider.js +6 -5
- package/contexts/ExpandedAttributesContext/useAttributeExpanded.test.js +25 -18
- package/contexts/MdmModuleContext/hooks.d.ts +2 -2
- package/contexts/ReloadDataContext/ReloadDataContext.spec.js +16 -30
- package/package.json +2 -2
- package/test-utils/TestStylesProvider.js +3 -2
- package/AttributesFiltersBuilder/components/AttributeSelector/AttributeSelector.test.js +0 -101
- package/AttributesFiltersBuilder/components/RowActions/RowActions.test.js +0 -106
- package/BasicTable/IntegrationBasicTable.test.d.ts +0 -1
- package/BasicTable/IntegrationBasicTable.test.js +0 -203
- package/DependentLookupEditor/IntegrationDependentLookupEditor.test.d.ts +0 -1
- package/DependentLookupEditor/IntegrationDependentLookupEditor.test.js +0 -137
- package/DropDownMenuButton/components/DefaultMenuItemRenderer/DefaultMenuItemRenderer.spec.d.ts +0 -1
- package/DropDownMenuButton/components/DefaultMenuItemRenderer/DefaultMenuItemRenderer.spec.js +0 -32
- package/EditModeAttributesFactory/components/EditModeAttribute/EditModeAttribute.test.d.ts +0 -1
- package/EditModeAttributesFactory/components/EditModeAttribute/EditModeAttribute.test.js +0 -106
- package/EditModeAttributesPager/components/AttributeRenderer/AttributeRenderer.test.d.ts +0 -1
- package/EditModeAttributesPager/components/AttributeRenderer/AttributeRenderer.test.js +0 -338
- package/EditModeAttributesPager/components/AttributeRenderer/IntegrationAttributeRenderer.test.d.ts +0 -1
- package/EditModeAttributesPager/components/AttributeRenderer/IntegrationAttributeRenderer.test.js +0 -225
- package/EditModeAttributesPager/components/ImageLineRenderer/ImageLineRenderer.test.d.ts +0 -1
- package/EditModeAttributesPager/components/ImageLineRenderer/ImageLineRenderer.test.js +0 -47
- package/EditModeAttributesPager/components/SpecialRenderer/SpecialRenderer.test.d.ts +0 -1
- package/EditModeAttributesPager/components/SpecialRenderer/SpecialRenderer.test.js +0 -204
- package/EditModeAttributesView/IntegrationEditModeAttributesView.test.d.ts +0 -1
- package/EditModeAttributesView/IntegrationEditModeAttributesView.test.js +0 -246
- package/EditModeAttributesView/metadata.test-data.d.ts +0 -4
- package/EditModeAttributesView/metadata.test-data.js +0 -119
- package/EntityCreator/entityType.test-data.d.ts +0 -52
- package/EntityCreator/entityType.test-data.js +0 -188
- package/EntitySelector/components/ClearIndicator/ClearIndicator.test.d.ts +0 -1
- package/EntitySelector/components/ClearIndicator/ClearIndicator.test.js +0 -27
- package/EntitySelector/components/EntityOption/EntityOption.test.d.ts +0 -1
- package/EntitySelector/components/EntityOption/EntityOption.test.js +0 -79
- package/EntitySelector/components/Group/Group.test.d.ts +0 -1
- package/EntitySelector/components/Group/Group.test.js +0 -65
- package/EntitySelector/components/SingleValue/SingleValue.test.d.ts +0 -1
- package/EntitySelector/components/SingleValue/SingleValue.test.js +0 -78
- package/FilterValueEditor/components/RangeDataTypeValueEditor/RangeDataTypeValueEditor.test.d.ts +0 -1
- package/FilterValueEditor/components/RangeDataTypeValueEditor/RangeDataTypeValueEditor.test.js +0 -76
- package/cjs/AttributesFiltersBuilder/components/AttributeSelector/AttributeSelector.test.d.ts +0 -1
- package/cjs/AttributesFiltersBuilder/components/AttributeSelector/AttributeSelector.test.js +0 -106
- package/cjs/AttributesFiltersBuilder/components/RowActions/RowActions.test.d.ts +0 -1
- package/cjs/AttributesFiltersBuilder/components/RowActions/RowActions.test.js +0 -111
- package/cjs/BasicTable/IntegrationBasicTable.test.d.ts +0 -1
- package/cjs/BasicTable/IntegrationBasicTable.test.js +0 -208
- package/cjs/DependentLookupEditor/IntegrationDependentLookupEditor.test.d.ts +0 -1
- package/cjs/DependentLookupEditor/IntegrationDependentLookupEditor.test.js +0 -142
- package/cjs/DropDownMenuButton/components/DefaultMenuItemRenderer/DefaultMenuItemRenderer.spec.d.ts +0 -1
- package/cjs/DropDownMenuButton/components/DefaultMenuItemRenderer/DefaultMenuItemRenderer.spec.js +0 -37
- package/cjs/EditModeAttributesFactory/components/EditModeAttribute/EditModeAttribute.test.d.ts +0 -1
- package/cjs/EditModeAttributesFactory/components/EditModeAttribute/EditModeAttribute.test.js +0 -111
- package/cjs/EditModeAttributesPager/components/AttributeRenderer/AttributeRenderer.test.d.ts +0 -1
- package/cjs/EditModeAttributesPager/components/AttributeRenderer/AttributeRenderer.test.js +0 -343
- package/cjs/EditModeAttributesPager/components/AttributeRenderer/IntegrationAttributeRenderer.test.d.ts +0 -1
- package/cjs/EditModeAttributesPager/components/AttributeRenderer/IntegrationAttributeRenderer.test.js +0 -230
- package/cjs/EditModeAttributesPager/components/ImageLineRenderer/ImageLineRenderer.test.d.ts +0 -1
- package/cjs/EditModeAttributesPager/components/ImageLineRenderer/ImageLineRenderer.test.js +0 -52
- package/cjs/EditModeAttributesPager/components/SpecialRenderer/SpecialRenderer.test.d.ts +0 -1
- package/cjs/EditModeAttributesPager/components/SpecialRenderer/SpecialRenderer.test.js +0 -209
- package/cjs/EditModeAttributesView/IntegrationEditModeAttributesView.test.d.ts +0 -1
- package/cjs/EditModeAttributesView/IntegrationEditModeAttributesView.test.js +0 -251
- package/cjs/EditModeAttributesView/metadata.test-data.d.ts +0 -4
- package/cjs/EditModeAttributesView/metadata.test-data.js +0 -123
- package/cjs/EntityCreator/entityType.test-data.d.ts +0 -52
- package/cjs/EntityCreator/entityType.test-data.js +0 -191
- package/cjs/EntitySelector/components/ClearIndicator/ClearIndicator.test.d.ts +0 -1
- package/cjs/EntitySelector/components/ClearIndicator/ClearIndicator.test.js +0 -32
- package/cjs/EntitySelector/components/EntityOption/EntityOption.test.d.ts +0 -1
- package/cjs/EntitySelector/components/EntityOption/EntityOption.test.js +0 -84
- package/cjs/EntitySelector/components/Group/Group.test.d.ts +0 -1
- package/cjs/EntitySelector/components/Group/Group.test.js +0 -70
- package/cjs/EntitySelector/components/SingleValue/SingleValue.test.d.ts +0 -1
- package/cjs/EntitySelector/components/SingleValue/SingleValue.test.js +0 -83
- package/cjs/FilterValueEditor/components/RangeDataTypeValueEditor/RangeDataTypeValueEditor.test.d.ts +0 -1
- package/cjs/FilterValueEditor/components/RangeDataTypeValueEditor/RangeDataTypeValueEditor.test.js +0 -81
- package/cjs/contexts/CollaborationContext/CollaborationContextProvider.test.d.ts +0 -1
- package/cjs/contexts/CollaborationContext/CollaborationContextProvider.test.js +0 -104
- package/contexts/CollaborationContext/CollaborationContextProvider.test.d.ts +0 -1
- package/contexts/CollaborationContext/CollaborationContextProvider.test.js +0 -99
- /package/{AttributesFiltersBuilder/components/AttributeSelector/AttributeSelector.test.d.ts → EditModeAttributesFactory/EditModeAttributesFactory.test.d.ts} +0 -0
- /package/{AttributesFiltersBuilder/components/RowActions/RowActions.test.d.ts → cjs/EditModeAttributesFactory/EditModeAttributesFactory.test.d.ts} +0 -0
|
@@ -10,273 +10,737 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
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);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
+
if (ar || !(i in from)) {
|
|
52
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
+
ar[i] = from[i];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
+
};
|
|
13
58
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
59
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
60
|
};
|
|
61
|
+
var _a;
|
|
16
62
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
63
|
var react_1 = __importDefault(require("react"));
|
|
18
|
-
var
|
|
64
|
+
var jsdom_testing_mocks_1 = require("jsdom-testing-mocks");
|
|
65
|
+
var react_2 = require("@testing-library/react");
|
|
66
|
+
var user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
67
|
+
var x_date_pickers_1 = require("@mui/x-date-pickers");
|
|
68
|
+
var AdapterMoment_1 = require("@mui/x-date-pickers/AdapterMoment");
|
|
19
69
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
20
|
-
var EditModeAttributesPager_1 = __importDefault(require("./EditModeAttributesPager"));
|
|
21
|
-
var BranchDecorator_1 = require("../BranchDecorator");
|
|
22
|
-
var AttributeRenderer_1 = require("./components/AttributeRenderer");
|
|
23
|
-
var SpecialRenderer_1 = require("./components/SpecialRenderer");
|
|
24
|
-
var ImageLineRenderer_1 = require("./components/ImageLineRenderer");
|
|
25
|
-
var AttributeTitle_1 = require("../AttributeTitle");
|
|
26
70
|
var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
|
|
71
|
+
var FeaturesContext_1 = require("../contexts/FeaturesContext");
|
|
72
|
+
var HiddenAttributesContext_1 = require("../contexts/HiddenAttributesContext");
|
|
73
|
+
var HasDeletionsContext_1 = require("../contexts/HasDeletionsContext");
|
|
74
|
+
var PinnedAttributesContext_1 = require("../contexts/PinnedAttributesContext");
|
|
75
|
+
var EditModeAttributesPager_1 = __importDefault(require("./EditModeAttributesPager"));
|
|
27
76
|
var ScrollToElementContext_1 = require("../contexts/ScrollToElementContext");
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
77
|
+
var defaultAttributeType = {
|
|
78
|
+
uri: 'configuration/entityTypes/HCP/attributes/Fruit',
|
|
79
|
+
type: 'String',
|
|
80
|
+
name: 'Fruit',
|
|
81
|
+
label: 'Fruit',
|
|
82
|
+
defaultValue: 'pineapple'
|
|
83
|
+
};
|
|
84
|
+
var defaultValues = [
|
|
85
|
+
{ type: defaultAttributeType.uri, uri: 'entities/sIeHttl/attributes/Fruit/apple', value: 'apple', ov: true },
|
|
86
|
+
{ type: defaultAttributeType.uri, uri: 'entities/sIeHttl/attributes/Fruit/kiwi', value: 'kiwi', ov: true },
|
|
87
|
+
{ type: defaultAttributeType.uri, uri: 'entities/sIeHttl/attributes/Fruit/orange', value: 'orange', ov: false },
|
|
88
|
+
{ type: defaultAttributeType.uri, uri: 'entities/sIeHttl/attributes/Fruit/banana', value: 'banana', ov: true },
|
|
89
|
+
{ type: defaultAttributeType.uri, uri: 'entities/sIeHttl/attributes/Fruit/mango', value: 'mango', ov: true },
|
|
90
|
+
{ type: defaultAttributeType.uri, uri: 'entities/sIeHttl/attributes/Fruit/avocado', value: 'avocado', ov: false }
|
|
91
|
+
];
|
|
92
|
+
var entity = { uri: 'entities/sIeHttl', type: 'configuration/entityTypes/HCP' };
|
|
93
|
+
var modifiedEntities = (_a = {}, _a[entity.uri] = entity, _a);
|
|
94
|
+
var dependentLookups = { editors: {}, structure: {}, initedTypeUris: [] };
|
|
95
|
+
var metadata = {
|
|
96
|
+
roles: [{ uri: 'configuration/roles/OfficeStaff', description: '', label: 'Office Staff' }],
|
|
97
|
+
entityTypes: [{ uri: 'configuration/entityTypes/HCP', entityTypeRoleURIs: ['configuration/roles/OfficeStaff'] }]
|
|
98
|
+
};
|
|
99
|
+
var defaultMdmValues = { metadata: metadata, dependentLookups: dependentLookups, entity: entity, modifiedEntities: modifiedEntities };
|
|
100
|
+
var defaultMdmActions = { errorDeactivated: jest.fn(), requestNextPageOfAttributeValues: jest.fn() };
|
|
101
|
+
var defaultProps = {
|
|
102
|
+
attributeType: defaultAttributeType,
|
|
103
|
+
values: defaultValues,
|
|
104
|
+
mode: mdm_sdk_1.Mode.Editing,
|
|
105
|
+
parentUri: 'entities/sIeHttl',
|
|
106
|
+
showEmptyEditors: false,
|
|
107
|
+
onDeleteAttribute: jest.fn(),
|
|
108
|
+
onChangeAttribute: jest.fn(),
|
|
109
|
+
onAddAttributes: jest.fn()
|
|
110
|
+
};
|
|
111
|
+
var setUp = function (_a) {
|
|
112
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? defaultProps : _c, _d = _b.mdmValues, mdmValues = _d === void 0 ? defaultMdmValues : _d, _e = _b.mdmActions, mdmActions = _e === void 0 ? defaultMdmActions : _e, _f = _b.hiddenAttributesContextValue, hiddenAttributesContextValue = _f === void 0 ? {} : _f, _g = _b.pinnedAttributesContextValue, pinnedAttributesContextValue = _g === void 0 ? [] : _g, _h = _b.CustomProviders, CustomProviders = _h === void 0 ? react_1.default.Fragment : _h;
|
|
113
|
+
var user = user_event_1.default.setup();
|
|
114
|
+
var Providers = function (_a) {
|
|
36
115
|
var children = _a.children;
|
|
37
|
-
return react_1.default.createElement(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
type: 'String',
|
|
44
|
-
name: 'Simple',
|
|
45
|
-
label: 'Simple label'
|
|
116
|
+
return (react_1.default.createElement(CustomProviders, null,
|
|
117
|
+
react_1.default.createElement(x_date_pickers_1.LocalizationProvider, { dateAdapter: AdapterMoment_1.AdapterMoment },
|
|
118
|
+
react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { values: mdmValues, actions: mdmActions },
|
|
119
|
+
react_1.default.createElement(HiddenAttributesContext_1.HiddenAttributesContext.Provider, { value: hiddenAttributesContextValue },
|
|
120
|
+
react_1.default.createElement(PinnedAttributesContext_1.PinnedAttributesContext.Provider, { value: pinnedAttributesContextValue },
|
|
121
|
+
react_1.default.createElement(FeaturesContext_1.FeaturesContext.Provider, { value: { showDescription: true } }, children)))))));
|
|
46
122
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
var component = setUp();
|
|
102
|
-
expect(component.find(BranchDecorator_1.BranchDecorator)).toHaveLength(0);
|
|
103
|
-
var attribute = component.find(AttributeRenderer_1.AttributeRenderer);
|
|
104
|
-
expect(attribute).toHaveLength(1);
|
|
105
|
-
expect(attribute.props()).toMatchObject(__assign(__assign({}, defaultProps), { values: values.filter(function (_a) {
|
|
106
|
-
var ov = _a.ov;
|
|
107
|
-
return ov === true;
|
|
108
|
-
}) }));
|
|
123
|
+
return __assign(__assign({}, (0, react_2.render)(react_1.default.createElement(EditModeAttributesPager_1.default, __assign({}, props)), { wrapper: Providers })), { user: user });
|
|
124
|
+
};
|
|
125
|
+
describe('Edit mode attributes pager tests', function () {
|
|
126
|
+
var resizeObserver = (0, jsdom_testing_mocks_1.mockResizeObserver)();
|
|
127
|
+
describe('attribute renderer', function () {
|
|
128
|
+
it('should render title correctly', function () {
|
|
129
|
+
setUp();
|
|
130
|
+
var title = react_2.screen.getByTestId('reltio-attribute-label');
|
|
131
|
+
expect(title).toHaveTextContent('Fruit');
|
|
132
|
+
expect(title).not.toHaveTextContent('*');
|
|
133
|
+
});
|
|
134
|
+
it('should render title correctly if attribute type is required', function () {
|
|
135
|
+
var attributeType = __assign(__assign({}, defaultAttributeType), { required: true });
|
|
136
|
+
var props = __assign(__assign({}, defaultProps), { attributeType: attributeType });
|
|
137
|
+
setUp({ props: props });
|
|
138
|
+
var title = react_2.screen.getByTestId('reltio-attribute-label');
|
|
139
|
+
expect(title).toHaveTextContent('Fruit');
|
|
140
|
+
expect(title).toHaveTextContent('*');
|
|
141
|
+
});
|
|
142
|
+
it('should render description correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
143
|
+
var attributeType, props, user;
|
|
144
|
+
return __generator(this, function (_a) {
|
|
145
|
+
switch (_a.label) {
|
|
146
|
+
case 0:
|
|
147
|
+
attributeType = __assign(__assign({}, defaultAttributeType), { description: 'The soft, pulpy part of a flowering plant that contains seeds' });
|
|
148
|
+
props = __assign(__assign({}, defaultProps), { attributeType: attributeType });
|
|
149
|
+
user = setUp({ props: props }).user;
|
|
150
|
+
expect(react_2.screen.queryByRole('tooltip')).not.toBeInTheDocument();
|
|
151
|
+
return [4 /*yield*/, user.hover(react_2.screen.getByTestId('reltio-description-icon'))];
|
|
152
|
+
case 1:
|
|
153
|
+
_a.sent();
|
|
154
|
+
react_2.screen.getByText('The soft, pulpy part of a flowering plant that contains seeds');
|
|
155
|
+
return [2 /*return*/];
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}); });
|
|
159
|
+
it('should not render description if attribute does not have it', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
160
|
+
return __generator(this, function (_a) {
|
|
161
|
+
setUp();
|
|
162
|
+
expect(react_2.screen.queryByTestId('reltio-description-icon')).not.toBeInTheDocument();
|
|
163
|
+
return [2 /*return*/];
|
|
164
|
+
});
|
|
165
|
+
}); });
|
|
166
|
+
it('should render control attribute icon if controlAttributes has attribute type uri', function () {
|
|
167
|
+
var mdmValues = __assign(__assign({}, defaultMdmValues), { controlAttributes: [
|
|
168
|
+
'configuration/entityTypes/HCP/attributes/Vegatable',
|
|
169
|
+
'configuration/entityTypes/HCP/attributes/Fruit'
|
|
170
|
+
] });
|
|
171
|
+
setUp({ mdmValues: mdmValues });
|
|
172
|
+
react_2.screen.getByTestId('reltio-control-attribute-icon');
|
|
173
|
+
});
|
|
174
|
+
it('should not render control attribute icon if controlAttributes does not have attribute type uri', function () {
|
|
175
|
+
setUp();
|
|
176
|
+
expect(react_2.screen.queryByTestId('reltio-control-attribute-icon')).not.toBeInTheDocument();
|
|
109
177
|
});
|
|
110
|
-
it('should
|
|
111
|
-
var
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
178
|
+
it('should render ov icon and non ov values correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
179
|
+
var user, nonOvValues;
|
|
180
|
+
return __generator(this, function (_a) {
|
|
181
|
+
switch (_a.label) {
|
|
182
|
+
case 0:
|
|
183
|
+
user = setUp().user;
|
|
184
|
+
expect(react_2.screen.queryByRole('tooltip')).not.toBeInTheDocument();
|
|
185
|
+
return [4 /*yield*/, user.hover(react_2.screen.getByText('+ 2'))];
|
|
186
|
+
case 1:
|
|
187
|
+
_a.sent();
|
|
188
|
+
nonOvValues = react_2.screen.getAllByTestId('non-ov-value');
|
|
189
|
+
expect(nonOvValues).toHaveLength(2);
|
|
190
|
+
expect(nonOvValues[0]).toHaveTextContent('orange');
|
|
191
|
+
expect(nonOvValues[1]).toHaveTextContent('avocado');
|
|
192
|
+
return [2 /*return*/];
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}); });
|
|
196
|
+
it('should not render ov icon if showNonOv is true', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
197
|
+
var props;
|
|
198
|
+
return __generator(this, function (_a) {
|
|
199
|
+
props = __assign(__assign({}, defaultProps), { showNonOv: true });
|
|
200
|
+
setUp({ props: props });
|
|
201
|
+
expect(react_2.screen.queryByTestId('ov-icon')).not.toBeInTheDocument();
|
|
202
|
+
return [2 /*return*/];
|
|
203
|
+
});
|
|
204
|
+
}); });
|
|
205
|
+
it('should render cardinality message correctly', function () {
|
|
206
|
+
var attributeType = {
|
|
207
|
+
uri: 'configuration/entityTypes/HCP/attributes/Int',
|
|
208
|
+
type: 'Int',
|
|
209
|
+
name: 'Int',
|
|
210
|
+
label: 'Int',
|
|
211
|
+
cardinality: { minValue: 10 }
|
|
212
|
+
};
|
|
213
|
+
var values = [{ type: attributeType.uri, uri: 'entities/sIeHttl/attributes/Int/1', value: 5, ov: true }];
|
|
214
|
+
var props = __assign(__assign({}, defaultProps), { attributeType: attributeType, values: values });
|
|
215
|
+
setUp({ props: props });
|
|
216
|
+
react_2.screen.getByText('This attribute can have minimum 10 values');
|
|
217
|
+
});
|
|
218
|
+
it('should render, expand and collapse attribute values correctly when max is less than values count', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
219
|
+
var props, user, attributes;
|
|
220
|
+
return __generator(this, function (_a) {
|
|
221
|
+
switch (_a.label) {
|
|
222
|
+
case 0:
|
|
223
|
+
props = __assign(__assign({}, defaultProps), { max: 3 });
|
|
224
|
+
user = setUp({ props: props }).user;
|
|
225
|
+
attributes = react_2.screen.getAllByTestId('reltio-edit-attribute');
|
|
226
|
+
expect(attributes).toHaveLength(3);
|
|
227
|
+
expect((0, react_2.within)(attributes[0]).getByRole('textbox')).toHaveValue('apple');
|
|
228
|
+
expect((0, react_2.within)(attributes[1]).getByRole('textbox')).toHaveValue('kiwi');
|
|
229
|
+
expect((0, react_2.within)(attributes[2]).getByRole('textbox')).toHaveValue('banana');
|
|
230
|
+
expect(react_2.screen.queryByText('Show less')).not.toBeInTheDocument();
|
|
231
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Show 1 more of remaining 1 value'))];
|
|
232
|
+
case 1:
|
|
233
|
+
_a.sent();
|
|
234
|
+
attributes = react_2.screen.getAllByTestId('reltio-edit-attribute');
|
|
235
|
+
expect(attributes).toHaveLength(4);
|
|
236
|
+
expect((0, react_2.within)(attributes[3]).getByRole('textbox')).toHaveValue('mango');
|
|
237
|
+
expect(react_2.screen.queryByTestId('show-more')).not.toBeInTheDocument();
|
|
238
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Show less'))];
|
|
239
|
+
case 2:
|
|
240
|
+
_a.sent();
|
|
241
|
+
attributes = react_2.screen.getAllByTestId('reltio-edit-attribute');
|
|
242
|
+
expect(attributes).toHaveLength(3);
|
|
243
|
+
return [2 /*return*/];
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
}); });
|
|
247
|
+
it('should render, expand and collapse attribute values correctly when showNonOv is true and max is less than values count', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
248
|
+
var mdmValues, props, user, attributes;
|
|
249
|
+
return __generator(this, function (_a) {
|
|
250
|
+
switch (_a.label) {
|
|
251
|
+
case 0:
|
|
252
|
+
mdmValues = __assign(__assign({}, defaultMdmValues), { maxValuesInResponse: 2 });
|
|
253
|
+
props = __assign(__assign({}, defaultProps), { showNonOv: true });
|
|
254
|
+
user = setUp({ props: props, mdmValues: mdmValues }).user;
|
|
255
|
+
attributes = react_2.screen.getAllByTestId('reltio-edit-attribute');
|
|
256
|
+
expect(attributes).toHaveLength(2);
|
|
257
|
+
expect((0, react_2.within)(attributes[0]).getByRole('textbox')).toHaveValue('apple');
|
|
258
|
+
expect((0, react_2.within)(attributes[1]).getByRole('textbox')).toHaveValue('kiwi');
|
|
259
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Show 2 more of remaining 4 value'))];
|
|
260
|
+
case 1:
|
|
261
|
+
_a.sent();
|
|
262
|
+
attributes = react_2.screen.getAllByTestId('reltio-edit-attribute');
|
|
263
|
+
expect(attributes).toHaveLength(4);
|
|
264
|
+
expect((0, react_2.within)(attributes[2]).getByRole('textbox')).toHaveValue('orange');
|
|
265
|
+
expect((0, react_2.within)(attributes[3]).getByRole('textbox')).toHaveValue('banana');
|
|
266
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Show 2 more of remaining 2 value'))];
|
|
267
|
+
case 2:
|
|
268
|
+
_a.sent();
|
|
269
|
+
attributes = react_2.screen.getAllByTestId('reltio-edit-attribute');
|
|
270
|
+
expect(attributes).toHaveLength(6);
|
|
271
|
+
expect((0, react_2.within)(attributes[4]).getByRole('textbox')).toHaveValue('mango');
|
|
272
|
+
expect((0, react_2.within)(attributes[5]).getByRole('textbox')).toHaveValue('avocado');
|
|
273
|
+
expect(react_2.screen.queryByTestId('show-more')).not.toBeInTheDocument();
|
|
274
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Show less'))];
|
|
275
|
+
case 3:
|
|
276
|
+
_a.sent();
|
|
277
|
+
attributes = react_2.screen.getAllByTestId('reltio-edit-attribute');
|
|
278
|
+
expect(attributes).toHaveLength(2);
|
|
279
|
+
react_2.screen.getByText('Show 2 more of remaining 4 value');
|
|
280
|
+
return [2 /*return*/];
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
}); });
|
|
284
|
+
it('should render attribute values correctly if max is not passed', function () {
|
|
285
|
+
setUp();
|
|
286
|
+
var attributes = react_2.screen.getAllByTestId('reltio-edit-attribute');
|
|
287
|
+
expect(attributes).toHaveLength(4);
|
|
288
|
+
expect((0, react_2.within)(attributes[0]).getByRole('textbox')).toHaveValue('apple');
|
|
289
|
+
expect((0, react_2.within)(attributes[1]).getByRole('textbox')).toHaveValue('kiwi');
|
|
290
|
+
expect((0, react_2.within)(attributes[2]).getByRole('textbox')).toHaveValue('banana');
|
|
291
|
+
expect((0, react_2.within)(attributes[3]).getByRole('textbox')).toHaveValue('mango');
|
|
292
|
+
expect(react_2.screen.queryByTestId('show-more')).not.toBeInTheDocument();
|
|
293
|
+
expect(react_2.screen.queryByTestId('show-less')).not.toBeInTheDocument();
|
|
120
294
|
});
|
|
121
|
-
it('should
|
|
295
|
+
it('should render attribute values correctly if showNonOv prop is true and max is not passed', function () {
|
|
122
296
|
var props = __assign(__assign({}, defaultProps), { showNonOv: true });
|
|
123
|
-
|
|
124
|
-
var
|
|
125
|
-
expect(
|
|
297
|
+
setUp({ props: props });
|
|
298
|
+
var attributes = react_2.screen.getAllByTestId('reltio-edit-attribute');
|
|
299
|
+
expect(attributes).toHaveLength(6);
|
|
300
|
+
expect((0, react_2.within)(attributes[0]).getByRole('textbox')).toHaveValue('apple');
|
|
301
|
+
expect((0, react_2.within)(attributes[1]).getByRole('textbox')).toHaveValue('kiwi');
|
|
302
|
+
expect((0, react_2.within)(attributes[2]).getByRole('textbox')).toHaveValue('orange');
|
|
303
|
+
expect((0, react_2.within)(attributes[3]).getByRole('textbox')).toHaveValue('banana');
|
|
304
|
+
expect((0, react_2.within)(attributes[4]).getByRole('textbox')).toHaveValue('mango');
|
|
305
|
+
expect((0, react_2.within)(attributes[5]).getByRole('textbox')).toHaveValue('avocado');
|
|
306
|
+
expect(react_2.screen.queryByTestId('show-more')).not.toBeInTheDocument();
|
|
307
|
+
expect(react_2.screen.queryByTestId('show-less')).not.toBeInTheDocument();
|
|
126
308
|
});
|
|
127
|
-
it('should
|
|
309
|
+
it('should return null if there are no values and showEmptyEditors is falsy', function () {
|
|
310
|
+
var props = __assign(__assign({}, defaultProps), { values: [], showEmptyEditors: false });
|
|
311
|
+
var container = setUp({ props: props }).container;
|
|
312
|
+
expect(container).toBeEmptyDOMElement();
|
|
313
|
+
});
|
|
314
|
+
it('should render special "empty" attribute if there are no values and showEmptyEditors is true', function () {
|
|
315
|
+
var props = __assign(__assign({}, defaultProps), { values: [], showEmptyEditors: true });
|
|
316
|
+
setUp({ props: props });
|
|
317
|
+
expect((0, react_2.within)(react_2.screen.getByTestId('reltio-edit-attribute')).getByRole('textbox')).toHaveValue('');
|
|
318
|
+
});
|
|
319
|
+
it('should render special "empty" attribute if there are no values and attribute are required', function () {
|
|
320
|
+
var attributeType = __assign(__assign({}, defaultAttributeType), { required: true });
|
|
321
|
+
var props = __assign(__assign({}, defaultProps), { attributeType: attributeType, values: [], showEmptyEditors: true });
|
|
322
|
+
setUp({ props: props });
|
|
323
|
+
expect((0, react_2.within)(react_2.screen.getByTestId('reltio-edit-attribute')).getByRole('textbox')).toHaveValue('');
|
|
324
|
+
});
|
|
325
|
+
it('should add 2 attributes on add one more button click for simple "empty" attribute', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
326
|
+
var props, user;
|
|
327
|
+
return __generator(this, function (_a) {
|
|
328
|
+
switch (_a.label) {
|
|
329
|
+
case 0:
|
|
330
|
+
props = __assign(__assign({}, defaultProps), { values: [], showEmptyEditors: true });
|
|
331
|
+
user = setUp({ props: props }).user;
|
|
332
|
+
return [4 /*yield*/, user.click(react_2.screen.getByTestId('reltio-add-one-more-simple-attribute-button'))];
|
|
333
|
+
case 1:
|
|
334
|
+
_a.sent();
|
|
335
|
+
expect(props.onAddAttributes).toHaveBeenCalledWith([
|
|
336
|
+
{
|
|
337
|
+
attributeType: {
|
|
338
|
+
uri: 'configuration/entityTypes/HCP/attributes/Fruit',
|
|
339
|
+
type: 'String',
|
|
340
|
+
name: 'Fruit',
|
|
341
|
+
label: 'Fruit'
|
|
342
|
+
},
|
|
343
|
+
index: Infinity,
|
|
344
|
+
parentUri: props.parentUri
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
attributeType: props.attributeType,
|
|
348
|
+
index: Infinity,
|
|
349
|
+
parentUri: props.parentUri
|
|
350
|
+
}
|
|
351
|
+
]);
|
|
352
|
+
return [2 /*return*/];
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
}); });
|
|
356
|
+
it('should add 1 attribute on on add one more button click for Nested "empty" attribute', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
357
|
+
var attributeType, props, user;
|
|
358
|
+
return __generator(this, function (_a) {
|
|
359
|
+
switch (_a.label) {
|
|
360
|
+
case 0:
|
|
361
|
+
attributeType = __assign(__assign({}, defaultAttributeType), { type: 'Nested' });
|
|
362
|
+
props = __assign(__assign({}, defaultProps), { attributeType: attributeType, values: [], showEmptyEditors: true });
|
|
363
|
+
user = setUp({ props: props }).user;
|
|
364
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Create attribute'))];
|
|
365
|
+
case 1:
|
|
366
|
+
_a.sent();
|
|
367
|
+
expect(props.onAddAttributes).toHaveBeenCalledWith([
|
|
368
|
+
{
|
|
369
|
+
parentUri: props.parentUri,
|
|
370
|
+
index: Infinity,
|
|
371
|
+
attributeType: props.attributeType
|
|
372
|
+
}
|
|
373
|
+
]);
|
|
374
|
+
return [2 /*return*/];
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
}); });
|
|
378
|
+
it('should return null if there are no values, showEmptyEditors is true but delete operation was performed', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
379
|
+
var props, _a, user, container;
|
|
380
|
+
return __generator(this, function (_b) {
|
|
381
|
+
switch (_b.label) {
|
|
382
|
+
case 0:
|
|
383
|
+
props = __assign(__assign({}, defaultProps), { values: [], showEmptyEditors: true });
|
|
384
|
+
_a = setUp({ props: props }), user = _a.user, container = _a.container;
|
|
385
|
+
return [4 /*yield*/, user.click(react_2.screen.getByTestId('reltio-delete-simple-attribute-button'))];
|
|
386
|
+
case 1:
|
|
387
|
+
_b.sent();
|
|
388
|
+
expect(container).toBeEmptyDOMElement();
|
|
389
|
+
return [2 /*return*/];
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
}); });
|
|
393
|
+
it('should render special "empty" attribute if there are no values and attribute is pinned', function () {
|
|
394
|
+
var props = __assign(__assign({}, defaultProps), { values: [] });
|
|
395
|
+
var pinnedAttributesContextValue = [defaultAttributeType.uri];
|
|
396
|
+
setUp({ props: props, pinnedAttributesContextValue: pinnedAttributesContextValue });
|
|
397
|
+
expect((0, react_2.within)(react_2.screen.getByTestId('reltio-edit-attribute')).getByRole('textbox')).toHaveValue('');
|
|
398
|
+
});
|
|
399
|
+
it('should call onAddAttributes with correct params in case when values is not empty', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
400
|
+
var user;
|
|
401
|
+
return __generator(this, function (_a) {
|
|
402
|
+
switch (_a.label) {
|
|
403
|
+
case 0:
|
|
404
|
+
user = setUp().user;
|
|
405
|
+
return [4 /*yield*/, user.click(react_2.screen.getByTestId('reltio-add-one-more-simple-attribute-button'))];
|
|
406
|
+
case 1:
|
|
407
|
+
_a.sent();
|
|
408
|
+
expect(defaultProps.onAddAttributes).toHaveBeenCalledWith([
|
|
409
|
+
{
|
|
410
|
+
attributeType: defaultProps.attributeType,
|
|
411
|
+
index: Infinity,
|
|
412
|
+
parentUri: defaultProps.parentUri
|
|
413
|
+
}
|
|
414
|
+
]);
|
|
415
|
+
return [2 /*return*/];
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
}); });
|
|
419
|
+
it('should render correct if one of the values is masked', function () {
|
|
420
|
+
var values = __spreadArray(__spreadArray([], defaultValues, true), [
|
|
421
|
+
{
|
|
422
|
+
type: defaultAttributeType.uri,
|
|
423
|
+
uri: 'entities/sIeHttl/attributes/Fruit/strawberry',
|
|
424
|
+
value: 'strawberry',
|
|
425
|
+
ov: true,
|
|
426
|
+
masked: true
|
|
427
|
+
}
|
|
428
|
+
], false);
|
|
429
|
+
var props = __assign(__assign({}, defaultProps), { values: values });
|
|
430
|
+
setUp({ props: props });
|
|
431
|
+
var attributes = react_2.screen.getAllByTestId('reltio-edit-attribute');
|
|
432
|
+
expect((0, react_2.within)(attributes[4]).queryByRole('textbox')).not.toBeInTheDocument();
|
|
433
|
+
(0, react_2.within)(attributes[4]).getByText('strawberry');
|
|
434
|
+
});
|
|
435
|
+
it('should not allow to add more values in edit mode if cardinality max value is one', function () {
|
|
436
|
+
var props = __assign(__assign({}, defaultProps), { values: [], showEmptyEditors: true, attributeType: __assign(__assign({}, defaultAttributeType), { cardinality: { maxValue: 1, minValue: 0 } }) });
|
|
437
|
+
setUp({ props: props });
|
|
438
|
+
expect(react_2.screen.queryByTestId('reltio-add-one-more-simple-attribute-button')).not.toBeInTheDocument();
|
|
439
|
+
});
|
|
440
|
+
it('should allow to add more values in edit mode if cardinality max value is more than one', function () {
|
|
441
|
+
var props = __assign(__assign({}, defaultProps), { values: [], showEmptyEditors: true, attributeType: __assign(__assign({}, defaultAttributeType), { cardinality: { maxValue: 2, minValue: 1 } }) });
|
|
442
|
+
setUp({ props: props });
|
|
443
|
+
react_2.screen.getByTestId('reltio-add-one-more-simple-attribute-button');
|
|
444
|
+
});
|
|
445
|
+
it('should highlight error if it have same parent uri, empty uri, and attribute type uri', function () {
|
|
128
446
|
var fullError = {
|
|
129
447
|
type: 'invalid',
|
|
130
|
-
|
|
448
|
+
name: '',
|
|
449
|
+
attributeTypeUri: defaultAttributeType.uri,
|
|
131
450
|
parentUri: defaultProps.parentUri,
|
|
132
|
-
uri:
|
|
451
|
+
uri: undefined,
|
|
133
452
|
source: 'validationService',
|
|
134
453
|
severity: 'ERROR'
|
|
135
454
|
};
|
|
455
|
+
var highlightError = jest.fn();
|
|
456
|
+
var scrollIntoRef = jest.fn();
|
|
136
457
|
var Providers = function (_a) {
|
|
137
458
|
var children = _a.children;
|
|
138
|
-
return (react_1.default.createElement(ScrollToElementContext_1.ScrollToElementContext.Provider, { value: {
|
|
139
|
-
element: fullError,
|
|
140
|
-
highlightError: jest.fn(),
|
|
141
|
-
scrollIntoRef: jest.fn(),
|
|
142
|
-
type: ScrollToElementContext_1.ScrollType.Error
|
|
143
|
-
} }, children));
|
|
459
|
+
return (react_1.default.createElement(ScrollToElementContext_1.ScrollToElementContext.Provider, { value: { element: fullError, highlightError: highlightError, scrollIntoRef: scrollIntoRef, type: ScrollToElementContext_1.ScrollType.Error } }, children));
|
|
144
460
|
};
|
|
145
|
-
|
|
146
|
-
expect(
|
|
461
|
+
setUp({ CustomProviders: Providers });
|
|
462
|
+
expect(scrollIntoRef).toHaveBeenCalled();
|
|
147
463
|
});
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
var
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
expect(
|
|
166
|
-
var attribute = decorator.find(SpecialRenderer_1.SpecialRenderer);
|
|
167
|
-
expect(attribute).toHaveLength(1);
|
|
168
|
-
expect(attribute.props()).toMatchObject(props);
|
|
169
|
-
expect(decorator.find(AttributeTitle_1.AttributeTitle)).toHaveLength(0);
|
|
170
|
-
});
|
|
171
|
-
it('should set enabled BranchDecorator prop as true when drawLines is true', function () {
|
|
172
|
-
var props = __assign(__assign({}, defaultProps), { attributeType: attributeType, drawLines: true });
|
|
173
|
-
var component = setUp({ props: props });
|
|
174
|
-
var decorator = component.find(BranchDecorator_1.BranchDecorator);
|
|
175
|
-
expect(decorator).toHaveLength(1);
|
|
176
|
-
expect(decorator.prop('enabled')).toBe(true);
|
|
177
|
-
expect(decorator.find(SpecialRenderer_1.SpecialRenderer)).toHaveLength(1);
|
|
464
|
+
it('should not highlight error if it have uri', function () {
|
|
465
|
+
var fullError = {
|
|
466
|
+
type: 'invalid',
|
|
467
|
+
name: '',
|
|
468
|
+
attributeTypeUri: defaultAttributeType.uri,
|
|
469
|
+
parentUri: defaultProps.parentUri,
|
|
470
|
+
uri: 'entities/sIeHttl/attributes/Address/edEosww/AddressType/uri$$1627902448724',
|
|
471
|
+
source: 'validationService',
|
|
472
|
+
severity: 'ERROR'
|
|
473
|
+
};
|
|
474
|
+
var highlightError = jest.fn();
|
|
475
|
+
var scrollIntoRef = jest.fn();
|
|
476
|
+
var Providers = function (_a) {
|
|
477
|
+
var children = _a.children;
|
|
478
|
+
return (react_1.default.createElement(ScrollToElementContext_1.ScrollToElementContext.Provider, { value: { element: fullError, highlightError: highlightError, scrollIntoRef: scrollIntoRef, type: ScrollToElementContext_1.ScrollType.Error } }, children));
|
|
479
|
+
};
|
|
480
|
+
setUp({ CustomProviders: Providers });
|
|
481
|
+
expect(scrollIntoRef).not.toHaveBeenCalled();
|
|
178
482
|
});
|
|
179
483
|
});
|
|
180
|
-
describe('
|
|
181
|
-
var
|
|
484
|
+
describe('image line attribute renderer', function () {
|
|
485
|
+
var defaultAttributeType = {
|
|
182
486
|
type: mdm_sdk_1.DataTypes.TYPE_IMAGE,
|
|
183
487
|
label: 'Image',
|
|
488
|
+
name: 'ImageGallery',
|
|
184
489
|
uri: 'configuration/entityTypes/HCP/attributes/ImageGallery'
|
|
185
490
|
};
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
491
|
+
var defaultValues = [
|
|
492
|
+
{
|
|
493
|
+
label: '',
|
|
494
|
+
value: {
|
|
495
|
+
Width: [
|
|
496
|
+
{
|
|
497
|
+
type: 'configuration/entityTypes/HCP/attributes/ImageGallery/attributes/Width',
|
|
498
|
+
value: '200',
|
|
499
|
+
uri: 'entities/sIeHttl/attributes/ImageGallery/1IozCV9I/Width/1IozCuiq'
|
|
500
|
+
}
|
|
501
|
+
],
|
|
502
|
+
Height: [
|
|
503
|
+
{
|
|
504
|
+
type: 'configuration/entityTypes/HCP/attributes/ImageGallery/attributes/Height',
|
|
505
|
+
value: '300',
|
|
506
|
+
uri: 'entities/sIeHttl/attributes/ImageGallery/1IozCV9I/Height/1IozCyz6'
|
|
507
|
+
}
|
|
508
|
+
],
|
|
509
|
+
CdnUrlThumbnail: [
|
|
510
|
+
{
|
|
511
|
+
type: 'configuration/entityTypes/HCP/attributes/ImageGallery/attributes/CdnUrlThumbnail',
|
|
512
|
+
value: 'https://reltio.com/image.png',
|
|
513
|
+
uri: 'entities/sIeHttl/attributes/ImageGallery/1IozCV9I/CdnUrlThumbnail/1IozCqSa'
|
|
514
|
+
}
|
|
515
|
+
]
|
|
516
|
+
},
|
|
517
|
+
uri: 'entities/sIeHttl/attributes/ImageGallery/1IozCV9I'
|
|
518
|
+
}
|
|
519
|
+
];
|
|
520
|
+
var defaultImageLineAttributeProps = __assign(__assign({}, defaultProps), { attributeType: defaultAttributeType, values: defaultValues });
|
|
521
|
+
it('should render title correctly', function () {
|
|
522
|
+
setUp({ props: defaultImageLineAttributeProps });
|
|
523
|
+
var title = react_2.screen.getByTestId('reltio-attribute-label');
|
|
524
|
+
expect(title).toHaveTextContent('Image');
|
|
525
|
+
expect(title).not.toHaveTextContent('*');
|
|
526
|
+
});
|
|
527
|
+
it('should render title correctly if attribute type is required', function () {
|
|
528
|
+
var attributeType = __assign(__assign({}, defaultAttributeType), { required: true });
|
|
529
|
+
var props = __assign(__assign({}, defaultImageLineAttributeProps), { attributeType: attributeType });
|
|
530
|
+
setUp({ props: props });
|
|
531
|
+
var title = react_2.screen.getByTestId('reltio-attribute-label');
|
|
532
|
+
expect(title).toHaveTextContent('Image');
|
|
533
|
+
expect(title).toHaveTextContent('*');
|
|
534
|
+
});
|
|
535
|
+
it('should render description correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
536
|
+
var attributeType, props, user;
|
|
537
|
+
return __generator(this, function (_a) {
|
|
538
|
+
switch (_a.label) {
|
|
539
|
+
case 0:
|
|
540
|
+
attributeType = __assign(__assign({}, defaultAttributeType), { description: 'Image description' });
|
|
541
|
+
props = __assign(__assign({}, defaultImageLineAttributeProps), { attributeType: attributeType });
|
|
542
|
+
user = setUp({ props: props }).user;
|
|
543
|
+
expect(react_2.screen.queryByRole('tooltip')).not.toBeInTheDocument();
|
|
544
|
+
return [4 /*yield*/, user.hover(react_2.screen.getByTestId('reltio-description-icon'))];
|
|
545
|
+
case 1:
|
|
546
|
+
_a.sent();
|
|
547
|
+
react_2.screen.getByText('Image description');
|
|
548
|
+
return [2 /*return*/];
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
}); });
|
|
552
|
+
it('should not render description if attribute does not have it', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
553
|
+
return __generator(this, function (_a) {
|
|
554
|
+
setUp({ props: defaultImageLineAttributeProps });
|
|
555
|
+
expect(react_2.screen.queryByTestId('reltio-description-icon')).not.toBeInTheDocument();
|
|
556
|
+
return [2 /*return*/];
|
|
203
557
|
});
|
|
558
|
+
}); });
|
|
559
|
+
it('should render attribute values correctly', function () {
|
|
560
|
+
setUp({ props: defaultImageLineAttributeProps });
|
|
561
|
+
var imageLine = react_2.screen.getByTestId('image-line-edit-mode');
|
|
562
|
+
resizeObserver.mockElementSize(imageLine, { contentBoxSize: { inlineSize: 1000 } });
|
|
563
|
+
(0, react_2.act)(function () {
|
|
564
|
+
resizeObserver.resize();
|
|
565
|
+
});
|
|
566
|
+
react_2.screen.getByTestId('reltio-upload-image-button');
|
|
567
|
+
var attributeValues = react_2.screen.getAllByTestId('reltio-attribute-value');
|
|
568
|
+
expect(attributeValues).toHaveLength(2);
|
|
569
|
+
expect(attributeValues[0]).toHaveAttribute('src', 'https://reltio.com/image.png');
|
|
570
|
+
(0, react_2.within)(attributeValues[1]).getByTestId('SvgDefaultImage');
|
|
571
|
+
});
|
|
572
|
+
});
|
|
573
|
+
describe('special attribute renderer', function () {
|
|
574
|
+
it('should render Roles component for roles', function () {
|
|
575
|
+
var attributeType = mdm_sdk_1.EntityAttrTypes.roles;
|
|
576
|
+
var props = __assign(__assign({}, defaultProps), { attributeType: attributeType, values: ['configuration/roles/OfficeStaff'] });
|
|
577
|
+
setUp({ props: props });
|
|
578
|
+
expect(react_2.screen.getByTestId('reltio-attribute-label')).toHaveTextContent(attributeType.label);
|
|
579
|
+
expect(react_2.screen.getAllByTestId('reltio-attribute-value')).toHaveLength(1);
|
|
580
|
+
expect(react_2.screen.getByRole('combobox')).toBeInTheDocument();
|
|
581
|
+
expect(react_2.screen.getByText('Office Staff')).toBeInTheDocument();
|
|
204
582
|
});
|
|
205
|
-
it('should
|
|
206
|
-
var
|
|
207
|
-
var
|
|
208
|
-
|
|
209
|
-
expect(
|
|
210
|
-
expect(
|
|
211
|
-
expect(
|
|
583
|
+
it('should render Tags component for tags and special icon before title', function () {
|
|
584
|
+
var attributeType = mdm_sdk_1.EntityAttrTypes.tags;
|
|
585
|
+
var props = __assign(__assign({}, defaultProps), { attributeType: attributeType, values: ['tag1'] });
|
|
586
|
+
setUp({ props: props });
|
|
587
|
+
expect(react_2.screen.getByTestId('reltio-attribute-label')).toHaveTextContent(attributeType.label);
|
|
588
|
+
expect(react_2.screen.getAllByTestId('reltio-attribute-value')).toHaveLength(1);
|
|
589
|
+
expect(react_2.screen.getByRole('textbox')).toBeInTheDocument();
|
|
590
|
+
expect(react_2.screen.getByText('tag1')).toBeInTheDocument();
|
|
591
|
+
});
|
|
592
|
+
it('should render empty Tags', function () {
|
|
593
|
+
var attributeType = mdm_sdk_1.EntityAttrTypes.tags;
|
|
594
|
+
var props = __assign(__assign({}, defaultProps), { attributeType: attributeType, values: [] });
|
|
595
|
+
setUp({ props: props });
|
|
596
|
+
expect(react_2.screen.getByTestId('reltio-attribute-label')).toHaveTextContent(attributeType.label);
|
|
597
|
+
expect(react_2.screen.getAllByTestId('reltio-attribute-value')).toHaveLength(1);
|
|
598
|
+
expect(react_2.screen.getByRole('textbox')).toBeInTheDocument();
|
|
599
|
+
});
|
|
600
|
+
it('should render Attribute component for activeness attributes', function () {
|
|
601
|
+
var attributeType = mdm_sdk_1.EntityAttrTypes.endDate;
|
|
602
|
+
var props = __assign(__assign({}, defaultProps), { attributeType: attributeType, values: [1690891216477] });
|
|
603
|
+
setUp({ props: props });
|
|
604
|
+
expect(react_2.screen.getByTestId('reltio-attribute-label')).toHaveTextContent(attributeType.label);
|
|
605
|
+
expect(react_2.screen.getAllByTestId('reltio-attribute-value')).toHaveLength(1);
|
|
606
|
+
expect(react_2.screen.getByRole('textbox')).toHaveValue('08/01/2023');
|
|
607
|
+
});
|
|
608
|
+
it('should return null if there are no activeness values and showEmptyEditors is falsy', function () {
|
|
609
|
+
var props = __assign(__assign({}, defaultProps), { attributeType: mdm_sdk_1.EntityAttrTypes.endDate, values: [] });
|
|
610
|
+
var container = setUp({ props: props }).container;
|
|
611
|
+
expect(container).toBeEmptyDOMElement();
|
|
612
|
+
});
|
|
613
|
+
it('should render special "empty" activeness attribute if values empty and showEmptyEditors is true', function () {
|
|
614
|
+
var attributeType = mdm_sdk_1.EntityAttrTypes.endDate;
|
|
615
|
+
var props = __assign(__assign({}, defaultProps), { attributeType: attributeType, values: [], showEmptyEditors: true });
|
|
616
|
+
setUp({ props: props });
|
|
617
|
+
expect(react_2.screen.getByTestId('reltio-attribute-label')).toHaveTextContent(attributeType.label);
|
|
618
|
+
expect(react_2.screen.getAllByTestId('reltio-attribute-value')).toHaveLength(1);
|
|
619
|
+
expect(react_2.screen.getByRole('textbox')).toHaveValue('');
|
|
620
|
+
});
|
|
621
|
+
it('should render null if values empty, showEmptyEditors is true but delete operation was performed', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
622
|
+
var props, _a, user, container;
|
|
623
|
+
return __generator(this, function (_b) {
|
|
624
|
+
switch (_b.label) {
|
|
625
|
+
case 0:
|
|
626
|
+
props = __assign(__assign({}, defaultProps), { attributeType: mdm_sdk_1.EntityAttrTypes.endDate, values: [], showEmptyEditors: true });
|
|
627
|
+
_a = setUp({ props: props }), user = _a.user, container = _a.container;
|
|
628
|
+
expect(container).not.toBeEmptyDOMElement();
|
|
629
|
+
return [4 /*yield*/, user.click(react_2.screen.getByTestId('reltio-delete-simple-attribute-button'))];
|
|
630
|
+
case 1:
|
|
631
|
+
_b.sent();
|
|
632
|
+
expect(container).toBeEmptyDOMElement();
|
|
633
|
+
return [2 /*return*/];
|
|
634
|
+
}
|
|
635
|
+
});
|
|
636
|
+
}); });
|
|
637
|
+
it('should call HasDeletionsContext.Provider.value.setHasDeletions on delete operation if context is defined', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
638
|
+
var props, contextValue, CustomProviders, _a, container, user;
|
|
639
|
+
return __generator(this, function (_b) {
|
|
640
|
+
switch (_b.label) {
|
|
641
|
+
case 0:
|
|
642
|
+
props = __assign(__assign({}, defaultProps), { attributeType: mdm_sdk_1.EntityAttrTypes.endDate, values: [], showEmptyEditors: true });
|
|
643
|
+
contextValue = { setHasDeletions: jest.fn(), hasDeletionsMap: {} };
|
|
644
|
+
CustomProviders = function (_a) {
|
|
645
|
+
var children = _a.children;
|
|
646
|
+
return (react_1.default.createElement(HasDeletionsContext_1.HasDeletionsContext.Provider, { value: contextValue }, children));
|
|
647
|
+
};
|
|
648
|
+
_a = setUp({ props: props, CustomProviders: CustomProviders }), container = _a.container, user = _a.user;
|
|
649
|
+
return [4 /*yield*/, user.click(react_2.screen.getByTestId('reltio-delete-simple-attribute-button'))];
|
|
650
|
+
case 1:
|
|
651
|
+
_b.sent();
|
|
652
|
+
expect(react_2.screen.getAllByTestId('reltio-attribute-value')).toHaveLength(1);
|
|
653
|
+
expect(contextValue.setHasDeletions).toHaveBeenCalledWith(props.attributeType.uri, true);
|
|
654
|
+
expect(container).not.toBeEmptyDOMElement();
|
|
655
|
+
return [2 /*return*/];
|
|
656
|
+
}
|
|
657
|
+
});
|
|
658
|
+
}); });
|
|
659
|
+
it('should not crash without context provider and use internal state for hasDeletions', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
660
|
+
var attributeType, props, _a, user, container;
|
|
661
|
+
return __generator(this, function (_b) {
|
|
662
|
+
switch (_b.label) {
|
|
663
|
+
case 0:
|
|
664
|
+
attributeType = mdm_sdk_1.EntityAttrTypes.endDate;
|
|
665
|
+
props = __assign(__assign({}, defaultProps), { attributeType: attributeType, values: [], showEmptyEditors: true });
|
|
666
|
+
_a = setUp({ props: props }), user = _a.user, container = _a.container;
|
|
667
|
+
expect(container).not.toBeEmptyDOMElement();
|
|
668
|
+
return [4 /*yield*/, user.click(react_2.screen.getByTestId('reltio-delete-simple-attribute-button'))];
|
|
669
|
+
case 1:
|
|
670
|
+
_b.sent();
|
|
671
|
+
expect(react_2.screen.queryAllByTestId('reltio-attribute-value')).toHaveLength(0);
|
|
672
|
+
return [2 /*return*/];
|
|
673
|
+
}
|
|
674
|
+
});
|
|
675
|
+
}); });
|
|
676
|
+
it('should pass additional params to attribute component', function () {
|
|
677
|
+
var attributeType = mdm_sdk_1.EntityAttrTypes.endDate;
|
|
678
|
+
var additionalControlsRenderer = function () { return react_1.default.createElement("div", { "data-reltio-id": "additional-controls" }); };
|
|
679
|
+
var props = __assign(__assign({}, defaultProps), { attributeType: attributeType, values: [1690891216477], additionalControlsRenderer: additionalControlsRenderer });
|
|
680
|
+
setUp({ props: props });
|
|
681
|
+
expect(react_2.screen.getByTestId('reltio-attribute-label')).toHaveTextContent(attributeType.label);
|
|
682
|
+
expect(react_2.screen.getAllByTestId('reltio-attribute-value')).toHaveLength(1);
|
|
683
|
+
expect(react_2.screen.getByTestId('additional-controls')).toBeInTheDocument();
|
|
212
684
|
});
|
|
213
685
|
});
|
|
214
|
-
describe('
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
{
|
|
253
|
-
parentUri: defaultProps.parentUri,
|
|
254
|
-
uri: '',
|
|
255
|
-
attributeTypeUri: attributeType.uri,
|
|
256
|
-
message: 'Cardinality error',
|
|
257
|
-
type: 'invalid',
|
|
258
|
-
severity: mdm_sdk_1.ErrorSeverity.ERROR
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
parentUri: defaultProps.parentUri,
|
|
262
|
-
uri: values[0].uri,
|
|
263
|
-
attributeTypeUri: attributeType.uri,
|
|
264
|
-
message: 'Attribute is invalid',
|
|
265
|
-
type: 'invalid',
|
|
266
|
-
severity: mdm_sdk_1.ErrorSeverity.WARNING
|
|
267
|
-
}
|
|
268
|
-
];
|
|
269
|
-
it('should filter active errors correctly', function () {
|
|
270
|
-
var mdmValues = __assign(__assign({}, defaultMdmValues), { profileErrors: errors });
|
|
271
|
-
var component = setUp({ mdmValues: mdmValues });
|
|
272
|
-
var attribute = component.find(AttributeRenderer_1.AttributeRenderer);
|
|
273
|
-
expect(attribute.prop('errors')).toEqual([errors[0], errors[4], errors[5]]);
|
|
686
|
+
describe('errors', function () {
|
|
687
|
+
it('should render error message correctly', function () {
|
|
688
|
+
var profileErrors = [
|
|
689
|
+
{
|
|
690
|
+
type: mdm_sdk_1.ErrorType.invalid,
|
|
691
|
+
uri: '',
|
|
692
|
+
attributeTypeUri: 'configuration/entityTypes/HCP/attributes/Fruit',
|
|
693
|
+
parentUri: 'entities/sIeHttl',
|
|
694
|
+
message: 'Attribute is invalid',
|
|
695
|
+
source: mdm_sdk_1.ErrorSource.local,
|
|
696
|
+
path: []
|
|
697
|
+
}
|
|
698
|
+
];
|
|
699
|
+
var mdmValues = __assign(__assign({}, defaultMdmValues), { profileErrors: profileErrors });
|
|
700
|
+
var props = __assign(__assign({}, defaultProps), { values: [defaultValues[0]] });
|
|
701
|
+
setUp({ props: props, mdmValues: mdmValues });
|
|
702
|
+
var attribute = react_2.screen.getByTestId('reltio-edit-attribute');
|
|
703
|
+
expect((0, react_2.within)(attribute).queryByText('Attribute is invalid')).not.toBeInTheDocument();
|
|
704
|
+
react_2.screen.getByText('Attribute is invalid');
|
|
705
|
+
});
|
|
706
|
+
it('should render active error correctly', function () {
|
|
707
|
+
var profileErrors = [
|
|
708
|
+
{
|
|
709
|
+
type: mdm_sdk_1.ErrorType.missed,
|
|
710
|
+
uri: '',
|
|
711
|
+
attributeTypeUri: 'configuration/entityTypes/HCP/attributes/Fruit',
|
|
712
|
+
parentUri: 'entities/sIeHttl',
|
|
713
|
+
message: 'Attribute is required',
|
|
714
|
+
source: mdm_sdk_1.ErrorSource.local,
|
|
715
|
+
path: []
|
|
716
|
+
}
|
|
717
|
+
];
|
|
718
|
+
var attributeType = __assign(__assign({}, defaultAttributeType), { required: true });
|
|
719
|
+
var mdmValues = __assign(__assign({}, defaultMdmValues), { profileErrors: profileErrors });
|
|
720
|
+
var props = __assign(__assign({}, defaultProps), { attributeType: attributeType, values: [] });
|
|
721
|
+
setUp({ props: props, mdmValues: mdmValues });
|
|
722
|
+
var attribute = react_2.screen.getByTestId('reltio-edit-attribute');
|
|
723
|
+
(0, react_2.within)(attribute).getByText('Attribute is required');
|
|
274
724
|
});
|
|
275
|
-
it('should
|
|
276
|
-
var
|
|
277
|
-
var
|
|
278
|
-
|
|
279
|
-
|
|
725
|
+
it('should not render active error if attribute is hidden', function () {
|
|
726
|
+
var _a;
|
|
727
|
+
var profileErrors = [
|
|
728
|
+
{
|
|
729
|
+
type: mdm_sdk_1.ErrorType.missed,
|
|
730
|
+
uri: '',
|
|
731
|
+
attributeTypeUri: 'configuration/entityTypes/HCP/attributes/Fruit',
|
|
732
|
+
parentUri: 'entities/sIeHttl',
|
|
733
|
+
message: 'Attribute is required',
|
|
734
|
+
source: mdm_sdk_1.ErrorSource.local,
|
|
735
|
+
path: []
|
|
736
|
+
}
|
|
737
|
+
];
|
|
738
|
+
var mdmValues = __assign(__assign({}, defaultMdmValues), { profileErrors: profileErrors });
|
|
739
|
+
var hiddenAttributesContextValue = (_a = {},
|
|
740
|
+
_a[defaultProps.parentUri] = ['configuration/entityTypes/HCP/attributes/Fruit'],
|
|
741
|
+
_a);
|
|
742
|
+
setUp({ mdmValues: mdmValues, hiddenAttributesContextValue: hiddenAttributesContextValue });
|
|
743
|
+
expect(react_2.screen.queryByText('Attribute is required')).not.toBeInTheDocument();
|
|
280
744
|
});
|
|
281
745
|
});
|
|
282
746
|
});
|