@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
|
@@ -10,1487 +10,1543 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
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 };
|
|
19
47
|
}
|
|
20
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
48
|
};
|
|
22
49
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
50
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
51
|
};
|
|
25
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
53
|
var react_1 = __importDefault(require("react"));
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
var
|
|
54
|
+
var react_2 = require("@testing-library/react");
|
|
55
|
+
var user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
56
|
+
var AdapterMoment_1 = require("@mui/x-date-pickers/AdapterMoment");
|
|
57
|
+
var LocalizationProvider_1 = require("@mui/x-date-pickers/LocalizationProvider");
|
|
30
58
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
31
|
-
var RelationEditor_1 = __importDefault(require("./RelationEditor"));
|
|
32
|
-
var ConnectionRelationTypeSelector_1 = require("../ConnectionRelationTypeSelector");
|
|
33
|
-
var ErrorWrapper_1 = require("../ErrorWrapper");
|
|
34
|
-
var EntitySelector_1 = require("../EntitySelector");
|
|
35
|
-
var relations_test_data_1 = require("./relations.test-data");
|
|
36
|
-
var EditModeAttributesList_1 = require("../EditModeAttributesList");
|
|
37
|
-
var EditModeComplexAttribute_1 = require("../EditModeComplexAttribute");
|
|
38
|
-
var EmptyStub_1 = require("../EmptyStub");
|
|
39
59
|
var ScrollToElementContext_1 = require("../contexts/ScrollToElementContext");
|
|
40
60
|
var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), {
|
|
44
|
-
jest.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
jest.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
jest.
|
|
54
|
-
jest.
|
|
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
|
-
|
|
61
|
+
var HiddenAttributesContext_1 = require("../contexts/HiddenAttributesContext");
|
|
62
|
+
var RelationEditor_1 = __importDefault(require("./RelationEditor"));
|
|
63
|
+
jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { typeAheadSearch: jest.fn() })); });
|
|
64
|
+
var highlightError = jest.fn();
|
|
65
|
+
var scrollIntoRef = jest.fn();
|
|
66
|
+
var mdmAction = jest.fn();
|
|
67
|
+
var mdmActions = {
|
|
68
|
+
setInitialInfo: jest.fn(function () { return mdmAction(); }),
|
|
69
|
+
setRelationType: jest.fn(function () { return mdmAction(); }),
|
|
70
|
+
closeRelationEditor: jest.fn(function () { return mdmAction(); }),
|
|
71
|
+
entityCreated: jest.fn(function () { return mdmAction(); }),
|
|
72
|
+
entityDeleted: jest.fn(function () { return mdmAction(); }),
|
|
73
|
+
setRelationEntity: jest.fn(function () { return mdmAction(); }),
|
|
74
|
+
errorDeactivated: jest.fn(function () { return mdmAction(); }),
|
|
75
|
+
errorsSet: jest.fn(function () { return mdmAction(); }),
|
|
76
|
+
addAttributes: jest.fn(function () { return mdmAction(); }),
|
|
77
|
+
modifyAttribute: jest.fn(function () { return mdmAction(); }),
|
|
78
|
+
removeAttribute: jest.fn(function () { return mdmAction(); }),
|
|
79
|
+
addRelation: jest.fn(function (_id, _connection) { return mdmAction(); }),
|
|
80
|
+
editRelation: jest.fn(function (_id, _connection) { return mdmAction(); })
|
|
81
|
+
};
|
|
82
|
+
var defaultRelation = {
|
|
83
|
+
relationUri: 'relations/uri$$Qgs4qfvmR3Daksyb1697627670006',
|
|
84
|
+
relationType: 'configuration/relationTypes/HasAddress',
|
|
85
|
+
relationLabel: 'has address',
|
|
86
|
+
object: {
|
|
87
|
+
type: 'configuration/relationTypes/HasAddress',
|
|
88
|
+
attributes: {},
|
|
89
|
+
uri: 'relations/uri$$Qgs4qfvmR3Daksyb1697627670006'
|
|
90
|
+
},
|
|
91
|
+
direction: 'out'
|
|
92
|
+
};
|
|
93
|
+
var defaultEntity = {
|
|
94
|
+
uri: 'entities/uri$$123',
|
|
95
|
+
type: 'configuration/entityTypes/HCP',
|
|
96
|
+
attributes: {}
|
|
97
|
+
};
|
|
98
|
+
var defaultMdmValues = {
|
|
99
|
+
relations: {},
|
|
100
|
+
modifiedEntities: {},
|
|
101
|
+
entity: defaultEntity,
|
|
102
|
+
dependentLookups: { editors: {}, structure: {}, initedTypeUris: [] },
|
|
103
|
+
uiConfigLayout: [],
|
|
104
|
+
uiConfigProfile: [],
|
|
105
|
+
profileErrors: []
|
|
106
|
+
};
|
|
107
|
+
var defaultProps = {
|
|
108
|
+
connection: { relation: defaultRelation, entity: {} },
|
|
109
|
+
config: {
|
|
110
|
+
id: 'relationView',
|
|
111
|
+
component: mdm_sdk_1.ProfileViewType.Relations,
|
|
112
|
+
content: {
|
|
113
|
+
entityTypes: ['configuration/entityTypes/Location'],
|
|
114
|
+
outRelations: [{ uri: 'configuration/relationTypes/HasAddress', label: '{directionalLabel}' }]
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
metadata: {
|
|
118
|
+
entityTypes: [
|
|
119
|
+
{
|
|
120
|
+
uri: 'configuration/entityTypes/HCP',
|
|
121
|
+
label: 'HCP'
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
uri: 'configuration/entityTypes/Location',
|
|
125
|
+
label: 'Address',
|
|
126
|
+
dataLabelPattern: '{FirstName}',
|
|
127
|
+
attributes: [
|
|
128
|
+
{
|
|
129
|
+
uri: 'configuration/entityTypes/Location/attributes/FirstName',
|
|
130
|
+
type: 'String',
|
|
131
|
+
name: 'FirstName',
|
|
132
|
+
label: 'First Name'
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
uri: 'configuration/entityTypes/Location/attributes/Address',
|
|
136
|
+
type: 'Reference',
|
|
137
|
+
name: 'Address',
|
|
138
|
+
label: 'Address',
|
|
139
|
+
referencedAttributeURIs: []
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
uri: 'configuration/entityTypes/HCA',
|
|
145
|
+
label: 'HCA'
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
relationTypes: [
|
|
149
|
+
{
|
|
150
|
+
uri: 'configuration/relationTypes/HasAddress',
|
|
151
|
+
label: 'has address',
|
|
152
|
+
startObject: {
|
|
153
|
+
objectTypeURI: 'configuration/entityTypes/HCP',
|
|
154
|
+
uri: 'configuration/relationTypes/HasAddress/startObject'
|
|
155
|
+
},
|
|
156
|
+
endObject: {
|
|
157
|
+
objectTypeURI: 'configuration/entityTypes/Location',
|
|
158
|
+
uri: 'configuration/relationTypes/HasAddress/endObject'
|
|
159
|
+
},
|
|
160
|
+
attributes: [
|
|
161
|
+
{
|
|
162
|
+
label: 'ActiveHiddenAttribute',
|
|
163
|
+
name: 'Active',
|
|
164
|
+
type: 'Boolean',
|
|
165
|
+
uri: 'configuration/relationTypes/HasAddress/attributes/Active'
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
label: 'Name',
|
|
169
|
+
name: 'Name',
|
|
170
|
+
type: 'String',
|
|
171
|
+
uri: 'configuration/relationTypes/HasAddress/attributes/Name',
|
|
172
|
+
required: true
|
|
173
|
+
}
|
|
174
|
+
]
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
uri: 'configuration/relationTypes/InternalHCAtoHCA',
|
|
178
|
+
label: 'InternalHCAtoHCA affiliation',
|
|
179
|
+
startObject: {
|
|
180
|
+
objectTypeURI: 'configuration/entityTypes/HCA',
|
|
181
|
+
uri: 'configuration/relationTypes/InternalHCAtoHCA/startObject'
|
|
182
|
+
},
|
|
183
|
+
endObject: {
|
|
184
|
+
objectTypeURI: 'configuration/entityTypes/HCA',
|
|
185
|
+
uri: 'configuration/relationTypes/InternalHCAtoHCA/endObject'
|
|
186
|
+
},
|
|
187
|
+
attributes: [
|
|
188
|
+
{
|
|
189
|
+
label: 'Title',
|
|
190
|
+
name: 'Title',
|
|
191
|
+
type: 'String',
|
|
192
|
+
uri: 'configuration/relationTypes/InternalHCAtoHCA/attributes/Title'
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
label: 'Affiliation Status',
|
|
196
|
+
name: 'AffiliationStatus',
|
|
197
|
+
type: 'String',
|
|
198
|
+
uri: 'configuration/relationTypes/InternalHCAtoHCA/attributes/AffiliationStatus'
|
|
199
|
+
}
|
|
200
|
+
]
|
|
201
|
+
}
|
|
202
|
+
]
|
|
203
|
+
},
|
|
204
|
+
mode: mdm_sdk_1.Mode.Editing
|
|
205
|
+
};
|
|
206
|
+
var setUp = function (_a) {
|
|
207
|
+
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.error, error = _e === void 0 ? null : _e, _f = _b.hiddenAttributes, hiddenAttributes = _f === void 0 ? {} : _f;
|
|
208
|
+
var user = user_event_1.default.setup();
|
|
209
|
+
var Providers = function (_a) {
|
|
210
|
+
var children = _a.children;
|
|
211
|
+
return (react_1.default.createElement(HiddenAttributesContext_1.HiddenAttributesContext.Provider, { value: hiddenAttributes },
|
|
212
|
+
react_1.default.createElement(ScrollToElementContext_1.ScrollToElementContext.Provider, { value: { element: error, highlightError: highlightError, scrollIntoRef: scrollIntoRef, type: ScrollToElementContext_1.ScrollType.Error } },
|
|
213
|
+
react_1.default.createElement(LocalizationProvider_1.LocalizationProvider, { dateAdapter: AdapterMoment_1.AdapterMoment }, children))));
|
|
95
214
|
};
|
|
96
|
-
var
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
MdmModuleContext_1.useMdmProfileErrors.mockReturnValue(mdmValues.profileErrors);
|
|
103
|
-
MdmModuleContext_1.useMdmEntityUri.mockReturnValue(mdmValues.entityUri);
|
|
104
|
-
var Component = function (props) {
|
|
105
|
-
return (react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { actions: mdmActions, values: mdmValues },
|
|
106
|
-
react_1.default.createElement(ScrollToElementContext_1.ScrollToElementContext.Provider, { value: {
|
|
107
|
-
element: contextError,
|
|
108
|
-
highlightError: highlightErrorSpy,
|
|
109
|
-
scrollIntoRef: scrollIntoRefSpy,
|
|
110
|
-
type: ScrollToElementContext_1.ScrollType.Error
|
|
111
|
-
} },
|
|
112
|
-
react_1.default.createElement(RelationEditor_1.default, __assign({}, props)))));
|
|
113
|
-
};
|
|
114
|
-
return (0, enzyme_1.mount)(react_1.default.createElement(Component, __assign({}, props)));
|
|
215
|
+
var result = (0, react_2.render)(react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { actions: mdmActions, values: mdmValues },
|
|
216
|
+
react_1.default.createElement(RelationEditor_1.default, __assign({}, props))), { wrapper: Providers });
|
|
217
|
+
var rerender = function (_a) {
|
|
218
|
+
var newProps = _a.props, newMdmValues = _a.mdmValues;
|
|
219
|
+
return result.rerender(react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { actions: mdmActions, values: __assign(__assign({}, mdmValues), newMdmValues) },
|
|
220
|
+
react_1.default.createElement(RelationEditor_1.default, __assign({}, props, newProps))));
|
|
115
221
|
};
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
EntitySelector_1.EntitySelector.mockImplementation(EmptyStub_1.EmptyStub);
|
|
122
|
-
EditModeAttributesList_1.EditModeAttributesList.mockImplementation(EmptyStub_1.EmptyStub);
|
|
123
|
-
useScrollToAttributeError_1.useScrollToAttributeError.mockReturnValue(scrollToAttributeError);
|
|
222
|
+
return __assign(__assign({}, result), { user: user, rerender: rerender });
|
|
223
|
+
};
|
|
224
|
+
describe('relation editor behaviour', function () {
|
|
225
|
+
beforeEach(function () {
|
|
226
|
+
mdm_sdk_1.typeAheadSearch.mockResolvedValue([]);
|
|
124
227
|
});
|
|
125
228
|
afterEach(function () {
|
|
126
229
|
jest.clearAllMocks();
|
|
127
230
|
});
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
expect(applyButton.prop('disabled')).toBe(true);
|
|
159
|
-
expect(cancelButton.length).toBe(1);
|
|
160
|
-
expect(component.find(EntitySelector_1.EntitySelector).length).toBe(0);
|
|
161
|
-
expect(component.find(EditModeAttributesList_1.EditModeAttributesList).length).toBe(0);
|
|
162
|
-
});
|
|
163
|
-
it('should render EntitySelector and AttributeList if relationType is specified', function () {
|
|
164
|
-
var connection = {
|
|
165
|
-
relation: { relationUri: relationUri, relationType: 'configuration/relationTypes/AccountTeam' },
|
|
166
|
-
entity: {}
|
|
167
|
-
};
|
|
168
|
-
var props = __assign(__assign({}, defaultProps), { connection: connection });
|
|
169
|
-
var component = setUp({ props: props });
|
|
170
|
-
expect(component.find(EntitySelector_1.EntitySelector).length).toBe(1);
|
|
171
|
-
expect(component.find(EditModeAttributesList_1.EditModeAttributesList).length).toBe(1);
|
|
172
|
-
var errorWrapper = component.find(".".concat(scrollToAttributeError.errorClassName));
|
|
173
|
-
expect(errorWrapper).toHaveLength(1);
|
|
174
|
-
expect(errorWrapper.getElement().ref).toBe(scrollToAttributeError.ref);
|
|
175
|
-
});
|
|
176
|
-
it('should call getInOutRelations with correctly params if connection.parentEntityUri does not exist', function () {
|
|
177
|
-
var connection = {
|
|
178
|
-
relation: {
|
|
179
|
-
relationUri: relationUri,
|
|
180
|
-
relationType: 'configuration/relationTypes/AccountTeam',
|
|
181
|
-
direction: mdm_sdk_1.Directions.IN
|
|
182
|
-
},
|
|
183
|
-
entity: {}
|
|
184
|
-
};
|
|
185
|
-
var config = {
|
|
186
|
-
id: 'relationView1',
|
|
187
|
-
content: { entityTypes: ['Type1'] }
|
|
188
|
-
};
|
|
189
|
-
var props = __assign(__assign({}, defaultProps), { connection: connection, config: config });
|
|
190
|
-
setUp({ props: props });
|
|
191
|
-
expect(mdm_sdk_1.getInOutRelations).toHaveBeenCalledWith({
|
|
192
|
-
content: config.content,
|
|
193
|
-
direction: mdm_sdk_1.Directions.IN,
|
|
194
|
-
relationType: 'configuration/relationTypes/AccountTeam',
|
|
195
|
-
mode: editing,
|
|
196
|
-
metadata: {
|
|
197
|
-
relationTypes: []
|
|
231
|
+
it('should render entity selector correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
232
|
+
var activityFilter, searchOptions, mdmValues, user, options;
|
|
233
|
+
return __generator(this, function (_a) {
|
|
234
|
+
switch (_a.label) {
|
|
235
|
+
case 0:
|
|
236
|
+
mdm_sdk_1.typeAheadSearch.mockResolvedValue([
|
|
237
|
+
{ type: 'configuration/entityTypes/Location', label: 'location entity 1', uri: 'entities/0C32GxR' },
|
|
238
|
+
{ type: 'configuration/entityTypes/Location', label: 'location entity 2', uri: 'entities/0G49Cnu' }
|
|
239
|
+
]);
|
|
240
|
+
activityFilter = mdm_sdk_1.ActivityFilter.ACTIVE_ONLY;
|
|
241
|
+
searchOptions = { searchByOv: true, ovOnly: true };
|
|
242
|
+
mdmValues = __assign(__assign({}, defaultMdmValues), { activityFilter: activityFilter, searchOptions: searchOptions });
|
|
243
|
+
user = setUp({ mdmValues: mdmValues }).user;
|
|
244
|
+
react_2.screen.getByText('Select Address profile');
|
|
245
|
+
react_2.screen.getByRole('combobox');
|
|
246
|
+
return [4 /*yield*/, user.click(react_2.screen.getByTestId('select-dropdown-indicator'))];
|
|
247
|
+
case 1:
|
|
248
|
+
_a.sent();
|
|
249
|
+
options = react_2.screen.getAllByRole('option');
|
|
250
|
+
expect(options).toHaveLength(2);
|
|
251
|
+
expect(options[0]).toHaveTextContent('location entity 1');
|
|
252
|
+
expect(options[1]).toHaveTextContent('location entity 2');
|
|
253
|
+
expect(mdm_sdk_1.typeAheadSearch).toHaveBeenCalledWith([defaultProps.metadata.entityTypes[1]], '', {
|
|
254
|
+
activityFilter: 'active',
|
|
255
|
+
globalFilter: '',
|
|
256
|
+
max: 20,
|
|
257
|
+
searchOptions: 'searchByOv',
|
|
258
|
+
sendMasked: false
|
|
259
|
+
});
|
|
260
|
+
return [2 /*return*/];
|
|
198
261
|
}
|
|
199
262
|
});
|
|
200
|
-
});
|
|
201
|
-
it('should
|
|
202
|
-
var
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
relationTypes: []
|
|
263
|
+
}); });
|
|
264
|
+
it('should render attributes list correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
265
|
+
var labels, values;
|
|
266
|
+
return __generator(this, function (_a) {
|
|
267
|
+
switch (_a.label) {
|
|
268
|
+
case 0:
|
|
269
|
+
setUp();
|
|
270
|
+
return [4 /*yield*/, react_2.screen.findByText('More attributes')];
|
|
271
|
+
case 1:
|
|
272
|
+
_a.sent();
|
|
273
|
+
labels = react_2.screen.getAllByTestId('reltio-attribute-label');
|
|
274
|
+
values = react_2.screen.getAllByTestId('reltio-attribute-value');
|
|
275
|
+
expect(labels).toHaveLength(4);
|
|
276
|
+
expect(values).toHaveLength(4);
|
|
277
|
+
expect(labels[0]).toHaveTextContent('Start date');
|
|
278
|
+
expect((0, react_2.within)(values[0]).getByRole('textbox')).toHaveValue('');
|
|
279
|
+
expect(labels[1]).toHaveTextContent('End date');
|
|
280
|
+
expect((0, react_2.within)(values[1]).getByRole('textbox')).toHaveValue('');
|
|
281
|
+
expect(labels[2]).toHaveTextContent('ActiveHiddenAttribute');
|
|
282
|
+
expect((0, react_2.within)(values[2]).getAllByRole('checkbox')[0]).not.toBeChecked();
|
|
283
|
+
expect((0, react_2.within)(values[2]).getAllByRole('checkbox')[1]).not.toBeChecked();
|
|
284
|
+
expect(labels[3]).toHaveTextContent('Name*');
|
|
285
|
+
expect((0, react_2.within)(values[3]).getByRole('textbox')).toHaveValue('');
|
|
286
|
+
return [2 /*return*/];
|
|
225
287
|
}
|
|
226
288
|
});
|
|
227
|
-
});
|
|
228
|
-
it('should
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
id: 'relationView1',
|
|
238
|
-
content: { entityTypes: ['Type1'] }
|
|
239
|
-
};
|
|
240
|
-
var props = __assign(__assign({}, defaultProps), { connection: connection, config: config });
|
|
241
|
-
var component = setUp({ props: props });
|
|
242
|
-
expect(component.find(EntitySelector_1.EntitySelector).prop('entityTypesUris')).toEqual(['Type1']);
|
|
243
|
-
});
|
|
244
|
-
it('should set entityTypesUris prop correctly for EntitySelector if parentEntityUri is missing in connection', function () {
|
|
245
|
-
var connection = {
|
|
246
|
-
relation: {
|
|
247
|
-
relationUri: relationUri,
|
|
248
|
-
relationType: 'configuration/relationTypes/AccountTeam'
|
|
249
|
-
},
|
|
250
|
-
entity: {}
|
|
251
|
-
};
|
|
252
|
-
var config = {
|
|
253
|
-
id: 'relationView1',
|
|
254
|
-
content: { entityTypes: ['Type1'] },
|
|
255
|
-
contentSecondLevel: { entityTypes: ['Type2'] }
|
|
256
|
-
};
|
|
257
|
-
var props = __assign(__assign({}, defaultProps), { connection: connection, config: config });
|
|
258
|
-
var component = setUp({ props: props });
|
|
259
|
-
expect(component.find(EntitySelector_1.EntitySelector).prop('entityTypesUris')).toEqual(['Type1']);
|
|
260
|
-
});
|
|
261
|
-
it('should set entityTypesUris prop correctly for EntitySelector if contentSecondLevel and parentEntityUri exists', function () {
|
|
262
|
-
var connection = {
|
|
263
|
-
relation: {
|
|
264
|
-
relationUri: relationUri,
|
|
265
|
-
relationType: 'configuration/relationTypes/AccountTeam'
|
|
266
|
-
},
|
|
267
|
-
entity: {},
|
|
268
|
-
parentEntityUri: 'entities/123'
|
|
269
|
-
};
|
|
270
|
-
var config = {
|
|
271
|
-
id: 'relationView1',
|
|
272
|
-
content: { entityTypes: ['Type1'] },
|
|
273
|
-
contentSecondLevel: { entityTypes: ['Type2'] }
|
|
274
|
-
};
|
|
275
|
-
var props = __assign(__assign({}, defaultProps), { connection: connection, config: config });
|
|
276
|
-
var component = setUp({ props: props });
|
|
277
|
-
expect(component.find(EntitySelector_1.EntitySelector).prop('entityTypesUris')).toEqual(['Type2']);
|
|
278
|
-
});
|
|
279
|
-
it('should render ErrorWrapper for EntitySelector and show error', function () {
|
|
280
|
-
var connection = {
|
|
281
|
-
relation: {
|
|
282
|
-
relationUri: relationUri,
|
|
283
|
-
relationType: 'configuration/relationTypes/AccountTeam'
|
|
284
|
-
},
|
|
285
|
-
entity: {}
|
|
286
|
-
};
|
|
287
|
-
var profileErrors = [
|
|
288
|
-
{
|
|
289
|
-
parentUri: 'relations/11',
|
|
290
|
-
uri: '',
|
|
291
|
-
attributeTypeUri: 'configuration/relationTypes/AccountTeam',
|
|
292
|
-
message: 'Entity is required',
|
|
293
|
-
deactivated: true,
|
|
294
|
-
type: 'missedRefEntity'
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
parentUri: connection.relation.relationUri,
|
|
298
|
-
uri: '',
|
|
299
|
-
attributeTypeUri: 'configuration/relationTypes/AccountTeam',
|
|
300
|
-
message: 'Entity is required - deactivated',
|
|
301
|
-
deactivated: true,
|
|
302
|
-
type: 'missedRefEntity'
|
|
303
|
-
},
|
|
304
|
-
{
|
|
305
|
-
parentUri: connection.relation.relationUri,
|
|
306
|
-
uri: '',
|
|
307
|
-
attributeTypeUri: 'configuration/relationTypes/AccountTeam',
|
|
308
|
-
message: 'Entity is required',
|
|
309
|
-
type: 'missedRefEntity'
|
|
289
|
+
}); });
|
|
290
|
+
it('should render label correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
291
|
+
return __generator(this, function (_a) {
|
|
292
|
+
switch (_a.label) {
|
|
293
|
+
case 0:
|
|
294
|
+
setUp();
|
|
295
|
+
return [4 /*yield*/, react_2.screen.findByText('Edit item')];
|
|
296
|
+
case 1:
|
|
297
|
+
_a.sent();
|
|
298
|
+
return [2 /*return*/];
|
|
310
299
|
}
|
|
311
|
-
];
|
|
312
|
-
var mdmValues = __assign(__assign({}, defaultMdmValues), { profileErrors: profileErrors });
|
|
313
|
-
var props = __assign(__assign({}, defaultProps), { connection: connection });
|
|
314
|
-
var component = setUp({ props: props, mdmValues: mdmValues });
|
|
315
|
-
var errorWrapper = component.find(ErrorWrapper_1.ErrorWrapper);
|
|
316
|
-
expect(errorWrapper.length).toBe(1);
|
|
317
|
-
expect(errorWrapper.prop('errorMessage')).toBe(profileErrors[2].message);
|
|
318
|
-
expect(errorWrapper.find(EntitySelector_1.EntitySelector).length).toBe(1);
|
|
319
|
-
});
|
|
320
|
-
it('should set correct outRelationTypes and inRelationTypes for RelationTypeSelector', function () {
|
|
321
|
-
var connection = { relation: { relationUri: relationUri }, entity: {} };
|
|
322
|
-
var props = __assign(__assign({}, defaultProps), { connection: connection, config: relations_test_data_1.config, metadata: { relationTypes: relations_test_data_1.relationTypes, entityTypes: [] } });
|
|
323
|
-
var component = setUp({ props: props });
|
|
324
|
-
var relationTypeSelector = component.find(ConnectionRelationTypeSelector_1.ConnectionRelationTypeSelector);
|
|
325
|
-
expect(relationTypeSelector.length).toBe(1);
|
|
326
|
-
expect(relationTypeSelector.prop('relation')).toBe(connection.relation);
|
|
327
|
-
expect(relationTypeSelector.prop('outRelationTypes')).toEqual([relations_test_data_1.relationTypes[0]]);
|
|
328
|
-
expect(relationTypeSelector.prop('inRelationTypes')).toEqual([relations_test_data_1.relationTypes[1]]);
|
|
329
|
-
});
|
|
330
|
-
it('should render default relation type label instead of RelationTypeSelector if there is only one relation type', function () {
|
|
331
|
-
var props = __assign(__assign({}, defaultProps), { config: relations_test_data_1.config, metadata: { relationTypes: relations_test_data_1.relationTypes.slice(0, 1), entityTypes: [] } });
|
|
332
|
-
var component = setUp({ props: props });
|
|
333
|
-
expect(component.find(ConnectionRelationTypeSelector_1.ConnectionRelationTypeSelector).length).toBe(0);
|
|
334
|
-
});
|
|
335
|
-
it('should dispatch setRelationType action on RelationTypeSelector change', function () {
|
|
336
|
-
var props = __assign(__assign({}, defaultProps), { config: relations_test_data_1.config, metadata: { relationTypes: relations_test_data_1.relationTypes, entityTypes: [] } });
|
|
337
|
-
var component = setUp({ props: props });
|
|
338
|
-
var relationTypeSelector = component.find(ConnectionRelationTypeSelector_1.ConnectionRelationTypeSelector);
|
|
339
|
-
expect(relationTypeSelector.length).toBe(1);
|
|
340
|
-
relationTypeSelector.prop('onChange')({ type: relations_test_data_1.relationTypes[1], direction: mdm_sdk_1.Directions.IN });
|
|
341
|
-
expect(mdmActions.setRelationType).toHaveBeenCalledWith(relations_test_data_1.config.id, relationUri, {
|
|
342
|
-
type: relations_test_data_1.relationTypes[1],
|
|
343
|
-
direction: mdm_sdk_1.Directions.IN
|
|
344
|
-
});
|
|
345
|
-
});
|
|
346
|
-
it('should set correct props for EditModeAttributesList', function () {
|
|
347
|
-
var connection = {
|
|
348
|
-
relation: {
|
|
349
|
-
relationUri: relationUri,
|
|
350
|
-
relationType: 'configuration/relationTypes/AccountTeam',
|
|
351
|
-
object: {
|
|
352
|
-
attributes: {
|
|
353
|
-
Role: []
|
|
354
|
-
}
|
|
355
|
-
},
|
|
356
|
-
startDate: 12345,
|
|
357
|
-
endDate: 678910
|
|
358
|
-
},
|
|
359
|
-
entity: {}
|
|
360
|
-
};
|
|
361
|
-
var props = __assign(__assign({}, defaultProps), { connection: connection, metadata: { relationTypes: relations_test_data_1.relationTypes, entityTypes: [] } });
|
|
362
|
-
var component = setUp({ props: props });
|
|
363
|
-
var attributesList = component.find(EditModeAttributesList_1.EditModeAttributesList);
|
|
364
|
-
expect(attributesList.length).toBe(1);
|
|
365
|
-
expect(attributesList.prop('attrTypes')).toEqual(__spreadArray(__spreadArray([], mdm_sdk_1.ACTIVENESS_ATTR_TYPES, true), relations_test_data_1.relationTypes[0].attributes, true));
|
|
366
|
-
expect(attributesList.prop('entity')).toEqual({
|
|
367
|
-
attributes: {
|
|
368
|
-
Role: []
|
|
369
|
-
},
|
|
370
|
-
startDate: 12345,
|
|
371
|
-
endDate: 678910
|
|
372
300
|
});
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
var mdmValues = __assign(__assign({}, defaultMdmValues), { activityFilter: activityFilter, searchOptions: searchOptions });
|
|
388
|
-
var props = __assign(__assign({}, defaultProps), { connection: connection, config: relations_test_data_1.config, metadata: metadata });
|
|
389
|
-
var component = setUp({ props: props, mdmValues: mdmValues });
|
|
390
|
-
var entitySelector = component.find(EntitySelector_1.EntitySelector);
|
|
391
|
-
expect(entitySelector.prop('globalSearchRequestOptions')).toEqual({
|
|
392
|
-
activityFilter: 'active',
|
|
393
|
-
searchOptions: 'searchByOv',
|
|
394
|
-
globalFilter: ''
|
|
301
|
+
}); });
|
|
302
|
+
it('should label for new connection correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
303
|
+
var connection, props;
|
|
304
|
+
return __generator(this, function (_a) {
|
|
305
|
+
switch (_a.label) {
|
|
306
|
+
case 0:
|
|
307
|
+
connection = __assign(__assign({}, defaultProps.connection), { isNew: true });
|
|
308
|
+
props = __assign(__assign({}, defaultProps), { connection: connection });
|
|
309
|
+
setUp({ props: props });
|
|
310
|
+
return [4 /*yield*/, react_2.screen.findByText('Add new item')];
|
|
311
|
+
case 1:
|
|
312
|
+
_a.sent();
|
|
313
|
+
return [2 /*return*/];
|
|
314
|
+
}
|
|
395
315
|
});
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
};
|
|
415
|
-
var props = __assign(__assign({}, defaultProps), { connection: connection, config: relations_test_data_1.config, metadata: { relationTypes: relations_test_data_1.relationTypes, entityTypes: [] } });
|
|
416
|
-
var component = setUp({ props: props });
|
|
417
|
-
var applyButton = findApplyButton(component);
|
|
418
|
-
expect(applyButton.prop('disabled')).toBe(true);
|
|
316
|
+
}); });
|
|
317
|
+
it('should render correctly if parentEntityUri and contentSecondLevel exists', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
318
|
+
var connection, config, props;
|
|
319
|
+
return __generator(this, function (_a) {
|
|
320
|
+
switch (_a.label) {
|
|
321
|
+
case 0:
|
|
322
|
+
connection = __assign(__assign({}, defaultProps.connection), { parentEntityUri: 'entities/HsPM72G' });
|
|
323
|
+
config = __assign(__assign({}, defaultProps.config), { contentSecondLevel: {
|
|
324
|
+
entityTypes: ['configuration/entityTypes/HCA'],
|
|
325
|
+
outRelations: [{ uri: 'configuration/relationTypes/InternalHCAtoHCA', label: '{directionalLabel}' }]
|
|
326
|
+
} });
|
|
327
|
+
props = __assign(__assign({}, defaultProps), { connection: connection, config: config });
|
|
328
|
+
setUp({ props: props });
|
|
329
|
+
return [4 /*yield*/, react_2.screen.findByText('Select HCA profile')];
|
|
330
|
+
case 1:
|
|
331
|
+
_a.sent();
|
|
332
|
+
return [2 /*return*/];
|
|
333
|
+
}
|
|
419
334
|
});
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
draft: 'added'
|
|
435
|
-
},
|
|
436
|
-
relation: {
|
|
437
|
-
relationUri: relationUri,
|
|
438
|
-
relationType: '123',
|
|
439
|
-
object: {
|
|
440
|
-
type: '123'
|
|
441
|
-
}
|
|
442
|
-
},
|
|
443
|
-
entity: {
|
|
444
|
-
entityUri: 'entities/456'
|
|
445
|
-
},
|
|
446
|
-
isNew: true,
|
|
447
|
-
initial: {
|
|
448
|
-
connection: {
|
|
449
|
-
__metadata: {
|
|
450
|
-
draft: 'added'
|
|
451
|
-
},
|
|
452
|
-
relation: {
|
|
453
|
-
relationUri: relationUri,
|
|
454
|
-
relationType: '123',
|
|
455
|
-
object: {
|
|
456
|
-
type: '123'
|
|
457
|
-
}
|
|
458
|
-
},
|
|
459
|
-
entity: {
|
|
460
|
-
entityUri: 'entities/456'
|
|
461
|
-
},
|
|
462
|
-
isNew: true
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
});
|
|
467
|
-
applyButton = findApplyButton(component);
|
|
468
|
-
expect(applyButton.prop('disabled')).toBe(false);
|
|
469
|
-
applyButton.find('button').simulate('click');
|
|
470
|
-
var clearedConnection = {
|
|
471
|
-
relation: {
|
|
472
|
-
relationUri: relationUri,
|
|
473
|
-
relationType: '123',
|
|
474
|
-
object: {
|
|
475
|
-
type: '123'
|
|
476
|
-
}
|
|
477
|
-
},
|
|
478
|
-
entity: {
|
|
479
|
-
entityUri: 'entities/456'
|
|
480
|
-
},
|
|
481
|
-
initial: {
|
|
482
|
-
connection: {
|
|
483
|
-
__metadata: {
|
|
484
|
-
draft: 'added'
|
|
335
|
+
}); });
|
|
336
|
+
it('should show error for entity selector correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
337
|
+
var profileErrors, mdmValues, errorMessage;
|
|
338
|
+
return __generator(this, function (_a) {
|
|
339
|
+
switch (_a.label) {
|
|
340
|
+
case 0:
|
|
341
|
+
profileErrors = [
|
|
342
|
+
{
|
|
343
|
+
parentUri: 'relations/11',
|
|
344
|
+
uri: '',
|
|
345
|
+
attributeTypeUri: defaultRelation.relationType,
|
|
346
|
+
message: 'Entity is required',
|
|
347
|
+
deactivated: true,
|
|
348
|
+
type: mdm_sdk_1.ErrorType.missedRefEntity
|
|
485
349
|
},
|
|
486
|
-
|
|
487
|
-
|
|
350
|
+
{
|
|
351
|
+
parentUri: defaultRelation.relationUri,
|
|
352
|
+
uri: '',
|
|
353
|
+
attributeTypeUri: defaultRelation.relationType,
|
|
354
|
+
message: 'Entity is required - deactivated',
|
|
355
|
+
deactivated: true,
|
|
356
|
+
type: mdm_sdk_1.ErrorType.missedRefEntity
|
|
488
357
|
},
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
relationUri: 'relations/1'
|
|
358
|
+
{
|
|
359
|
+
parentUri: defaultRelation.relationUri,
|
|
360
|
+
uri: '',
|
|
361
|
+
attributeTypeUri: defaultRelation.relationType,
|
|
362
|
+
message: 'Entity is required',
|
|
363
|
+
type: mdm_sdk_1.ErrorType.missedRefEntity
|
|
496
364
|
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
365
|
+
];
|
|
366
|
+
mdmValues = __assign(__assign({}, defaultMdmValues), { profileErrors: profileErrors });
|
|
367
|
+
setUp({ mdmValues: mdmValues });
|
|
368
|
+
return [4 /*yield*/, react_2.screen.findByTestId('error-message')];
|
|
369
|
+
case 1:
|
|
370
|
+
errorMessage = _a.sent();
|
|
371
|
+
expect(errorMessage).toHaveTextContent('Entity is required');
|
|
372
|
+
return [2 /*return*/];
|
|
373
|
+
}
|
|
503
374
|
});
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
label: '
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
375
|
+
}); });
|
|
376
|
+
it('should render relation type selector correctly if it is not possible to evaluate default relation type', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
377
|
+
var config, props, user, relationTypeSelector, options;
|
|
378
|
+
return __generator(this, function (_a) {
|
|
379
|
+
switch (_a.label) {
|
|
380
|
+
case 0:
|
|
381
|
+
config = __assign(__assign({}, defaultProps.config), { content: {
|
|
382
|
+
entityTypes: ['configuration/entityTypes/Location'],
|
|
383
|
+
inRelations: [{ uri: 'configuration/relationTypes/InternalHCAtoHCA', label: '{directionalLabel}' }],
|
|
384
|
+
outRelations: [{ uri: 'configuration/relationTypes/HasAddress', label: '{directionalLabel}' }]
|
|
385
|
+
} });
|
|
386
|
+
props = __assign(__assign({}, defaultProps), { config: config });
|
|
387
|
+
user = setUp({ props: props }).user;
|
|
388
|
+
relationTypeSelector = react_2.screen.getByTestId('relation-type-selector');
|
|
389
|
+
(0, react_2.within)(relationTypeSelector).getByText('Select relationship type');
|
|
390
|
+
(0, react_2.within)(relationTypeSelector).getByText('has address');
|
|
391
|
+
(0, react_2.within)(relationTypeSelector).getByRole('combobox');
|
|
392
|
+
return [4 /*yield*/, user.click((0, react_2.within)(relationTypeSelector).getByTestId('select-dropdown-indicator'))];
|
|
393
|
+
case 1:
|
|
394
|
+
_a.sent();
|
|
395
|
+
options = react_2.screen.getAllByRole('option');
|
|
396
|
+
expect(options).toHaveLength(2);
|
|
397
|
+
expect(options[0]).toHaveTextContent('InternalHCAtoHCA affiliation');
|
|
398
|
+
expect(options[1]).toHaveTextContent('has address');
|
|
399
|
+
return [2 /*return*/];
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
}); });
|
|
403
|
+
it('should dispatch setRelationType action on relation type selector change', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
404
|
+
var config, props, user;
|
|
405
|
+
return __generator(this, function (_a) {
|
|
406
|
+
switch (_a.label) {
|
|
407
|
+
case 0:
|
|
408
|
+
config = __assign(__assign({}, defaultProps.config), { content: {
|
|
409
|
+
entityTypes: ['configuration/entityTypes/Location'],
|
|
410
|
+
inRelations: [{ uri: 'configuration/relationTypes/InternalHCAtoHCA', label: '{directionalLabel}' }],
|
|
411
|
+
outRelations: [{ uri: 'configuration/relationTypes/HasAddress', label: '{directionalLabel}' }]
|
|
412
|
+
} });
|
|
413
|
+
props = __assign(__assign({}, defaultProps), { config: config });
|
|
414
|
+
user = setUp({ props: props }).user;
|
|
415
|
+
return [4 /*yield*/, user.click((0, react_2.within)(react_2.screen.getByTestId('relation-type-selector')).getByTestId('select-dropdown-indicator'))];
|
|
416
|
+
case 1:
|
|
417
|
+
_a.sent();
|
|
418
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('InternalHCAtoHCA affiliation'))];
|
|
419
|
+
case 2:
|
|
420
|
+
_a.sent();
|
|
421
|
+
expect(mdmActions.setRelationType).toHaveBeenCalledWith(props.config.id, expect.any(String), {
|
|
422
|
+
direction: 'in',
|
|
423
|
+
type: __assign(__assign({}, defaultProps.metadata.relationTypes[1]), { endObject: __assign(__assign({}, defaultProps.metadata.relationTypes[1].endObject), { objectType: { label: 'HCA', uri: 'configuration/entityTypes/HCA' } }), startObject: __assign(__assign({}, defaultProps.metadata.relationTypes[1].startObject), { objectType: { label: 'HCA', uri: 'configuration/entityTypes/HCA' } }) })
|
|
424
|
+
});
|
|
425
|
+
return [2 /*return*/];
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
}); });
|
|
429
|
+
it('should show "create entity" button if mode is not suggesting', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
430
|
+
var user, inputs;
|
|
431
|
+
return __generator(this, function (_a) {
|
|
432
|
+
switch (_a.label) {
|
|
433
|
+
case 0:
|
|
434
|
+
user = setUp().user;
|
|
435
|
+
inputs = react_2.screen.getAllByRole('combobox');
|
|
436
|
+
return [4 /*yield*/, user.click(inputs[0])];
|
|
437
|
+
case 1:
|
|
438
|
+
_a.sent();
|
|
439
|
+
expect(mdm_sdk_1.typeAheadSearch).toHaveBeenCalledWith([defaultProps.metadata.entityTypes[1]], '', {
|
|
440
|
+
globalFilter: '',
|
|
441
|
+
max: 20,
|
|
442
|
+
searchOptions: '',
|
|
443
|
+
sendMasked: false
|
|
444
|
+
});
|
|
445
|
+
react_2.screen.getByText('Create new Address');
|
|
446
|
+
return [2 /*return*/];
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
}); });
|
|
450
|
+
it('should show "create entity" button if mode is suggesting, but main entity uri is not temporary', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
451
|
+
var props, mdmValues, user, inputs;
|
|
452
|
+
return __generator(this, function (_a) {
|
|
453
|
+
switch (_a.label) {
|
|
454
|
+
case 0:
|
|
455
|
+
props = __assign(__assign({}, defaultProps), { mode: mdm_sdk_1.Mode.Suggesting });
|
|
456
|
+
mdmValues = __assign(__assign({}, defaultMdmValues), { entity: __assign(__assign({}, defaultEntity), { uri: 'entities/123' }) });
|
|
457
|
+
user = setUp({ props: props, mdmValues: mdmValues }).user;
|
|
458
|
+
inputs = react_2.screen.getAllByRole('combobox');
|
|
459
|
+
return [4 /*yield*/, user.click(inputs[0])];
|
|
460
|
+
case 1:
|
|
461
|
+
_a.sent();
|
|
462
|
+
react_2.screen.getByText('Create new Address');
|
|
463
|
+
return [2 /*return*/];
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
}); });
|
|
467
|
+
it('should show "create entity" button if mode is suggesting, main entity uri is temporary, but authoring mode is enabled for current entity type', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
468
|
+
var uiConfigProfile, props, mdmValues, user, inputs;
|
|
469
|
+
return __generator(this, function (_a) {
|
|
470
|
+
switch (_a.label) {
|
|
471
|
+
case 0:
|
|
472
|
+
uiConfigProfile = [
|
|
572
473
|
{
|
|
573
|
-
label: '
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
474
|
+
label: 'Profile',
|
|
475
|
+
id: 'com.reltio.plugins.ProfileEntityAction',
|
|
476
|
+
class: mdm_sdk_1.ScreenType.Profile,
|
|
477
|
+
entityTypes: {
|
|
478
|
+
'configuration/entityTypes/HCP': {
|
|
479
|
+
views: [],
|
|
480
|
+
layout: [],
|
|
481
|
+
sidePanelViews: [],
|
|
482
|
+
authoring: [{ label: 'Profile details', views: [], layout: [] }]
|
|
483
|
+
}
|
|
484
|
+
}
|
|
578
485
|
}
|
|
579
|
-
]
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
486
|
+
];
|
|
487
|
+
props = __assign(__assign({}, defaultProps), { mode: mdm_sdk_1.Mode.Suggesting });
|
|
488
|
+
mdmValues = __assign(__assign({}, defaultMdmValues), { uiConfigProfile: uiConfigProfile });
|
|
489
|
+
user = setUp({ props: props, mdmValues: mdmValues }).user;
|
|
490
|
+
inputs = react_2.screen.getAllByRole('combobox');
|
|
491
|
+
return [4 /*yield*/, user.click(inputs[0])];
|
|
492
|
+
case 1:
|
|
493
|
+
_a.sent();
|
|
494
|
+
react_2.screen.getByText('Create new Address');
|
|
495
|
+
return [2 /*return*/];
|
|
496
|
+
}
|
|
584
497
|
});
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
}
|
|
601
|
-
},
|
|
602
|
-
entity: {
|
|
603
|
-
entityUri: 'entities/456'
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
});
|
|
607
|
-
applyButton = findApplyButton(component);
|
|
608
|
-
expect(applyButton.prop('disabled')).toBe(false);
|
|
609
|
-
applyButton.find('button').simulate('click');
|
|
610
|
-
var clearedConnection = {
|
|
611
|
-
relation: {
|
|
612
|
-
relationUri: relationUri,
|
|
613
|
-
relationType: '123',
|
|
614
|
-
object: {
|
|
615
|
-
type: '123'
|
|
616
|
-
}
|
|
617
|
-
},
|
|
618
|
-
entity: {
|
|
619
|
-
entityUri: 'entities/456'
|
|
620
|
-
}
|
|
621
|
-
};
|
|
622
|
-
expect(mdmActions.editRelation).toHaveBeenCalledWith(relations_test_data_1.config.id, clearedConnection);
|
|
623
|
-
expect(mdmActions.closeRelationEditor).toHaveBeenCalledWith(relations_test_data_1.config.id, clearedConnection.relation.relationUri);
|
|
498
|
+
}); });
|
|
499
|
+
it('should not show "create entity" button if mode is "Suggesting", main entity uri is temporary and authoring mode is not enabled for current entity type', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
500
|
+
var props, user, inputs;
|
|
501
|
+
return __generator(this, function (_a) {
|
|
502
|
+
switch (_a.label) {
|
|
503
|
+
case 0:
|
|
504
|
+
props = __assign(__assign({}, defaultProps), { mode: mdm_sdk_1.Mode.Suggesting });
|
|
505
|
+
user = setUp({ props: props }).user;
|
|
506
|
+
inputs = react_2.screen.getAllByRole('combobox');
|
|
507
|
+
return [4 /*yield*/, user.click(inputs[0])];
|
|
508
|
+
case 1:
|
|
509
|
+
_a.sent();
|
|
510
|
+
expect(react_2.screen.queryByText('Create new Address')).not.toBeInTheDocument();
|
|
511
|
+
return [2 /*return*/];
|
|
512
|
+
}
|
|
624
513
|
});
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
514
|
+
}); });
|
|
515
|
+
it('should not hide hidden attributes', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
516
|
+
var hiddenAttributes, user, inputs;
|
|
517
|
+
return __generator(this, function (_a) {
|
|
518
|
+
switch (_a.label) {
|
|
519
|
+
case 0:
|
|
520
|
+
hiddenAttributes = { 'entities/uri$$123': ['configuration/relationTypes/HasAddress/attributes/Active'] };
|
|
521
|
+
user = setUp({ hiddenAttributes: hiddenAttributes }).user;
|
|
522
|
+
inputs = react_2.screen.getAllByRole('combobox');
|
|
523
|
+
return [4 /*yield*/, user.click(inputs[0])];
|
|
524
|
+
case 1:
|
|
525
|
+
_a.sent();
|
|
526
|
+
expect(react_2.screen.getByText('ActiveHiddenAttribute')).toBeInTheDocument();
|
|
527
|
+
return [2 /*return*/];
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
}); });
|
|
531
|
+
it('should add sendMasked option if connection entity has attribute with masked value', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
532
|
+
var props, user, inputs;
|
|
533
|
+
return __generator(this, function (_a) {
|
|
534
|
+
switch (_a.label) {
|
|
535
|
+
case 0:
|
|
536
|
+
props = __assign(__assign({}, defaultProps), { connection: {
|
|
537
|
+
relation: defaultRelation,
|
|
538
|
+
entity: {
|
|
539
|
+
uri: 'entities/uri$$123',
|
|
540
|
+
type: 'configuration/entityTypes/HCP',
|
|
541
|
+
object: {
|
|
542
|
+
uri: 'entities/04B1CqH',
|
|
543
|
+
type: 'configuration/entityTypes/Location',
|
|
544
|
+
attributes: {
|
|
545
|
+
Address: [
|
|
546
|
+
{
|
|
547
|
+
label: 'AcOEvPaVqTfzZCE Josogaf VA',
|
|
548
|
+
relationshipLabel: '',
|
|
549
|
+
value: {
|
|
550
|
+
AddressLine1: [
|
|
551
|
+
{
|
|
552
|
+
type: 'configuration/entityTypes/Location/attributes/AddressLine1',
|
|
553
|
+
ov: true,
|
|
554
|
+
value: 'AcOEvPaVqTfzZCE',
|
|
555
|
+
uri: 'entities/04B1CqH/attributes/Address/03R51aT/AddressLine1/1XFBcmPYm'
|
|
556
|
+
}
|
|
557
|
+
],
|
|
558
|
+
AddressLine2: [
|
|
559
|
+
{
|
|
560
|
+
type: 'configuration/entityTypes/Location/attributes/AddressLine2',
|
|
561
|
+
ov: true,
|
|
562
|
+
masked: true,
|
|
563
|
+
value: 'KBmiSMlqhElLHMH',
|
|
564
|
+
uri: 'entities/04B1CqH/attributes/Address/03R51aT/AddressLine2/1XFBcmTp2'
|
|
565
|
+
}
|
|
566
|
+
]
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
]
|
|
570
|
+
}
|
|
645
571
|
}
|
|
646
|
-
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
name: 'Role',
|
|
667
|
-
type: 'String',
|
|
668
|
-
hidden: false,
|
|
669
|
-
important: false,
|
|
670
|
-
system: false,
|
|
671
|
-
required: true,
|
|
672
|
-
attributeOrdering: {
|
|
673
|
-
orderType: 'ASC',
|
|
674
|
-
orderingStrategy: 'LUD'
|
|
675
|
-
},
|
|
676
|
-
uri: 'configuration/relationTypes/HCPtoHCA/attributes/Role'
|
|
677
|
-
},
|
|
678
|
-
attributeTypeUri: 'configuration/relationTypes/HCPtoHCA/attributes/Role',
|
|
679
|
-
message: 'Attribute is required',
|
|
680
|
-
parentUri: relationUri,
|
|
681
|
-
type: 'missed',
|
|
682
|
-
uri: '',
|
|
683
|
-
source: mdm_sdk_1.ErrorSource.local,
|
|
684
|
-
path: [
|
|
572
|
+
}
|
|
573
|
+
} });
|
|
574
|
+
user = setUp({ props: props }).user;
|
|
575
|
+
inputs = react_2.screen.getAllByRole('textbox');
|
|
576
|
+
return [4 /*yield*/, user.click(inputs[0])];
|
|
577
|
+
case 1:
|
|
578
|
+
_a.sent();
|
|
579
|
+
expect(mdm_sdk_1.typeAheadSearch).toHaveBeenCalledWith([defaultProps.metadata.entityTypes[1]], '', {
|
|
580
|
+
globalFilter: '',
|
|
581
|
+
max: 20,
|
|
582
|
+
searchOptions: '',
|
|
583
|
+
sendMasked: true
|
|
584
|
+
});
|
|
585
|
+
return [2 /*return*/];
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
}); });
|
|
589
|
+
describe('apply button', function () {
|
|
590
|
+
var createRelation = function (value) { return (__assign(__assign({}, defaultProps.connection.relation), { object: __assign(__assign({}, defaultProps.connection.relation.object), { attributes: {
|
|
591
|
+
Name: [
|
|
685
592
|
{
|
|
686
|
-
|
|
687
|
-
type: '
|
|
688
|
-
value:
|
|
689
|
-
valueType: relations_test_data_1.relationTypes[2],
|
|
690
|
-
viewId: 'relationView2'
|
|
593
|
+
uri: 'relations/uri$$Qgs4qfvmR3Daksyb1697627670006/attributes/Name/uri$$jIo2A6VSD',
|
|
594
|
+
type: 'configuration/relationTypes/HasAddress/attributes/Name',
|
|
595
|
+
value: value
|
|
691
596
|
}
|
|
692
597
|
]
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
var
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
draft: 'edited'
|
|
714
|
-
},
|
|
715
|
-
relation: {
|
|
716
|
-
relationUri: relationUri,
|
|
717
|
-
relationType: '123',
|
|
718
|
-
object: {
|
|
719
|
-
type: '123'
|
|
720
|
-
}
|
|
721
|
-
},
|
|
722
|
-
entity: {
|
|
723
|
-
entityUri: 'entities/uri$$1',
|
|
724
|
-
entityType: 'type',
|
|
725
|
-
entityLabel: '',
|
|
726
|
-
object: {
|
|
727
|
-
uri: 'entities/uri$$1',
|
|
728
|
-
type: 'type',
|
|
729
|
-
label: ''
|
|
730
|
-
}
|
|
731
|
-
}
|
|
598
|
+
} }) })); };
|
|
599
|
+
var createEntity = function (uri) { return ({
|
|
600
|
+
entityUri: uri,
|
|
601
|
+
entityType: 'configuration/entityTypes/Location',
|
|
602
|
+
entityLabel: 'location entity',
|
|
603
|
+
object: { uri: uri, type: 'configuration/entityTypes/Location', label: 'location entity' }
|
|
604
|
+
}); };
|
|
605
|
+
it('should be disables for new connections with added default values', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
606
|
+
var connection, props, applyButton;
|
|
607
|
+
return __generator(this, function (_a) {
|
|
608
|
+
switch (_a.label) {
|
|
609
|
+
case 0:
|
|
610
|
+
connection = { relation: createRelation('name value'), entity: {}, isNew: true };
|
|
611
|
+
props = __assign(__assign({}, defaultProps), { connection: connection });
|
|
612
|
+
setUp({ props: props });
|
|
613
|
+
return [4 /*yield*/, react_2.screen.findByText('Apply')];
|
|
614
|
+
case 1:
|
|
615
|
+
applyButton = _a.sent();
|
|
616
|
+
expect(applyButton).toBeDisabled();
|
|
617
|
+
return [2 /*return*/];
|
|
732
618
|
}
|
|
733
619
|
});
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
type: 'type',
|
|
752
|
-
label: expectedLabel
|
|
753
|
-
}
|
|
620
|
+
}); });
|
|
621
|
+
it('should call addRelation action on Apply button click for new connections', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
622
|
+
var entity, relation, connection, props, user;
|
|
623
|
+
return __generator(this, function (_a) {
|
|
624
|
+
switch (_a.label) {
|
|
625
|
+
case 0:
|
|
626
|
+
entity = createEntity('entities/0C32GxR');
|
|
627
|
+
relation = createRelation('new name value');
|
|
628
|
+
connection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity, isNew: true });
|
|
629
|
+
props = __assign(__assign({}, defaultProps), { connection: connection });
|
|
630
|
+
user = setUp({ props: props }).user;
|
|
631
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Apply'))];
|
|
632
|
+
case 1:
|
|
633
|
+
_a.sent();
|
|
634
|
+
expect(mdmActions.addRelation).toHaveBeenCalledWith(props.config.id, connection);
|
|
635
|
+
expect(mdmActions.closeRelationEditor).toHaveBeenCalledWith(props.config.id, relation.relationUri);
|
|
636
|
+
return [2 /*return*/];
|
|
754
637
|
}
|
|
755
|
-
};
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
638
|
+
});
|
|
639
|
+
}); });
|
|
640
|
+
it('should not call addRelation action on Apply button if connection has validation errors', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
641
|
+
var entity, relation, connection, props, user;
|
|
642
|
+
return __generator(this, function (_a) {
|
|
643
|
+
switch (_a.label) {
|
|
644
|
+
case 0:
|
|
645
|
+
entity = createEntity('entities/0C32GxR');
|
|
646
|
+
relation = createRelation('');
|
|
647
|
+
connection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity, isNew: true });
|
|
648
|
+
props = __assign(__assign({}, defaultProps), { connection: connection });
|
|
649
|
+
user = setUp({ props: props }).user;
|
|
650
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Apply'))];
|
|
651
|
+
case 1:
|
|
652
|
+
_a.sent();
|
|
653
|
+
expect(mdmActions.addRelation).not.toHaveBeenCalled();
|
|
654
|
+
expect(mdmActions.errorsSet).toHaveBeenCalledWith([
|
|
655
|
+
{
|
|
656
|
+
attributeType: props.metadata.relationTypes[0].attributes[1],
|
|
657
|
+
attributeTypeUri: 'configuration/relationTypes/HasAddress/attributes/Name',
|
|
658
|
+
message: 'Attribute is required',
|
|
659
|
+
parentUri: connection.relation.relationUri,
|
|
660
|
+
path: [
|
|
661
|
+
{
|
|
662
|
+
label: 'location entity, has address',
|
|
663
|
+
type: 'relationConnection',
|
|
664
|
+
value: connection,
|
|
665
|
+
valueType: props.metadata.relationTypes[0],
|
|
666
|
+
viewId: props.config.id
|
|
667
|
+
}
|
|
668
|
+
],
|
|
669
|
+
source: mdm_sdk_1.ErrorSource.local,
|
|
670
|
+
type: mdm_sdk_1.ErrorType.missed,
|
|
671
|
+
uri: ''
|
|
672
|
+
}
|
|
673
|
+
]);
|
|
674
|
+
expect(mdmActions.closeRelationEditor).not.toHaveBeenCalled();
|
|
675
|
+
return [2 /*return*/];
|
|
787
676
|
}
|
|
788
677
|
});
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
type: 'type',
|
|
807
|
-
label: ''
|
|
808
|
-
}
|
|
678
|
+
}); });
|
|
679
|
+
it('should call editRelation action on Apply button click for existing connections', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
680
|
+
var entity, relation, connection, props, user;
|
|
681
|
+
return __generator(this, function (_a) {
|
|
682
|
+
switch (_a.label) {
|
|
683
|
+
case 0:
|
|
684
|
+
entity = createEntity('entities/0C32GxR');
|
|
685
|
+
relation = createRelation('new name value');
|
|
686
|
+
connection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity });
|
|
687
|
+
props = __assign(__assign({}, defaultProps), { connection: connection });
|
|
688
|
+
user = setUp({ props: props }).user;
|
|
689
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Apply'))];
|
|
690
|
+
case 1:
|
|
691
|
+
_a.sent();
|
|
692
|
+
expect(mdmActions.editRelation).toHaveBeenCalledWith(props.config.id, connection);
|
|
693
|
+
expect(mdmActions.closeRelationEditor).toHaveBeenCalledWith(props.config.id, relation.relationUri);
|
|
694
|
+
return [2 /*return*/];
|
|
809
695
|
}
|
|
810
|
-
};
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
696
|
+
});
|
|
697
|
+
}); });
|
|
698
|
+
it('should not call editRelation action on Apply button click if connection has validation errors', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
699
|
+
var entity, relation, connection, props, user;
|
|
700
|
+
return __generator(this, function (_a) {
|
|
701
|
+
switch (_a.label) {
|
|
702
|
+
case 0:
|
|
703
|
+
entity = createEntity('entities/0C32GxR');
|
|
704
|
+
relation = createRelation('');
|
|
705
|
+
connection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity });
|
|
706
|
+
props = __assign(__assign({}, defaultProps), { connection: connection });
|
|
707
|
+
user = setUp({ props: props }).user;
|
|
708
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Apply'))];
|
|
709
|
+
case 1:
|
|
710
|
+
_a.sent();
|
|
711
|
+
expect(mdmActions.editRelation).not.toHaveBeenCalled();
|
|
712
|
+
expect(mdmActions.errorsSet).toHaveBeenCalledWith([
|
|
825
713
|
{
|
|
826
|
-
|
|
714
|
+
attributeType: props.metadata.relationTypes[0].attributes[1],
|
|
715
|
+
attributeTypeUri: 'configuration/relationTypes/HasAddress/attributes/Name',
|
|
716
|
+
message: 'Attribute is required',
|
|
717
|
+
parentUri: connection.relation.relationUri,
|
|
718
|
+
path: [
|
|
827
719
|
{
|
|
828
|
-
|
|
720
|
+
label: 'location entity, has address',
|
|
721
|
+
type: 'relationConnection',
|
|
722
|
+
value: connection,
|
|
723
|
+
valueType: props.metadata.relationTypes[0],
|
|
724
|
+
viewId: props.config.id
|
|
829
725
|
}
|
|
830
|
-
]
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
726
|
+
],
|
|
727
|
+
source: mdm_sdk_1.ErrorSource.local,
|
|
728
|
+
type: mdm_sdk_1.ErrorType.missed,
|
|
729
|
+
uri: ''
|
|
730
|
+
}
|
|
731
|
+
]);
|
|
732
|
+
expect(mdmActions.closeRelationEditor).not.toHaveBeenCalled();
|
|
733
|
+
return [2 /*return*/];
|
|
734
|
+
}
|
|
735
|
+
});
|
|
736
|
+
}); });
|
|
737
|
+
it('should evaluate and update connection entity label if modified entity is specified', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
738
|
+
var entityUri, entity, relation, connection, modifiedEntity, props, mdmValues, user;
|
|
739
|
+
var _a;
|
|
740
|
+
return __generator(this, function (_b) {
|
|
741
|
+
switch (_b.label) {
|
|
742
|
+
case 0:
|
|
743
|
+
entityUri = 'entities/uri$$kAp2KJM8';
|
|
744
|
+
entity = createEntity(entityUri);
|
|
745
|
+
relation = createRelation('new name value');
|
|
746
|
+
connection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity });
|
|
747
|
+
modifiedEntity = {
|
|
748
|
+
type: 'configuration/entityTypes/Location',
|
|
749
|
+
uri: entityUri,
|
|
750
|
+
attributes: {
|
|
751
|
+
FirstName: [
|
|
834
752
|
{
|
|
835
|
-
|
|
753
|
+
uri: 'entities/uri$$kAp2KJM8/attributes/FirstName/uri$$wsbN3s0X',
|
|
754
|
+
type: 'configuration/entityTypes/Location/attributes/FirstName',
|
|
755
|
+
value: 'first name value'
|
|
836
756
|
}
|
|
837
757
|
]
|
|
838
758
|
}
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
759
|
+
};
|
|
760
|
+
props = __assign(__assign({}, defaultProps), { connection: connection });
|
|
761
|
+
mdmValues = __assign(__assign({}, defaultMdmValues), { modifiedEntities: (_a = {}, _a[entityUri] = modifiedEntity, _a) });
|
|
762
|
+
user = setUp({ mdmValues: mdmValues, props: props }).user;
|
|
763
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Apply'))];
|
|
764
|
+
case 1:
|
|
765
|
+
_b.sent();
|
|
766
|
+
expect(mdmActions.editRelation).toHaveBeenCalledWith(props.config.id, {
|
|
767
|
+
entity: __assign(__assign({}, entity), { entityLabel: 'first name value', object: __assign(__assign({}, entity.object), { label: 'first name value' }) }),
|
|
768
|
+
relation: relation
|
|
769
|
+
});
|
|
770
|
+
expect(mdmActions.closeRelationEditor).toHaveBeenCalledWith(props.config.id, relation.relationUri);
|
|
771
|
+
return [2 /*return*/];
|
|
772
|
+
}
|
|
773
|
+
});
|
|
774
|
+
}); });
|
|
775
|
+
it('should clean up outdated temp modified entities', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
776
|
+
var entityUri, entity, relation, connection, modifiedEntities, props, mdmValues, _a, user, rerender, updatedModifiedEntities, updatedEntity, updatedConnection;
|
|
777
|
+
var _b;
|
|
778
|
+
return __generator(this, function (_c) {
|
|
779
|
+
switch (_c.label) {
|
|
780
|
+
case 0:
|
|
781
|
+
entityUri = 'entities/uri$$kAp2KJM8';
|
|
782
|
+
entity = createEntity(entityUri);
|
|
783
|
+
relation = createRelation('new name value');
|
|
784
|
+
connection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity });
|
|
785
|
+
modifiedEntities = (_b = {},
|
|
786
|
+
_b[entityUri] = {
|
|
787
|
+
type: 'configuration/entityTypes/Location',
|
|
788
|
+
uri: entityUri,
|
|
789
|
+
attributes: {
|
|
790
|
+
Address: [
|
|
791
|
+
{
|
|
792
|
+
refEntity: [{ objectURI: 'entities/uri$$kLnBs782' }],
|
|
793
|
+
refRelation: null,
|
|
794
|
+
uri: 'entities/uri$$kAp2KJM8/attributes/Address/uri$$nbsAsD',
|
|
795
|
+
value: {},
|
|
796
|
+
relationshipLabel: '',
|
|
797
|
+
startObjectCrosswalks: []
|
|
798
|
+
},
|
|
799
|
+
{
|
|
800
|
+
refEntity: [{ objectURI: 'entities/uri$$bAWp0mnS' }],
|
|
801
|
+
refRelation: null,
|
|
802
|
+
uri: 'entities/uri$$kAp2KJM8/attributes/Address/uri$$nSplKs321',
|
|
803
|
+
value: {},
|
|
804
|
+
relationshipLabel: '',
|
|
805
|
+
startObjectCrosswalks: []
|
|
806
|
+
}
|
|
807
|
+
]
|
|
808
|
+
}
|
|
809
|
+
},
|
|
810
|
+
_b['entities/uri$$kLnBs782'] = {
|
|
811
|
+
type: 'configuration/entityTypes/Location',
|
|
812
|
+
uri: 'entities/uri$$kLnBs782',
|
|
813
|
+
attributes: {
|
|
814
|
+
Address: [
|
|
815
|
+
{
|
|
816
|
+
refEntity: [
|
|
817
|
+
{
|
|
818
|
+
objectURI: 'entities/uri$$ks0PsMA'
|
|
819
|
+
}
|
|
820
|
+
],
|
|
821
|
+
refRelation: null,
|
|
822
|
+
uri: 'entities/uri$$kLnBs782/attributes/Address/uri$$o23NbsDA',
|
|
823
|
+
value: {},
|
|
824
|
+
relationshipLabel: '',
|
|
825
|
+
startObjectCrosswalks: []
|
|
826
|
+
}
|
|
827
|
+
]
|
|
828
|
+
}
|
|
829
|
+
},
|
|
830
|
+
_b['entities/uri$$bAWp0mnS'] = {
|
|
831
|
+
uri: 'entities/uri$$bAWp0mnS',
|
|
832
|
+
type: 'configuration/entityTypes/HCP'
|
|
833
|
+
},
|
|
834
|
+
_b['entities/uri$$ks0PsMA'] = {
|
|
835
|
+
uri: 'entities/uri$$ks0PsMA',
|
|
836
|
+
type: 'configuration/entityTypes/HCP'
|
|
837
|
+
},
|
|
838
|
+
_b['entities/uri$$MsS01sDA'] = {
|
|
839
|
+
uri: 'entities/uri$$MsS01sDA',
|
|
840
|
+
type: 'configuration/entityTypes/HCP'
|
|
841
|
+
},
|
|
842
|
+
_b);
|
|
843
|
+
props = __assign(__assign({}, defaultProps), { connection: connection });
|
|
844
|
+
mdmValues = __assign(__assign({}, defaultMdmValues), { modifiedEntities: modifiedEntities });
|
|
845
|
+
_a = setUp({ mdmValues: mdmValues, props: props }), user = _a.user, rerender = _a.rerender;
|
|
846
|
+
updatedModifiedEntities = __assign(__assign({}, modifiedEntities), { 'entities/uri$$jSdsAA32': {
|
|
847
|
+
uri: 'entities/uri$$jSdsAA32',
|
|
848
|
+
type: 'configuration/entityTypes/Location',
|
|
849
|
+
attributes: {}
|
|
850
|
+
} });
|
|
851
|
+
updatedEntity = createEntity('entities/uri$$jSdsAA32');
|
|
852
|
+
updatedConnection = __assign(__assign({}, connection), { entity: updatedEntity });
|
|
853
|
+
rerender({
|
|
854
|
+
mdmValues: __assign(__assign({}, mdmValues), { modifiedEntities: updatedModifiedEntities }),
|
|
855
|
+
props: __assign(__assign({}, props), { connection: updatedConnection })
|
|
856
|
+
});
|
|
857
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Apply'))];
|
|
858
|
+
case 1:
|
|
859
|
+
_c.sent();
|
|
860
|
+
expect(mdmActions.editRelation).toHaveBeenCalledWith(props.config.id, __assign(__assign({}, connection), { entity: __assign(__assign({}, updatedEntity), { entityLabel: '', object: __assign(__assign({}, updatedEntity.object), { label: '' }) }) }));
|
|
861
|
+
expect(mdmActions.closeRelationEditor).toHaveBeenCalledWith(props.config.id, relation.relationUri);
|
|
862
|
+
expect(mdmActions.entityDeleted).toHaveBeenCalledWith('entities/uri$$kLnBs782');
|
|
863
|
+
expect(mdmActions.entityDeleted).toHaveBeenCalledWith('entities/uri$$bAWp0mnS');
|
|
864
|
+
expect(mdmActions.entityDeleted).toHaveBeenCalledWith('entities/uri$$ks0PsMA');
|
|
865
|
+
expect(mdmActions.entityDeleted).not.toHaveBeenCalledWith('entities/uri$$MsS01sDA');
|
|
866
|
+
return [2 /*return*/];
|
|
867
|
+
}
|
|
868
|
+
});
|
|
869
|
+
}); });
|
|
870
|
+
it('should disable apply button if modified entity and connection was not changed', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
871
|
+
var entityUri, entity, relation, modifiedEntity, connection, mdmConnection, props, mdmValues, applyButton;
|
|
872
|
+
var _a, _b;
|
|
873
|
+
return __generator(this, function (_c) {
|
|
874
|
+
switch (_c.label) {
|
|
875
|
+
case 0:
|
|
876
|
+
entityUri = 'entities/uri$$kAp2KJM8';
|
|
877
|
+
entity = createEntity(entityUri);
|
|
878
|
+
relation = createRelation('name value');
|
|
879
|
+
modifiedEntity = {
|
|
880
|
+
type: 'configuration/entityTypes/Location',
|
|
881
|
+
uri: entityUri,
|
|
882
|
+
attributes: {
|
|
883
|
+
FirstName: [
|
|
848
884
|
{
|
|
849
|
-
|
|
885
|
+
uri: 'entities/uri$$kAp2KJM8/attributes/FirstName/uri$$wsbN3s0X',
|
|
886
|
+
type: 'configuration/entityTypes/Location/attributes/FirstName',
|
|
887
|
+
value: 'first name value'
|
|
850
888
|
}
|
|
851
889
|
]
|
|
852
890
|
}
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
891
|
+
};
|
|
892
|
+
connection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity, isNew: true });
|
|
893
|
+
mdmConnection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity, initial: { modifiedEntity: modifiedEntity, connection: connection } });
|
|
894
|
+
props = __assign(__assign({}, defaultProps), { connection: connection });
|
|
895
|
+
mdmValues = __assign(__assign({}, defaultMdmValues), { relations: (_a = {}, _a[props.config.id] = { relationsToEdit: [mdmConnection] }, _a), modifiedEntities: (_b = {}, _b[entityUri] = modifiedEntity, _b) });
|
|
896
|
+
setUp({ props: props, mdmValues: mdmValues });
|
|
897
|
+
return [4 /*yield*/, react_2.screen.findByText('Apply')];
|
|
898
|
+
case 1:
|
|
899
|
+
applyButton = _c.sent();
|
|
900
|
+
expect(applyButton).toBeDisabled();
|
|
901
|
+
return [2 /*return*/];
|
|
864
902
|
}
|
|
865
|
-
};
|
|
866
|
-
var props = __assign(__assign({}, defaultProps), { connection: connection, config: relations_test_data_1.config, metadata: { relationTypes: relations_test_data_1.relationTypes, entityTypes: [{ uri: '456', attributes: [] }] } });
|
|
867
|
-
var mdmValues = __assign(__assign({}, defaultMdmValues), { initialConnection: connection, modifiedEntity: initialAllModifiedEntities['entities/uri$$relationEntity'], initialModifiedEntity: initialAllModifiedEntities['entities/uri$$relationEntity'], modifiedEntities: initialAllModifiedEntities });
|
|
868
|
-
var component = setUp({ props: props, mdmValues: mdmValues });
|
|
869
|
-
var applyButton = findApplyButton(component);
|
|
870
|
-
expect(applyButton.prop('disabled')).toBe(true);
|
|
871
|
-
MdmModuleContext_1.useMdmModifiedEntity.mockReturnValue({
|
|
872
|
-
uri: 'entities/uri$$newRelationEntity',
|
|
873
|
-
attributes: {}
|
|
874
903
|
});
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
904
|
+
}); });
|
|
905
|
+
it('should enable apply button if modified entity was changed', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
906
|
+
var createModifiedEntity, entityUri, entity, relation, connection, mdmConnection, props, mdmValues, applyButton;
|
|
907
|
+
var _a, _b;
|
|
908
|
+
return __generator(this, function (_c) {
|
|
909
|
+
switch (_c.label) {
|
|
910
|
+
case 0:
|
|
911
|
+
createModifiedEntity = function (value) { return ({
|
|
912
|
+
type: 'configuration/entityTypes/Location',
|
|
913
|
+
uri: entityUri,
|
|
914
|
+
attributes: {
|
|
915
|
+
FirstName: [
|
|
916
|
+
{
|
|
917
|
+
uri: 'entities/uri$$kAp2KJM8/attributes/FirstName/uri$$wsbN3s0X',
|
|
918
|
+
type: 'configuration/entityTypes/Location/attributes/FirstName',
|
|
919
|
+
value: value
|
|
920
|
+
}
|
|
921
|
+
]
|
|
922
|
+
}
|
|
923
|
+
}); };
|
|
924
|
+
entityUri = 'entities/uri$$kAp2KJM8';
|
|
925
|
+
entity = createEntity(entityUri);
|
|
926
|
+
relation = createRelation('name value');
|
|
927
|
+
connection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity, isNew: true });
|
|
928
|
+
mdmConnection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity, initial: { modifiedEntity: createModifiedEntity('initial first name'), connection: connection } });
|
|
929
|
+
props = __assign(__assign({}, defaultProps), { connection: connection });
|
|
930
|
+
mdmValues = __assign(__assign({}, defaultMdmValues), { relations: (_a = {}, _a[props.config.id] = { relationsToEdit: [mdmConnection] }, _a), modifiedEntities: (_b = {}, _b[entityUri] = createModifiedEntity('changed first name'), _b) });
|
|
931
|
+
setUp({ props: props, mdmValues: mdmValues });
|
|
932
|
+
return [4 /*yield*/, react_2.screen.findByText('Apply')];
|
|
933
|
+
case 1:
|
|
934
|
+
applyButton = _c.sent();
|
|
935
|
+
expect(applyButton).not.toBeDisabled();
|
|
936
|
+
return [2 /*return*/];
|
|
890
937
|
}
|
|
891
938
|
});
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
applyButton
|
|
895
|
-
var
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
expect(mdmActions.entityDeleted).toHaveBeenCalledWith('entities/uri$$addressEntity1');
|
|
908
|
-
expect(mdmActions.entityDeleted).toHaveBeenCalledWith('entities/uri$$addressEntity2');
|
|
909
|
-
expect(mdmActions.entityDeleted).toHaveBeenCalledWith('entities/uri$$locationEntity');
|
|
910
|
-
expect(mdmActions.entityDeleted).not.toHaveBeenCalledWith('entities/uri$$notRelatedEntity');
|
|
911
|
-
});
|
|
912
|
-
it('should call validateConnection with correct params', function () {
|
|
913
|
-
mdm_sdk_1.getEntityType.mockReturnValue({});
|
|
914
|
-
var connection = {
|
|
915
|
-
relation: { relationUri: relationUri },
|
|
916
|
-
entity: { entityUri: 'entities/uri$$relationEntity' }
|
|
917
|
-
};
|
|
918
|
-
var initialAllModifiedEntities = {};
|
|
919
|
-
var metadata = { relationTypes: relations_test_data_1.relationTypes, entityTypes: [{ uri: '456', attributes: [] }] };
|
|
920
|
-
var props = __assign(__assign({}, defaultProps), { connection: connection, config: relations_test_data_1.config, metadata: metadata });
|
|
921
|
-
var mdmValues = __assign(__assign({}, defaultMdmValues), { initialConnection: connection, initialModifiedEntity: undefined, modifiedEntity: initialAllModifiedEntities['entities/uri$$relationEntity'], modifiedEntities: initialAllModifiedEntities });
|
|
922
|
-
var component = setUp({ props: props, mdmValues: mdmValues });
|
|
923
|
-
var applyButton = findApplyButton(component);
|
|
924
|
-
expect(applyButton.prop('disabled')).toBe(true);
|
|
925
|
-
var updatedAllModifiedEntities = __assign(__assign({}, initialAllModifiedEntities), { 'entities/uri$$newRelationEntity': {
|
|
926
|
-
uri: 'entities/uri$$newRelationEntity',
|
|
927
|
-
type: '456'
|
|
928
|
-
} });
|
|
929
|
-
var updatedConnecton = {
|
|
930
|
-
relation: {
|
|
931
|
-
relationUri: relationUri,
|
|
932
|
-
relationType: '123',
|
|
933
|
-
object: {
|
|
934
|
-
type: '123'
|
|
935
|
-
}
|
|
936
|
-
},
|
|
937
|
-
entity: { entityUri: 'entities/uri$$newRelationEntity' }
|
|
938
|
-
};
|
|
939
|
-
MdmModuleContext_1.useMdmModifiedEntities.mockReturnValue(updatedAllModifiedEntities);
|
|
940
|
-
component.setProps({ connection: updatedConnecton });
|
|
941
|
-
applyButton = findApplyButton(component);
|
|
942
|
-
expect(applyButton.prop('disabled')).toBe(false);
|
|
943
|
-
applyButton.find('button').simulate('click');
|
|
944
|
-
expect(mdm_sdk_1.validateConnection).toHaveBeenCalledWith(metadata, updatedAllModifiedEntities, updatedConnecton);
|
|
945
|
-
});
|
|
946
|
-
it('should enable Apply button if modified entity was changed', function () {
|
|
947
|
-
var connection = { relation: { relationUri: relationUri }, entity: { entityUri: 'entities/uri$$123' } };
|
|
948
|
-
var props = __assign(__assign({}, defaultProps), { config: relations_test_data_1.config, metadata: { relationTypes: relations_test_data_1.relationTypes, entityTypes: [] }, connection: connection });
|
|
949
|
-
var mdmValues = __assign(__assign({}, defaultMdmValues), { initialConnection: connection });
|
|
950
|
-
var component = setUp({ props: props, mdmValues: mdmValues });
|
|
951
|
-
var applyButton = findApplyButton(component);
|
|
952
|
-
expect(applyButton.prop('disabled')).toBe(true);
|
|
953
|
-
MdmModuleContext_1.useMdmModifiedEntity.mockReturnValue({
|
|
954
|
-
uri: 'entities/$$uri',
|
|
955
|
-
attributes: []
|
|
956
|
-
});
|
|
957
|
-
component.setProps({ test: 1 });
|
|
958
|
-
applyButton = findApplyButton(component);
|
|
959
|
-
expect(applyButton.prop('disabled')).toBe(false);
|
|
960
|
-
});
|
|
961
|
-
it('should enable Apply button if some referenced entity related to modified entity was changed', function () {
|
|
962
|
-
var connection = {
|
|
963
|
-
relation: { relationUri: relationUri },
|
|
964
|
-
entity: { entityUri: 'entities/uri$$relationEntity' }
|
|
965
|
-
};
|
|
966
|
-
var initialAllModifiedEntities = {
|
|
967
|
-
'entities/uri$$relationEntity': {
|
|
968
|
-
uri: 'entities/uri$$relationEntity',
|
|
969
|
-
attributes: {
|
|
970
|
-
Address: [
|
|
971
|
-
{
|
|
972
|
-
refEntity: [
|
|
939
|
+
}); });
|
|
940
|
+
it('should enable apply button if connection was changed', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
941
|
+
var entityUri, entity, relation, modifiedEntity, connection, mdmConnection, props, mdmValues, applyButton;
|
|
942
|
+
var _a, _b;
|
|
943
|
+
return __generator(this, function (_c) {
|
|
944
|
+
switch (_c.label) {
|
|
945
|
+
case 0:
|
|
946
|
+
entityUri = 'entities/uri$$kAp2KJM8';
|
|
947
|
+
entity = createEntity(entityUri);
|
|
948
|
+
relation = createRelation('name value');
|
|
949
|
+
modifiedEntity = {
|
|
950
|
+
type: 'configuration/entityTypes/Location',
|
|
951
|
+
uri: entityUri,
|
|
952
|
+
attributes: {
|
|
953
|
+
FirstName: [
|
|
973
954
|
{
|
|
974
|
-
|
|
955
|
+
uri: 'entities/uri$$kAp2KJM8/attributes/FirstName/uri$$wsbN3s0X',
|
|
956
|
+
type: 'configuration/entityTypes/Location/attributes/FirstName',
|
|
957
|
+
value: 'first name value'
|
|
975
958
|
}
|
|
976
959
|
]
|
|
977
960
|
}
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
961
|
+
};
|
|
962
|
+
connection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity, isNew: true });
|
|
963
|
+
mdmConnection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity, initial: { modifiedEntity: modifiedEntity, connection: __assign(__assign({}, connection), { relation: createRelation('changed name value') }) } });
|
|
964
|
+
props = __assign(__assign({}, defaultProps), { connection: connection });
|
|
965
|
+
mdmValues = __assign(__assign({}, defaultMdmValues), { relations: (_a = {}, _a[props.config.id] = { relationsToEdit: [mdmConnection] }, _a), modifiedEntities: (_b = {}, _b[entityUri] = modifiedEntity, _b) });
|
|
966
|
+
setUp({ props: props, mdmValues: mdmValues });
|
|
967
|
+
return [4 /*yield*/, react_2.screen.findByText('Apply')];
|
|
968
|
+
case 1:
|
|
969
|
+
applyButton = _c.sent();
|
|
970
|
+
expect(applyButton).not.toBeDisabled();
|
|
971
|
+
return [2 /*return*/];
|
|
972
|
+
}
|
|
973
|
+
});
|
|
974
|
+
}); });
|
|
975
|
+
it('should enable apply button if some referenced entity related to modified entity was changed', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
976
|
+
var entityUri, entity, relation, modifiedEntity, modifiedEntities, connection, mdmConnection, props, mdmValues, rerender, updatedModifiedEntities, applyButton;
|
|
977
|
+
var _a, _b;
|
|
978
|
+
return __generator(this, function (_c) {
|
|
979
|
+
switch (_c.label) {
|
|
980
|
+
case 0:
|
|
981
|
+
entityUri = 'entities/uri$$kAp2KJM8';
|
|
982
|
+
entity = createEntity(entityUri);
|
|
983
|
+
relation = createRelation('name value');
|
|
984
|
+
modifiedEntity = {
|
|
985
|
+
type: 'configuration/entityTypes/Location',
|
|
986
|
+
uri: entityUri,
|
|
987
|
+
attributes: {
|
|
988
|
+
Address: [
|
|
987
989
|
{
|
|
988
|
-
objectURI: 'entities/uri$$
|
|
990
|
+
refEntity: [{ objectURI: 'entities/uri$$kLnBs782' }],
|
|
991
|
+
refRelation: null,
|
|
992
|
+
uri: 'entities/uri$$kAp2KJM8/attributes/Address/uri$$nbsAsD',
|
|
993
|
+
value: {},
|
|
994
|
+
relationshipLabel: '',
|
|
995
|
+
startObjectCrosswalks: []
|
|
989
996
|
}
|
|
990
997
|
]
|
|
991
998
|
}
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
999
|
+
};
|
|
1000
|
+
modifiedEntities = (_a = {},
|
|
1001
|
+
_a[entityUri] = modifiedEntity,
|
|
1002
|
+
_a['entities/uri$$kLnBs782'] = {
|
|
1003
|
+
uri: 'entities/uri$$MsS01sDA',
|
|
1004
|
+
type: 'configuration/entityTypes/Location',
|
|
1005
|
+
attributes: {
|
|
1006
|
+
FirstName: [
|
|
1007
|
+
{
|
|
1008
|
+
uri: 'entities/uri$$MsS01sDA/attributes/FirstName/uri$$jsNs01HO',
|
|
1009
|
+
type: 'configuration/entityTypes/Location/attributes/FirstName',
|
|
1010
|
+
value: 'initial first name value'
|
|
1011
|
+
}
|
|
1012
|
+
]
|
|
1013
|
+
}
|
|
1014
|
+
},
|
|
1015
|
+
_a);
|
|
1016
|
+
connection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity, isNew: true });
|
|
1017
|
+
mdmConnection = __assign(__assign({}, defaultProps.connection), { relation: relation, entity: entity, initial: { modifiedEntity: modifiedEntity, connection: connection } });
|
|
1018
|
+
props = __assign(__assign({}, defaultProps), { connection: connection });
|
|
1019
|
+
mdmValues = __assign(__assign({}, defaultMdmValues), { relations: (_b = {}, _b[props.config.id] = { relationsToEdit: [mdmConnection] }, _b), modifiedEntities: modifiedEntities });
|
|
1020
|
+
rerender = setUp({ props: props, mdmValues: mdmValues }).rerender;
|
|
1021
|
+
updatedModifiedEntities = __assign(__assign({}, modifiedEntities), { 'entities/uri$$kLnBs782': {
|
|
1022
|
+
uri: 'entities/uri$$MsS01sDA',
|
|
1023
|
+
type: 'configuration/entityTypes/Location',
|
|
1024
|
+
attributes: {
|
|
1025
|
+
FirstName: [
|
|
1026
|
+
{
|
|
1027
|
+
uri: 'entities/uri$$MsS01sDA/attributes/FirstName/uri$$jsNs01HO',
|
|
1028
|
+
type: 'configuration/entityTypes/Location/attributes/FirstName',
|
|
1029
|
+
value: 'changed first name value'
|
|
1030
|
+
}
|
|
1031
|
+
]
|
|
1032
|
+
}
|
|
1033
|
+
} });
|
|
1034
|
+
rerender({ mdmValues: __assign(__assign({}, mdmValues), { modifiedEntities: updatedModifiedEntities }) });
|
|
1035
|
+
return [4 /*yield*/, react_2.screen.findByText('Apply')];
|
|
1036
|
+
case 1:
|
|
1037
|
+
applyButton = _c.sent();
|
|
1038
|
+
expect(applyButton).not.toBeDisabled();
|
|
1039
|
+
return [2 /*return*/];
|
|
997
1040
|
}
|
|
998
|
-
};
|
|
999
|
-
|
|
1000
|
-
var mdmValues = __assign(__assign({}, defaultMdmValues), { initialConnection: connection, modifiedEntity: initialAllModifiedEntities['entities/uri$$relationEntity'], initialModifiedEntity: initialAllModifiedEntities['entities/uri$$relationEntity'], modifiedEntities: initialAllModifiedEntities });
|
|
1001
|
-
var component = setUp({ props: props, mdmValues: mdmValues });
|
|
1002
|
-
var applyButton = findApplyButton(component);
|
|
1003
|
-
expect(applyButton.prop('disabled')).toBe(true);
|
|
1004
|
-
// change deep referenced entity (modifiedEntity is not changed)
|
|
1005
|
-
MdmModuleContext_1.useMdmModifiedEntities.mockReturnValue(__assign(__assign({}, initialAllModifiedEntities), { 'entities/uri$$locationEntity': {
|
|
1006
|
-
uri: 'entities/uri$$locationEntity',
|
|
1007
|
-
attributes: {}
|
|
1008
|
-
} }));
|
|
1009
|
-
component.setProps({ test: 1 });
|
|
1010
|
-
applyButton = findApplyButton(component);
|
|
1011
|
-
expect(applyButton.prop('disabled')).toBe(false);
|
|
1012
|
-
});
|
|
1041
|
+
});
|
|
1042
|
+
}); });
|
|
1013
1043
|
});
|
|
1014
|
-
describe('
|
|
1015
|
-
it('should call closeRelationEditor action and remove related errors', function () {
|
|
1016
|
-
var
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
{
|
|
1064
|
-
parentUri: connection.relation.relationUri,
|
|
1065
|
-
uri: '',
|
|
1066
|
-
attributeTypeUri: 'configuration/relationTypes/HasAddress/attributes/BusinessCode',
|
|
1067
|
-
message: 'Entity is required',
|
|
1068
|
-
type: 'missed'
|
|
1044
|
+
describe('cancel button', function () {
|
|
1045
|
+
it('should call closeRelationEditor action and remove related errors', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1046
|
+
var profileErrors, mdmValues, user;
|
|
1047
|
+
return __generator(this, function (_a) {
|
|
1048
|
+
switch (_a.label) {
|
|
1049
|
+
case 0:
|
|
1050
|
+
profileErrors = [
|
|
1051
|
+
{
|
|
1052
|
+
parentUri: 'relations/11',
|
|
1053
|
+
uri: '',
|
|
1054
|
+
attributeTypeUri: defaultRelation.relationType,
|
|
1055
|
+
message: 'Entity is required',
|
|
1056
|
+
deactivated: true,
|
|
1057
|
+
type: mdm_sdk_1.ErrorType.missedRefEntity
|
|
1058
|
+
},
|
|
1059
|
+
{
|
|
1060
|
+
parentUri: defaultRelation.relationUri,
|
|
1061
|
+
uri: '',
|
|
1062
|
+
attributeTypeUri: defaultRelation.relationType,
|
|
1063
|
+
message: 'Entity is required - deactivated',
|
|
1064
|
+
deactivated: true,
|
|
1065
|
+
type: mdm_sdk_1.ErrorType.missedRefEntity
|
|
1066
|
+
},
|
|
1067
|
+
{
|
|
1068
|
+
parentUri: defaultRelation.relationUri,
|
|
1069
|
+
uri: '',
|
|
1070
|
+
attributeTypeUri: defaultRelation.relationType,
|
|
1071
|
+
message: 'Entity is required',
|
|
1072
|
+
type: mdm_sdk_1.ErrorType.missedRefEntity
|
|
1073
|
+
}
|
|
1074
|
+
];
|
|
1075
|
+
mdmValues = __assign(__assign({}, defaultMdmValues), { profileErrors: profileErrors });
|
|
1076
|
+
user = setUp({ mdmValues: mdmValues }).user;
|
|
1077
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Cancel'))];
|
|
1078
|
+
case 1:
|
|
1079
|
+
_a.sent();
|
|
1080
|
+
expect(mdmActions.errorsSet).toHaveBeenCalledWith([
|
|
1081
|
+
{
|
|
1082
|
+
attributeTypeUri: defaultRelation.relationType,
|
|
1083
|
+
deactivated: true,
|
|
1084
|
+
message: 'Entity is required',
|
|
1085
|
+
parentUri: 'relations/11',
|
|
1086
|
+
type: mdm_sdk_1.ErrorType.missedRefEntity,
|
|
1087
|
+
uri: ''
|
|
1088
|
+
}
|
|
1089
|
+
]);
|
|
1090
|
+
expect(mdmActions.closeRelationEditor).toHaveBeenCalledWith(defaultProps.config.id, defaultProps.connection.relation.relationUri);
|
|
1091
|
+
expect(mdmAction).toHaveBeenCalledTimes(2);
|
|
1092
|
+
return [2 /*return*/];
|
|
1069
1093
|
}
|
|
1070
|
-
];
|
|
1071
|
-
var mdmValues = __assign(__assign({}, defaultMdmValues), { profileErrors: profileErrors });
|
|
1072
|
-
var component = setUp({ props: props, mdmValues: mdmValues });
|
|
1073
|
-
MdmModuleContext_1.useMdmModifiedEntity.mockReturnValue({
|
|
1074
|
-
uri: 'entities/uri$$123',
|
|
1075
|
-
attributes: []
|
|
1076
1094
|
});
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1095
|
+
}); });
|
|
1096
|
+
it('should delete modified entity if there was no entity initially but it was set after', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1097
|
+
var entityUri, connection, modifiedEntity, props, mdmValues, user;
|
|
1098
|
+
var _a, _b;
|
|
1099
|
+
return __generator(this, function (_c) {
|
|
1100
|
+
switch (_c.label) {
|
|
1101
|
+
case 0:
|
|
1102
|
+
entityUri = 'entities/uri$$kAp2KJM8';
|
|
1103
|
+
connection = __assign(__assign({}, defaultProps.connection), { entity: {
|
|
1104
|
+
entityUri: entityUri,
|
|
1105
|
+
entityType: 'configuration/entityTypes/Location',
|
|
1106
|
+
entityLabel: 'location entity',
|
|
1107
|
+
object: { uri: entityUri, type: 'configuration/entityTypes/Location', label: 'location entity' }
|
|
1108
|
+
} });
|
|
1109
|
+
modifiedEntity = { type: 'configuration/entityTypes/Location', uri: entityUri, attributes: {} };
|
|
1110
|
+
props = __assign(__assign({}, defaultProps), { connection: connection });
|
|
1111
|
+
mdmValues = __assign(__assign({}, defaultMdmValues), { relations: (_a = {},
|
|
1112
|
+
_a[props.config.id] = {
|
|
1113
|
+
relationsToEdit: [__assign(__assign({}, defaultProps.connection), { initial: { connection: connection } })]
|
|
1114
|
+
},
|
|
1115
|
+
_a), modifiedEntities: (_b = {},
|
|
1116
|
+
_b[entityUri] = modifiedEntity,
|
|
1117
|
+
_b) });
|
|
1118
|
+
user = setUp({ props: props, mdmValues: mdmValues }).user;
|
|
1119
|
+
mdmAction.mockClear();
|
|
1120
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Cancel'))];
|
|
1121
|
+
case 1:
|
|
1122
|
+
_c.sent();
|
|
1123
|
+
expect(mdmActions.entityDeleted).toHaveBeenCalledWith(entityUri);
|
|
1124
|
+
expect(mdmActions.errorsSet).toHaveBeenCalledWith([]);
|
|
1125
|
+
expect(mdmActions.closeRelationEditor).toHaveBeenCalledWith(props.config.id, connection.relation.relationUri);
|
|
1126
|
+
expect(mdmAction).toHaveBeenCalledTimes(3);
|
|
1127
|
+
return [2 /*return*/];
|
|
1106
1128
|
}
|
|
1107
1129
|
});
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
type: 'missed'
|
|
1129
|
-
}
|
|
1130
|
-
];
|
|
1131
|
-
var mdmValues = __assign(__assign({}, defaultMdmValues), { initialModifiedEntity: initialModifiedEntity, modifiedEntity: initialModifiedEntity, profileErrors: profileErrors });
|
|
1132
|
-
var component = setUp({ props: props, mdmValues: mdmValues });
|
|
1133
|
-
MdmModuleContext_1.useMdmModifiedEntity.mockReturnValue({
|
|
1134
|
-
uri: 'entities/uri$$newone',
|
|
1135
|
-
attributes: {
|
|
1136
|
-
Name: [{ value: '123', uri: 'uri' }]
|
|
1130
|
+
}); });
|
|
1131
|
+
it('should restore modified entity to initial state if there was initial entity and it was changed/cleared', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1132
|
+
var entityUri, modifiedEntity, relationToEdit, mdmValues, user;
|
|
1133
|
+
var _a;
|
|
1134
|
+
return __generator(this, function (_b) {
|
|
1135
|
+
switch (_b.label) {
|
|
1136
|
+
case 0:
|
|
1137
|
+
entityUri = 'entities/uri$$kAp2KJM8';
|
|
1138
|
+
modifiedEntity = { type: 'configuration/entityTypes/Location', uri: entityUri, attributes: {} };
|
|
1139
|
+
relationToEdit = __assign(__assign({}, defaultProps.connection), { initial: { connection: defaultProps.connection, modifiedEntity: modifiedEntity } });
|
|
1140
|
+
mdmValues = __assign(__assign({}, defaultMdmValues), { relations: (_a = {}, _a[defaultProps.config.id] = { relationsToEdit: [relationToEdit] }, _a), modifiedEntities: {} });
|
|
1141
|
+
user = setUp({ mdmValues: mdmValues }).user;
|
|
1142
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Cancel'))];
|
|
1143
|
+
case 1:
|
|
1144
|
+
_b.sent();
|
|
1145
|
+
expect(mdmActions.entityCreated).toHaveBeenCalledWith(modifiedEntity);
|
|
1146
|
+
expect(mdmActions.errorsSet).toHaveBeenCalledWith([]);
|
|
1147
|
+
expect(mdmActions.closeRelationEditor).toHaveBeenCalledWith(defaultProps.config.id, defaultProps.connection.relation.relationUri);
|
|
1148
|
+
expect(mdmAction).toHaveBeenCalledTimes(3);
|
|
1149
|
+
return [2 /*return*/];
|
|
1137
1150
|
}
|
|
1138
1151
|
});
|
|
1139
|
-
|
|
1140
|
-
|
|
1152
|
+
}); });
|
|
1153
|
+
it('should restore initial modified entity if it was changed to another one (and delete new one)', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1154
|
+
var entityUri, modifiedEntity, connection, relationToEdit, mdmValues, props, user;
|
|
1155
|
+
var _a;
|
|
1156
|
+
return __generator(this, function (_b) {
|
|
1157
|
+
switch (_b.label) {
|
|
1158
|
+
case 0:
|
|
1159
|
+
entityUri = 'entities/uri$$kAp2KJM8';
|
|
1160
|
+
modifiedEntity = { type: 'configuration/entityTypes/Location', uri: entityUri, attributes: {} };
|
|
1161
|
+
connection = __assign(__assign({}, defaultProps.connection), { entity: { entityUri: 'entities/uri$$7BhsS31L' } });
|
|
1162
|
+
relationToEdit = __assign(__assign({}, connection), { initial: { connection: defaultProps.connection, modifiedEntity: modifiedEntity } });
|
|
1163
|
+
mdmValues = __assign(__assign({}, defaultMdmValues), { relations: (_a = {}, _a[defaultProps.config.id] = { relationsToEdit: [relationToEdit] }, _a), modifiedEntities: { 'entities/uri$$7BhsS31L': __assign(__assign({}, modifiedEntity), { uri: 'entities/uri$$7BhsS31L' }) } });
|
|
1164
|
+
props = __assign(__assign({}, defaultProps), { connection: connection });
|
|
1165
|
+
user = setUp({ mdmValues: mdmValues, props: props }).user;
|
|
1166
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Cancel'))];
|
|
1167
|
+
case 1:
|
|
1168
|
+
_b.sent();
|
|
1169
|
+
expect(mdmActions.entityCreated).toHaveBeenCalledWith(modifiedEntity);
|
|
1170
|
+
expect(mdmActions.entityDeleted).toHaveBeenCalledWith('entities/uri$$7BhsS31L');
|
|
1171
|
+
expect(mdmActions.errorsSet).toHaveBeenCalledWith([]);
|
|
1172
|
+
expect(mdmActions.closeRelationEditor).toHaveBeenCalledWith(props.config.id, connection.relation.relationUri);
|
|
1173
|
+
expect(mdmAction).toHaveBeenCalledTimes(4);
|
|
1174
|
+
return [2 /*return*/];
|
|
1175
|
+
}
|
|
1141
1176
|
});
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1177
|
+
}); });
|
|
1178
|
+
it('should not call additional actions if modifiedEntity prop was not changed', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1179
|
+
var entityUri, modifiedEntity, connection, relationToEdit, mdmValues, props, user;
|
|
1180
|
+
var _a, _b;
|
|
1181
|
+
return __generator(this, function (_c) {
|
|
1182
|
+
switch (_c.label) {
|
|
1183
|
+
case 0:
|
|
1184
|
+
entityUri = 'entities/uri$$kAp2KJM8';
|
|
1185
|
+
modifiedEntity = { type: 'configuration/entityTypes/Location', uri: entityUri, attributes: {} };
|
|
1186
|
+
connection = __assign(__assign({}, defaultProps.connection), { entity: { entityUri: entityUri } });
|
|
1187
|
+
relationToEdit = __assign(__assign({}, connection), { initial: { connection: defaultProps.connection, modifiedEntity: modifiedEntity } });
|
|
1188
|
+
mdmValues = __assign(__assign({}, defaultMdmValues), { relations: (_a = {}, _a[defaultProps.config.id] = { relationsToEdit: [relationToEdit] }, _a), modifiedEntities: (_b = {}, _b[entityUri] = modifiedEntity, _b) });
|
|
1189
|
+
props = __assign(__assign({}, defaultProps), { connection: connection });
|
|
1190
|
+
user = setUp({ mdmValues: mdmValues, props: props }).user;
|
|
1191
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Cancel'))];
|
|
1192
|
+
case 1:
|
|
1193
|
+
_c.sent();
|
|
1194
|
+
expect(mdmActions.entityCreated).not.toHaveBeenCalled();
|
|
1195
|
+
expect(mdmActions.errorsSet).toHaveBeenCalledWith([]);
|
|
1196
|
+
expect(mdmActions.closeRelationEditor).toHaveBeenCalledWith(props.config.id, connection.relation.relationUri);
|
|
1197
|
+
expect(mdmAction).toHaveBeenCalledTimes(2);
|
|
1198
|
+
return [2 /*return*/];
|
|
1162
1199
|
}
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
var
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1200
|
+
});
|
|
1201
|
+
}); });
|
|
1202
|
+
it('should restore all related referenced entities to their initial state and delete outdated related referenced entities', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1203
|
+
var entityUri, connection, modifiedEntities, relationToEdit, mdmValues, props, _a, user, rerender, updatedModifiedEntities;
|
|
1204
|
+
var _b, _c;
|
|
1205
|
+
return __generator(this, function (_d) {
|
|
1206
|
+
switch (_d.label) {
|
|
1207
|
+
case 0:
|
|
1208
|
+
entityUri = 'entities/uri$$kAp2KJM8';
|
|
1209
|
+
connection = __assign(__assign({}, defaultProps.connection), { entity: { entityUri: entityUri } });
|
|
1210
|
+
modifiedEntities = (_b = {},
|
|
1211
|
+
_b[entityUri] = {
|
|
1212
|
+
type: 'configuration/entityTypes/Location',
|
|
1213
|
+
uri: entityUri,
|
|
1214
|
+
attributes: {
|
|
1215
|
+
Address: [
|
|
1216
|
+
{
|
|
1217
|
+
refEntity: [{ objectURI: 'entities/uri$$kLnBs782' }],
|
|
1218
|
+
refRelation: null,
|
|
1219
|
+
uri: 'entities/uri$$kAp2KJM8/attributes/Address/uri$$nbsAsD',
|
|
1220
|
+
value: {},
|
|
1221
|
+
relationshipLabel: '',
|
|
1222
|
+
startObjectCrosswalks: []
|
|
1223
|
+
}
|
|
1224
|
+
]
|
|
1225
|
+
}
|
|
1226
|
+
},
|
|
1227
|
+
_b['entities/uri$$kLnBs782'] = {
|
|
1228
|
+
type: 'configuration/entityTypes/Location',
|
|
1229
|
+
uri: 'entities/uri$$kLnBs782',
|
|
1230
|
+
attributes: {
|
|
1231
|
+
Address: [
|
|
1232
|
+
{
|
|
1233
|
+
refEntity: [
|
|
1234
|
+
{
|
|
1235
|
+
objectURI: 'entities/uri$$ks0PsMA'
|
|
1236
|
+
}
|
|
1237
|
+
],
|
|
1238
|
+
refRelation: null,
|
|
1239
|
+
uri: 'entities/uri$$kLnBs782/attributes/Address/uri$$o23NbsDA',
|
|
1240
|
+
value: {},
|
|
1241
|
+
relationshipLabel: '',
|
|
1242
|
+
startObjectCrosswalks: []
|
|
1243
|
+
}
|
|
1244
|
+
]
|
|
1245
|
+
}
|
|
1246
|
+
},
|
|
1247
|
+
_b['entities/uri$$ks0PsMA'] = {
|
|
1248
|
+
uri: 'entities/uri$$ks0PsMA',
|
|
1249
|
+
type: 'configuration/entityTypes/Location'
|
|
1250
|
+
},
|
|
1251
|
+
_b);
|
|
1252
|
+
relationToEdit = __assign(__assign({}, connection), { initial: { connection: defaultProps.connection, modifiedEntity: modifiedEntities[entityUri] } });
|
|
1253
|
+
mdmValues = __assign(__assign({}, defaultMdmValues), { relations: (_c = {}, _c[defaultProps.config.id] = { relationsToEdit: [relationToEdit] }, _c), modifiedEntities: modifiedEntities });
|
|
1254
|
+
props = __assign(__assign({}, defaultProps), { connection: connection });
|
|
1255
|
+
_a = setUp({ mdmValues: mdmValues, props: props }), user = _a.user, rerender = _a.rerender;
|
|
1256
|
+
updatedModifiedEntities = __assign(__assign({}, modifiedEntities), { 'entities/uri$$ks0PsMA': {
|
|
1257
|
+
type: 'configuration/entityTypes/Location',
|
|
1258
|
+
uri: 'entities/uri$$ks0PsMA',
|
|
1259
|
+
attributes: {
|
|
1260
|
+
Address: [
|
|
1261
|
+
{
|
|
1262
|
+
refEntity: [
|
|
1263
|
+
{
|
|
1264
|
+
objectURI: 'entities/uri$$8jKsBssA3'
|
|
1265
|
+
}
|
|
1266
|
+
],
|
|
1267
|
+
refRelation: null,
|
|
1268
|
+
uri: 'entities/uri$$ks0PsMA/attributes/Address/uri$$o23NbsDA',
|
|
1269
|
+
value: {},
|
|
1270
|
+
relationshipLabel: '',
|
|
1271
|
+
startObjectCrosswalks: []
|
|
1272
|
+
}
|
|
1273
|
+
]
|
|
1274
|
+
}
|
|
1275
|
+
}, 'entities/uri$$8jKsBssA3': {
|
|
1276
|
+
uri: 'entities/uri$$8jKsBssA3',
|
|
1277
|
+
type: 'configuration/entityTypes/Location'
|
|
1278
|
+
}, 'entities/uri$$IS2bSa92': {
|
|
1279
|
+
uri: 'entities/uri$$IS2bSa92',
|
|
1280
|
+
type: 'configuration/entityTypes/HCP'
|
|
1281
|
+
} });
|
|
1282
|
+
rerender({ mdmValues: __assign(__assign({}, mdmValues), { modifiedEntities: updatedModifiedEntities }) });
|
|
1283
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Cancel'))];
|
|
1284
|
+
case 1:
|
|
1285
|
+
_d.sent();
|
|
1286
|
+
expect(mdmActions.entityCreated).toHaveBeenCalledWith(modifiedEntities['entities/uri$$kLnBs782']);
|
|
1287
|
+
expect(mdmActions.entityCreated).toHaveBeenCalledWith(modifiedEntities['entities/uri$$ks0PsMA']);
|
|
1288
|
+
expect(mdmActions.entityDeleted).toHaveBeenCalledWith('entities/uri$$8jKsBssA3');
|
|
1289
|
+
expect(mdmActions.entityDeleted).not.toHaveBeenCalledWith('entities/uri$$IS2bSa92');
|
|
1290
|
+
expect(mdmActions.errorsSet).toHaveBeenCalledWith([]);
|
|
1291
|
+
expect(mdmActions.closeRelationEditor).toHaveBeenCalledWith(props.config.id, connection.relation.relationUri);
|
|
1292
|
+
expect(mdmAction).toHaveBeenCalledTimes(5);
|
|
1293
|
+
return [2 /*return*/];
|
|
1176
1294
|
}
|
|
1177
1295
|
});
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1296
|
+
}); });
|
|
1297
|
+
});
|
|
1298
|
+
describe('entity selector', function () {
|
|
1299
|
+
describe('creating', function () {
|
|
1300
|
+
it('should create new entity and call events for saving it in relation and in modified entities store slice', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1301
|
+
var user;
|
|
1302
|
+
return __generator(this, function (_a) {
|
|
1303
|
+
switch (_a.label) {
|
|
1304
|
+
case 0:
|
|
1305
|
+
user = setUp().user;
|
|
1306
|
+
return [4 /*yield*/, user.click(react_2.screen.getByTestId('select-dropdown-indicator'))];
|
|
1307
|
+
case 1:
|
|
1308
|
+
_a.sent();
|
|
1309
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Create new Address'))];
|
|
1310
|
+
case 2:
|
|
1311
|
+
_a.sent();
|
|
1312
|
+
expect(mdmActions.setRelationEntity).toHaveBeenCalledWith(defaultProps.config.id, defaultProps.connection.relation.relationUri, {
|
|
1313
|
+
attributes: {},
|
|
1314
|
+
timestamp: expect.any(Number),
|
|
1315
|
+
type: 'configuration/entityTypes/Location',
|
|
1316
|
+
uri: expect.any(String)
|
|
1317
|
+
});
|
|
1318
|
+
expect(mdmActions.entityCreated).toHaveBeenCalledWith({
|
|
1319
|
+
attributes: {},
|
|
1320
|
+
timestamp: expect.any(Number),
|
|
1321
|
+
type: 'configuration/entityTypes/Location',
|
|
1322
|
+
uri: expect.any(String)
|
|
1323
|
+
});
|
|
1324
|
+
expect(mdmAction).toHaveBeenCalledTimes(2);
|
|
1325
|
+
return [2 /*return*/];
|
|
1199
1326
|
}
|
|
1200
|
-
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
}
|
|
1212
|
-
|
|
1327
|
+
});
|
|
1328
|
+
}); });
|
|
1329
|
+
it('should delete previous temp (modified) entity before creating new one', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1330
|
+
var entityUri, modifiedEntity, connection, mdmValues, props, user;
|
|
1331
|
+
var _a;
|
|
1332
|
+
return __generator(this, function (_b) {
|
|
1333
|
+
switch (_b.label) {
|
|
1334
|
+
case 0:
|
|
1335
|
+
entityUri = 'entities/uri$$kAp2KJM8';
|
|
1336
|
+
modifiedEntity = { type: 'configuration/entityTypes/Location', uri: entityUri, attributes: {} };
|
|
1337
|
+
connection = __assign(__assign({}, defaultProps.connection), { entity: { entityUri: entityUri, entityType: 'configuration/entityTypes/Location' } });
|
|
1338
|
+
mdmValues = __assign(__assign({}, defaultMdmValues), { modifiedEntities: (_a = {}, _a[entityUri] = modifiedEntity, _a) });
|
|
1339
|
+
props = __assign(__assign({}, defaultProps), { connection: connection });
|
|
1340
|
+
user = setUp({ mdmValues: mdmValues, props: props }).user;
|
|
1341
|
+
return [4 /*yield*/, user.click(react_2.screen.getByTestId('select-dropdown-indicator'))];
|
|
1342
|
+
case 1:
|
|
1343
|
+
_b.sent();
|
|
1344
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Create new Address'))];
|
|
1345
|
+
case 2:
|
|
1346
|
+
_b.sent();
|
|
1347
|
+
expect(mdmActions.setInitialInfo).toHaveBeenCalledWith(props.config.id, props.connection.relation.relationUri, modifiedEntity);
|
|
1348
|
+
expect(mdmActions.entityDeleted).toHaveBeenCalledWith(entityUri);
|
|
1349
|
+
expect(mdmActions.setRelationEntity).toHaveBeenCalledWith(defaultProps.config.id, defaultProps.connection.relation.relationUri, {
|
|
1350
|
+
attributes: {},
|
|
1351
|
+
timestamp: expect.any(Number),
|
|
1352
|
+
type: 'configuration/entityTypes/Location',
|
|
1353
|
+
uri: expect.any(String)
|
|
1354
|
+
});
|
|
1355
|
+
expect(mdmActions.entityCreated).toHaveBeenCalledWith({
|
|
1356
|
+
attributes: {},
|
|
1357
|
+
timestamp: expect.any(Number),
|
|
1358
|
+
type: 'configuration/entityTypes/Location',
|
|
1359
|
+
uri: expect.any(String)
|
|
1360
|
+
});
|
|
1361
|
+
expect(mdmAction).toHaveBeenCalledTimes(4);
|
|
1362
|
+
return [2 /*return*/];
|
|
1213
1363
|
}
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1364
|
+
});
|
|
1365
|
+
}); });
|
|
1366
|
+
it('should create new entity with init value and call events when onCreate prop was called with initValue argument', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1367
|
+
var user;
|
|
1368
|
+
return __generator(this, function (_a) {
|
|
1369
|
+
switch (_a.label) {
|
|
1370
|
+
case 0:
|
|
1371
|
+
user = setUp().user;
|
|
1372
|
+
return [4 /*yield*/, user.click(react_2.screen.getByTestId('select-dropdown-indicator'))];
|
|
1373
|
+
case 1:
|
|
1374
|
+
_a.sent();
|
|
1375
|
+
return [4 /*yield*/, user.type(react_2.screen.getByRole('combobox'), 'init value')];
|
|
1376
|
+
case 2:
|
|
1377
|
+
_a.sent();
|
|
1378
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('Create "init value" as new Address'))];
|
|
1379
|
+
case 3:
|
|
1380
|
+
_a.sent();
|
|
1381
|
+
expect(mdmActions.setRelationEntity).toHaveBeenCalledWith(defaultProps.config.id, defaultProps.connection.relation.relationUri, {
|
|
1382
|
+
attributes: {
|
|
1383
|
+
FirstName: [
|
|
1384
|
+
{
|
|
1385
|
+
type: 'configuration/entityTypes/Location/attributes/FirstName',
|
|
1386
|
+
uri: expect.any(String),
|
|
1387
|
+
value: 'init value'
|
|
1388
|
+
}
|
|
1389
|
+
]
|
|
1390
|
+
},
|
|
1391
|
+
timestamp: expect.any(Number),
|
|
1392
|
+
type: 'configuration/entityTypes/Location',
|
|
1393
|
+
uri: expect.any(String)
|
|
1394
|
+
});
|
|
1395
|
+
expect(mdmActions.entityCreated).toHaveBeenCalledWith({
|
|
1396
|
+
attributes: {
|
|
1397
|
+
FirstName: [
|
|
1398
|
+
{
|
|
1399
|
+
type: 'configuration/entityTypes/Location/attributes/FirstName',
|
|
1400
|
+
uri: expect.any(String),
|
|
1401
|
+
value: 'init value'
|
|
1402
|
+
}
|
|
1403
|
+
]
|
|
1404
|
+
},
|
|
1405
|
+
timestamp: expect.any(Number),
|
|
1406
|
+
type: 'configuration/entityTypes/Location',
|
|
1407
|
+
uri: expect.any(String)
|
|
1408
|
+
});
|
|
1409
|
+
expect(mdmAction).toHaveBeenCalledTimes(2);
|
|
1410
|
+
return [2 /*return*/];
|
|
1244
1411
|
}
|
|
1245
|
-
}, 'entities/uri$$outdatedEntity': {
|
|
1246
|
-
uri: 'entities/uri$$outdatedEntity',
|
|
1247
|
-
attributes: {}
|
|
1248
|
-
}, 'entities/uri$$notRelatedEntity': {
|
|
1249
|
-
uri: 'entities/uri$$notRelatedEntity',
|
|
1250
|
-
attributes: {}
|
|
1251
|
-
} }));
|
|
1252
|
-
component.setProps({ test: 1 });
|
|
1253
|
-
findCancelButton(component).find('button').simulate('click');
|
|
1254
|
-
expect(mdmActions.entityCreated).toHaveBeenCalledWith(initialAllModifiedEntities['entities/uri$$addressEntity1']);
|
|
1255
|
-
expect(mdmActions.entityCreated).toHaveBeenCalledWith(initialAllModifiedEntities['entities/uri$$locationEntity']);
|
|
1256
|
-
expect(mdmActions.entityDeleted).toHaveBeenCalledWith('entities/uri$$outdatedEntity');
|
|
1257
|
-
expect(mdmActions.entityDeleted).not.toHaveBeenCalledWith('entities/uri$$notRelatedEntity');
|
|
1258
|
-
expect(mdmActions.errorsSet).toHaveBeenCalledWith([]);
|
|
1259
|
-
expect(mdmActions.closeRelationEditor).toHaveBeenCalledWith(relations_test_data_1.config.id, connection.relation.relationUri);
|
|
1260
|
-
expect(mdmAction).toHaveBeenCalledTimes(5);
|
|
1261
|
-
});
|
|
1262
|
-
});
|
|
1263
|
-
describe('EntitySelector behavior', function () {
|
|
1264
|
-
describe('onCreate behavior', function () {
|
|
1265
|
-
it('should create new entity and call events for saving it in relation and in modified entities store slice', function () {
|
|
1266
|
-
var mockedNewEntity = { uri: 'entities/uri$$1' };
|
|
1267
|
-
mdm_sdk_1.createTemporaryEntity.mockReturnValue(mockedNewEntity);
|
|
1268
|
-
mdm_sdk_1.getEntityType.mockReturnValue({ dataLabelPattern: '{Name}' });
|
|
1269
|
-
var connection = {
|
|
1270
|
-
relation: {
|
|
1271
|
-
relationUri: relationUri,
|
|
1272
|
-
relationType: 'configuration/relationTypes/AccountTeam'
|
|
1273
|
-
},
|
|
1274
|
-
entity: {}
|
|
1275
|
-
};
|
|
1276
|
-
var entityTypeUri = 'configuration/entityTypes/HCP';
|
|
1277
|
-
var metadata = { relationTypes: [] };
|
|
1278
|
-
var props = __assign(__assign({}, defaultProps), { connection: connection, config: relations_test_data_1.config, metadata: metadata });
|
|
1279
|
-
var component = setUp({ props: props });
|
|
1280
|
-
var entitySelector = component.find(EntitySelector_1.EntitySelector);
|
|
1281
|
-
expect(entitySelector.length).toBe(1);
|
|
1282
|
-
entitySelector.prop('onCreate')(entityTypeUri);
|
|
1283
|
-
expect(mdm_sdk_1.getEntityType).toHaveBeenCalledWith(metadata, entityTypeUri);
|
|
1284
|
-
expect(mdm_sdk_1.createTemporaryEntity).toHaveBeenCalledWith(expect.objectContaining({ entityTypeUri: entityTypeUri }));
|
|
1285
|
-
expect(mdmActions.setRelationEntity).toHaveBeenCalledWith(relations_test_data_1.config.id, connection.relation.relationUri, mockedNewEntity);
|
|
1286
|
-
expect(mdmActions.entityCreated).toHaveBeenCalledWith(mockedNewEntity);
|
|
1287
|
-
expect(mdmAction).toHaveBeenCalledTimes(2);
|
|
1288
|
-
});
|
|
1289
|
-
it('should delete previous temp (modified) entity before creating new one', function () {
|
|
1290
|
-
var mockedNewEntity = { uri: 'entities/uri$$1' };
|
|
1291
|
-
mdm_sdk_1.createTemporaryEntity.mockReturnValue(mockedNewEntity);
|
|
1292
|
-
mdm_sdk_1.getEntityType.mockReturnValue({ dataLabelPattern: '{Name}' });
|
|
1293
|
-
var connection = {
|
|
1294
|
-
relation: {
|
|
1295
|
-
relationUri: relationUri,
|
|
1296
|
-
relationType: 'configuration/relationTypes/AccountTeam'
|
|
1297
|
-
},
|
|
1298
|
-
entity: { entityUri: 'entities/uri$$prev' }
|
|
1299
|
-
};
|
|
1300
|
-
var modifiedEntity = { uri: 'entities/uri$$prev' };
|
|
1301
|
-
var entityTypeUri = 'configuration/entityTypes/HCP';
|
|
1302
|
-
var metadata = { relationTypes: [] };
|
|
1303
|
-
var props = __assign(__assign({}, defaultProps), { connection: connection, config: relations_test_data_1.config, metadata: metadata });
|
|
1304
|
-
var mdmValues = __assign(__assign({}, defaultMdmValues), { modifiedEntity: modifiedEntity });
|
|
1305
|
-
var component = setUp({ props: props, mdmValues: mdmValues });
|
|
1306
|
-
var entitySelector = component.find(EntitySelector_1.EntitySelector);
|
|
1307
|
-
expect(entitySelector.length).toBe(1);
|
|
1308
|
-
entitySelector.prop('onCreate')(entityTypeUri);
|
|
1309
|
-
expect(mdm_sdk_1.getEntityType).toHaveBeenCalledWith(metadata, entityTypeUri);
|
|
1310
|
-
expect(mdm_sdk_1.createTemporaryEntity).toHaveBeenCalledWith(expect.objectContaining({ entityTypeUri: entityTypeUri }));
|
|
1311
|
-
expect(mdmActions.setInitialInfo).toHaveBeenCalledWith(relations_test_data_1.config.id, relationUri, modifiedEntity);
|
|
1312
|
-
expect(mdmActions.entityDeleted).toHaveBeenCalledWith('entities/uri$$prev');
|
|
1313
|
-
expect(mdmActions.setRelationEntity).toHaveBeenCalledWith(relations_test_data_1.config.id, connection.relation.relationUri, mockedNewEntity);
|
|
1314
|
-
expect(mdmActions.entityCreated).toHaveBeenCalledWith(mockedNewEntity);
|
|
1315
|
-
expect(mdmAction).toHaveBeenCalledTimes(4);
|
|
1316
|
-
});
|
|
1317
|
-
it('should create new entity with init value and call events when onCreate prop was called with initValue argument', function () {
|
|
1318
|
-
var connection = {
|
|
1319
|
-
relation: {
|
|
1320
|
-
relationUri: relationUri,
|
|
1321
|
-
relationType: 'configuration/relationTypes/AccountTeam'
|
|
1322
|
-
},
|
|
1323
|
-
entity: {}
|
|
1324
|
-
};
|
|
1325
|
-
var entityTypeUri = 'configuration/entityTypes/HCP';
|
|
1326
|
-
var entityType = {
|
|
1327
|
-
uri: 'configuration/entityTypes/HCP',
|
|
1328
|
-
label: 'HCP',
|
|
1329
|
-
attributes: [
|
|
1330
|
-
{
|
|
1331
|
-
name: 'Name',
|
|
1332
|
-
type: 'String',
|
|
1333
|
-
uri: 'configuration/entityTypes/HCP/attributes/Name',
|
|
1334
|
-
access: ['CREATE', 'READ']
|
|
1335
|
-
},
|
|
1336
|
-
{
|
|
1337
|
-
name: 'Int',
|
|
1338
|
-
type: 'Int',
|
|
1339
|
-
uri: 'configuration/entityTypes/HCP/attributes/Int',
|
|
1340
|
-
access: ['CREATE', 'READ']
|
|
1341
|
-
},
|
|
1342
|
-
{
|
|
1343
|
-
name: 'UsedInBusinessCard',
|
|
1344
|
-
type: 'String',
|
|
1345
|
-
uri: 'configuration/entityTypes/HCP/attributes/UsedInBusinessCard',
|
|
1346
|
-
access: ['CREATE', 'READ']
|
|
1347
|
-
},
|
|
1348
|
-
{
|
|
1349
|
-
name: 'DataLabelSimple',
|
|
1350
|
-
type: 'String',
|
|
1351
|
-
uri: 'configuration/entityTypes/HCP/attributes/DataLabelSimple',
|
|
1352
|
-
access: []
|
|
1353
|
-
},
|
|
1354
|
-
{
|
|
1355
|
-
name: 'Required',
|
|
1356
|
-
type: 'String',
|
|
1357
|
-
required: true,
|
|
1358
|
-
uri: 'configuration/entityTypes/HCP/attributes/Required',
|
|
1359
|
-
access: []
|
|
1360
|
-
}
|
|
1361
|
-
],
|
|
1362
|
-
dataLabelPattern: '{DataLabelSimple} {OtherSimple}',
|
|
1363
|
-
businessCardAttributeURIs: [
|
|
1364
|
-
'configuration/entityTypes/HCP/attributes/Employment',
|
|
1365
|
-
'configuration/entityTypes/HCP/attributes/FirstName',
|
|
1366
|
-
'configuration/entityTypes/HCP/attributes/UsedInBusinessCard'
|
|
1367
|
-
]
|
|
1368
|
-
};
|
|
1369
|
-
var mockedNewEntity = { uri: 'entities/uri$$1' };
|
|
1370
|
-
var initValue = '123';
|
|
1371
|
-
var metadata = { relationTypes: [] };
|
|
1372
|
-
mdm_sdk_1.getEntityType.mockReturnValue(entityType);
|
|
1373
|
-
mdm_sdk_1.createTemporaryEntity.mockReturnValue(mockedNewEntity);
|
|
1374
|
-
var props = __assign(__assign({}, defaultProps), { connection: connection, config: relations_test_data_1.config, metadata: metadata });
|
|
1375
|
-
var component = setUp({ props: props });
|
|
1376
|
-
var entitySelector = component.find(EntitySelector_1.EntitySelector);
|
|
1377
|
-
expect(entitySelector.length).toBe(1);
|
|
1378
|
-
entitySelector.prop('onCreate')(entityTypeUri, initValue);
|
|
1379
|
-
expect(mdm_sdk_1.getEntityType).toHaveBeenCalledWith(metadata, entityTypeUri);
|
|
1380
|
-
expect(mdm_sdk_1.createTemporaryEntity).toHaveBeenCalledWith({
|
|
1381
|
-
entityTypeUri: entityTypeUri,
|
|
1382
|
-
initValue: initValue,
|
|
1383
|
-
attributeTypes: [
|
|
1384
|
-
{
|
|
1385
|
-
name: 'UsedInBusinessCard',
|
|
1386
|
-
type: 'String',
|
|
1387
|
-
uri: 'configuration/entityTypes/HCP/attributes/UsedInBusinessCard',
|
|
1388
|
-
access: ['CREATE', 'READ']
|
|
1389
|
-
}
|
|
1390
|
-
],
|
|
1391
|
-
metadata: metadata,
|
|
1392
|
-
mode: 'Editing'
|
|
1393
1412
|
});
|
|
1394
|
-
|
|
1395
|
-
expect(mdmActions.entityCreated).toHaveBeenCalledWith(mockedNewEntity);
|
|
1396
|
-
expect(mdmAction).toHaveBeenCalledTimes(2);
|
|
1397
|
-
});
|
|
1413
|
+
}); });
|
|
1398
1414
|
});
|
|
1399
|
-
describe('
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
},
|
|
1406
|
-
entity: {}
|
|
1407
|
-
};
|
|
1408
|
-
var props = __assign(__assign({}, defaultProps), { connection: connection, config: relations_test_data_1.config });
|
|
1409
|
-
var component = setUp({ props: props });
|
|
1410
|
-
var entitySelector = component.find(EntitySelector_1.EntitySelector);
|
|
1411
|
-
expect(entitySelector.length).toBe(1);
|
|
1412
|
-
var entity = { uri: 'entities/123' };
|
|
1413
|
-
entitySelector.prop('onChange')(entity);
|
|
1414
|
-
expect(mdmActions.setRelationEntity).toHaveBeenCalledWith(relations_test_data_1.config.id, connection.relation.relationUri, entity);
|
|
1415
|
-
expect(mdmAction).toHaveBeenCalledTimes(1);
|
|
1415
|
+
describe('changing', function () {
|
|
1416
|
+
beforeEach(function () {
|
|
1417
|
+
mdm_sdk_1.typeAheadSearch.mockResolvedValue([
|
|
1418
|
+
{ type: 'configuration/entityTypes/Location', label: 'location entity 1', uri: 'entities/0C32GxR' },
|
|
1419
|
+
{ type: 'configuration/entityTypes/Location', label: 'location entity 2', uri: 'entities/0G49Cnu' }
|
|
1420
|
+
]);
|
|
1416
1421
|
});
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
relation: {
|
|
1420
|
-
relationUri: relationUri,
|
|
1421
|
-
relationType: 'configuration/relationTypes/AccountTeam'
|
|
1422
|
-
},
|
|
1423
|
-
entity: {}
|
|
1424
|
-
};
|
|
1425
|
-
var error = {
|
|
1426
|
-
uri: 'uri',
|
|
1427
|
-
type: 'missedRefEntity',
|
|
1428
|
-
message: 'alarm!',
|
|
1429
|
-
attributeTypeUri: 'configuration/relationTypes/AccountTeam',
|
|
1430
|
-
parentUri: relationUri
|
|
1431
|
-
};
|
|
1432
|
-
var profileErrors = [error];
|
|
1433
|
-
var props = __assign(__assign({}, defaultProps), { connection: connection, config: relations_test_data_1.config });
|
|
1434
|
-
var mdmValues = __assign(__assign({}, defaultMdmValues), { profileErrors: profileErrors });
|
|
1435
|
-
var component = setUp({ props: props, mdmValues: mdmValues });
|
|
1436
|
-
var entitySelector = component.find(EntitySelector_1.EntitySelector);
|
|
1437
|
-
expect(entitySelector.length).toBe(1);
|
|
1438
|
-
var entity = { uri: 'entities/123' };
|
|
1439
|
-
entitySelector.prop('onChange')(entity);
|
|
1440
|
-
expect(mdmActions.setRelationEntity).toHaveBeenCalledWith(relations_test_data_1.config.id, connection.relation.relationUri, entity);
|
|
1441
|
-
expect(mdmActions.errorDeactivated).toHaveBeenCalledWith("".concat(error.attributeTypeUri, "-").concat(error.uri, "-").concat(error.parentUri));
|
|
1442
|
-
expect(mdmAction).toHaveBeenCalledTimes(2);
|
|
1443
|
-
});
|
|
1444
|
-
it('should clear connection entity and modified entity if it set', function () {
|
|
1445
|
-
var connection = {
|
|
1446
|
-
relation: {
|
|
1447
|
-
relationUri: relationUri,
|
|
1448
|
-
relationType: 'configuration/relationTypes/AccountTeam'
|
|
1449
|
-
},
|
|
1450
|
-
entity: { entityUri: 'entities/uri$$1' }
|
|
1451
|
-
};
|
|
1452
|
-
var modifiedEntity = { uri: 'entities/uri$$1' };
|
|
1453
|
-
var props = __assign(__assign({}, defaultProps), { connection: connection, config: relations_test_data_1.config });
|
|
1454
|
-
var mdmValues = __assign(__assign({}, defaultMdmValues), { modifiedEntity: modifiedEntity, initialModifiedEntity: modifiedEntity });
|
|
1455
|
-
var component = setUp({ props: props, mdmValues: mdmValues });
|
|
1456
|
-
var entitySelector = component.find(EntitySelector_1.EntitySelector);
|
|
1457
|
-
expect(entitySelector.length).toBe(1);
|
|
1458
|
-
var entity = {};
|
|
1459
|
-
entitySelector.prop('onChange')(entity);
|
|
1460
|
-
expect(mdmActions.entityDeleted).toHaveBeenCalledWith(modifiedEntity.uri);
|
|
1461
|
-
expect(mdmActions.setRelationEntity).toHaveBeenCalledWith(relations_test_data_1.config.id, connection.relation.relationUri, entity);
|
|
1462
|
-
expect(mdmAction).toHaveBeenCalledTimes(2);
|
|
1422
|
+
afterEach(function () {
|
|
1423
|
+
jest.clearAllMocks();
|
|
1463
1424
|
});
|
|
1425
|
+
it('should set connection entity', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1426
|
+
var user;
|
|
1427
|
+
return __generator(this, function (_a) {
|
|
1428
|
+
switch (_a.label) {
|
|
1429
|
+
case 0:
|
|
1430
|
+
user = setUp().user;
|
|
1431
|
+
return [4 /*yield*/, user.click(react_2.screen.getByTestId('select-dropdown-indicator'))];
|
|
1432
|
+
case 1:
|
|
1433
|
+
_a.sent();
|
|
1434
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('location entity 1'))];
|
|
1435
|
+
case 2:
|
|
1436
|
+
_a.sent();
|
|
1437
|
+
expect(mdmActions.setRelationEntity).toHaveBeenCalledWith(defaultProps.config.id, defaultProps.connection.relation.relationUri, {
|
|
1438
|
+
entityType: defaultProps.metadata.entityTypes[1],
|
|
1439
|
+
label: 'location entity 1',
|
|
1440
|
+
type: 'configuration/entityTypes/Location',
|
|
1441
|
+
uri: 'entities/0C32GxR'
|
|
1442
|
+
});
|
|
1443
|
+
expect(mdmAction).toHaveBeenCalledTimes(1);
|
|
1444
|
+
return [2 /*return*/];
|
|
1445
|
+
}
|
|
1446
|
+
});
|
|
1447
|
+
}); });
|
|
1448
|
+
it('should deactivate error if it was set', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1449
|
+
var error, mdmValues, user;
|
|
1450
|
+
return __generator(this, function (_a) {
|
|
1451
|
+
switch (_a.label) {
|
|
1452
|
+
case 0:
|
|
1453
|
+
error = {
|
|
1454
|
+
parentUri: defaultRelation.relationUri,
|
|
1455
|
+
uri: 'uri',
|
|
1456
|
+
attributeTypeUri: defaultRelation.relationType,
|
|
1457
|
+
message: 'Entity is required',
|
|
1458
|
+
type: mdm_sdk_1.ErrorType.missedRefEntity
|
|
1459
|
+
};
|
|
1460
|
+
mdmValues = __assign(__assign({}, defaultMdmValues), { profileErrors: [error] });
|
|
1461
|
+
setUp({ mdmValues: mdmValues });
|
|
1462
|
+
user = setUp().user;
|
|
1463
|
+
return [4 /*yield*/, user.click(react_2.screen.getAllByTestId('select-dropdown-indicator')[0])];
|
|
1464
|
+
case 1:
|
|
1465
|
+
_a.sent();
|
|
1466
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('location entity 1'))];
|
|
1467
|
+
case 2:
|
|
1468
|
+
_a.sent();
|
|
1469
|
+
expect(mdmActions.setRelationEntity).toHaveBeenCalledWith(defaultProps.config.id, defaultProps.connection.relation.relationUri, {
|
|
1470
|
+
entityType: defaultProps.metadata.entityTypes[1],
|
|
1471
|
+
label: 'location entity 1',
|
|
1472
|
+
type: 'configuration/entityTypes/Location',
|
|
1473
|
+
uri: 'entities/0C32GxR'
|
|
1474
|
+
});
|
|
1475
|
+
expect(mdmActions.errorDeactivated).toHaveBeenCalledWith("".concat(error.attributeTypeUri, "-").concat(error.uri, "-").concat(error.parentUri));
|
|
1476
|
+
expect(mdmAction).toHaveBeenCalledTimes(2);
|
|
1477
|
+
return [2 /*return*/];
|
|
1478
|
+
}
|
|
1479
|
+
});
|
|
1480
|
+
}); });
|
|
1481
|
+
it('should clear connection entity and modified entity if it set', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1482
|
+
var entityUri, modifiedEntity, connection, mdmValues, props, user;
|
|
1483
|
+
var _a;
|
|
1484
|
+
return __generator(this, function (_b) {
|
|
1485
|
+
switch (_b.label) {
|
|
1486
|
+
case 0:
|
|
1487
|
+
entityUri = 'entities/uri$$kAp2KJM8';
|
|
1488
|
+
modifiedEntity = { type: 'configuration/entityTypes/Location', uri: entityUri, attributes: {} };
|
|
1489
|
+
connection = __assign(__assign({}, defaultProps.connection), { entity: { entityUri: entityUri, entityType: 'configuration/entityTypes/Location' } });
|
|
1490
|
+
mdmValues = __assign(__assign({}, defaultMdmValues), { modifiedEntities: (_a = {}, _a[entityUri] = modifiedEntity, _a) });
|
|
1491
|
+
props = __assign(__assign({}, defaultProps), { connection: connection });
|
|
1492
|
+
user = setUp({ mdmValues: mdmValues, props: props }).user;
|
|
1493
|
+
mdmAction.mockClear();
|
|
1494
|
+
return [4 /*yield*/, user.click(react_2.screen.getByTestId('select-dropdown-indicator'))];
|
|
1495
|
+
case 1:
|
|
1496
|
+
_b.sent();
|
|
1497
|
+
return [4 /*yield*/, user.click(react_2.screen.getByText('location entity 1'))];
|
|
1498
|
+
case 2:
|
|
1499
|
+
_b.sent();
|
|
1500
|
+
expect(mdmActions.entityDeleted).toHaveBeenCalledWith(entityUri);
|
|
1501
|
+
expect(mdmActions.setRelationEntity).toHaveBeenCalledWith(defaultProps.config.id, defaultProps.connection.relation.relationUri, {
|
|
1502
|
+
entityType: defaultProps.metadata.entityTypes[1],
|
|
1503
|
+
label: 'location entity 1',
|
|
1504
|
+
type: 'configuration/entityTypes/Location',
|
|
1505
|
+
uri: 'entities/0C32GxR'
|
|
1506
|
+
});
|
|
1507
|
+
expect(mdmAction).toHaveBeenCalledTimes(2);
|
|
1508
|
+
return [2 /*return*/];
|
|
1509
|
+
}
|
|
1510
|
+
});
|
|
1511
|
+
}); });
|
|
1464
1512
|
});
|
|
1465
1513
|
});
|
|
1466
|
-
describe('
|
|
1514
|
+
describe('errors highlighting', function () {
|
|
1467
1515
|
var fullError = {
|
|
1468
|
-
type:
|
|
1516
|
+
type: mdm_sdk_1.ErrorType.invalid,
|
|
1469
1517
|
attributeTypeUri: defaultProps.connection.relation.relationType,
|
|
1470
1518
|
parentUri: defaultProps.connection.relation.relationUri,
|
|
1471
1519
|
uri: 'someUrl',
|
|
1472
|
-
source:
|
|
1473
|
-
severity:
|
|
1520
|
+
source: mdm_sdk_1.ErrorSource.validationService,
|
|
1521
|
+
severity: mdm_sdk_1.ErrorSeverity.ERROR
|
|
1474
1522
|
};
|
|
1475
|
-
it('should not highlight error if it have uri', function () {
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1523
|
+
it('should not highlight error if it have uri', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1524
|
+
return __generator(this, function (_a) {
|
|
1525
|
+
switch (_a.label) {
|
|
1526
|
+
case 0:
|
|
1527
|
+
setUp({ error: fullError });
|
|
1528
|
+
return [4 /*yield*/, react_2.screen.findByText('Select Address profile')];
|
|
1529
|
+
case 1:
|
|
1530
|
+
_a.sent();
|
|
1531
|
+
expect(scrollIntoRef).not.toHaveBeenCalledWith();
|
|
1532
|
+
return [2 /*return*/];
|
|
1533
|
+
}
|
|
1481
1534
|
});
|
|
1482
|
-
});
|
|
1483
|
-
it('should highlight error if it have same parent uri, empty uri, and attribute type uri', function () {
|
|
1484
|
-
var error
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1535
|
+
}); });
|
|
1536
|
+
it('should highlight error if it have same parent uri, empty uri, and attribute type uri', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1537
|
+
var error;
|
|
1538
|
+
return __generator(this, function (_a) {
|
|
1539
|
+
switch (_a.label) {
|
|
1540
|
+
case 0:
|
|
1541
|
+
error = __assign(__assign({}, fullError), { uri: '' });
|
|
1542
|
+
setUp({ error: error });
|
|
1543
|
+
return [4 /*yield*/, react_2.screen.findByText('Select Address profile')];
|
|
1544
|
+
case 1:
|
|
1545
|
+
_a.sent();
|
|
1546
|
+
expect(scrollIntoRef).toHaveBeenCalled();
|
|
1547
|
+
return [2 /*return*/];
|
|
1548
|
+
}
|
|
1549
|
+
});
|
|
1550
|
+
}); });
|
|
1495
1551
|
});
|
|
1496
1552
|
});
|