@reltio/components 1.4.1906 → 1.4.1907

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/cjs/ActionsPanel/ActionsPanel.test.js +133 -49
  2. package/cjs/AttributeListItem/AttributeListItem.spec.js +147 -118
  3. package/cjs/AttributeSelector/AttributeSelector.specs.js +125 -193
  4. package/cjs/AttributesErrorsPanel/AttributesErrorsPanel.specs.js +128 -71
  5. package/cjs/AttributesErrorsPanel/components/Error/Error.specs.js +96 -90
  6. package/cjs/AttributesErrorsPanel/store.test-data.d.ts +22 -0
  7. package/cjs/AttributesErrorsPanel/store.test-data.js +29 -0
  8. package/cjs/AttributesFilterSelector/AttributesFilterSelector.test.js +127 -105
  9. package/cjs/AttributesFiltersButton/AttributesFiltersButton.test.js +218 -136
  10. package/cjs/AttributesValuesEditor/AttributesValuesEditor.test.js +92 -88
  11. package/cjs/AttributesView/AttributesView.test.js +67 -34
  12. package/cjs/AutoSizeList/AutoSizeList.test.js +81 -59
  13. package/cjs/{ActionsPanel/components/MenuItemRenderer/MenuItemRenderer.spec.js → AvatarWithFallback/AvatarWithFallback.test.js} +15 -31
  14. package/cjs/BarChart/BarChart.test.js +128 -65
  15. package/cjs/BasicAttributeSelector/BasicAttributeSelector.spec.js +27 -10
  16. package/cjs/BasicViewContent/BasicViewContent.test.js +7 -9
  17. package/cjs/BlobRenderer/BlobRenderer.test.js +28 -9
  18. package/cjs/BooleanRadioEditor/BooleanRadioEditor.test.js +89 -35
  19. package/cjs/BubbleChart/BubbleChart.test.js +111 -87
  20. package/cjs/CloudChart/CloudChart.test.js +95 -36
  21. package/cjs/CollaborationItem/CollaborationItem.test.js +67 -30
  22. package/cjs/CollaborationItem/components/Comment/Comment.test.js +221 -189
  23. package/cjs/CollaborationItem/components/CommentContent/CommentContent.test.js +46 -81
  24. package/cjs/CollaborationItem/components/RepliedComment/RepliedComment.test.js +194 -163
  25. package/cjs/CollaborationItem/components/SendMessageArea/SendMessageArea.test.js +307 -266
  26. package/cjs/CollapseButton/CollapseButton.test.js +74 -15
  27. package/cjs/CollapseRowButton/CollapseRowButton.test.js +82 -24
  28. package/cjs/ColorBar/ColorBar.test.js +13 -15
  29. package/cjs/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.spec.js +207 -129
  30. package/cjs/CommentsContainer/CommentsContainer.test.js +282 -211
  31. package/cjs/CommentsContainer/components/CollaborationPopup/CollaborationPopup.test.js +183 -122
  32. package/cjs/ConfigureColumnsPopup/ConfigureColumnsPopup.test.js +42 -41
  33. package/cjs/ConfirmDeleteDialog/ConfirmDeleteDialog.test.js +77 -28
  34. package/cjs/ConfirmationDialog/ConfirmationDialog.test.js +85 -48
  35. package/cjs/ConnectionEditor/ConnectionEditor.test.js +299 -282
  36. package/esm/ActionsPanel/ActionsPanel.test.js +133 -49
  37. package/esm/AttributeListItem/AttributeListItem.spec.js +149 -97
  38. package/esm/AttributeSelector/AttributeSelector.specs.js +125 -193
  39. package/esm/AttributesErrorsPanel/AttributesErrorsPanel.specs.js +128 -71
  40. package/esm/AttributesErrorsPanel/components/Error/Error.specs.js +98 -72
  41. package/esm/AttributesErrorsPanel/store.test-data.d.ts +22 -0
  42. package/esm/AttributesErrorsPanel/store.test-data.js +26 -0
  43. package/esm/AttributesFilterSelector/AttributesFilterSelector.test.js +129 -84
  44. package/esm/AttributesFiltersButton/AttributesFiltersButton.test.js +218 -136
  45. package/esm/AttributesValuesEditor/AttributesValuesEditor.test.js +94 -67
  46. package/esm/AttributesView/AttributesView.test.js +67 -34
  47. package/esm/AutoSizeList/AutoSizeList.test.js +81 -59
  48. package/esm/{ActionsPanel/components/MenuItemRenderer/MenuItemRenderer.spec.js → AvatarWithFallback/AvatarWithFallback.test.js} +16 -32
  49. package/esm/BarChart/BarChart.test.js +128 -65
  50. package/esm/BasicAttributeSelector/BasicAttributeSelector.spec.js +27 -10
  51. package/esm/BasicViewContent/BasicViewContent.test.js +7 -9
  52. package/esm/BlobRenderer/BlobRenderer.test.js +28 -9
  53. package/esm/BooleanRadioEditor/BooleanRadioEditor.test.js +89 -35
  54. package/esm/BubbleChart/BubbleChart.test.js +111 -87
  55. package/esm/CloudChart/CloudChart.test.js +95 -36
  56. package/esm/CollaborationItem/CollaborationItem.test.js +67 -30
  57. package/esm/CollaborationItem/components/Comment/Comment.test.js +221 -189
  58. package/esm/CollaborationItem/components/CommentContent/CommentContent.test.js +46 -58
  59. package/esm/CollaborationItem/components/RepliedComment/RepliedComment.test.js +194 -163
  60. package/esm/CollaborationItem/components/SendMessageArea/SendMessageArea.test.js +307 -266
  61. package/esm/CollapseButton/CollapseButton.test.js +74 -15
  62. package/esm/CollapseRowButton/CollapseRowButton.test.js +82 -24
  63. package/esm/ColorBar/ColorBar.test.js +13 -15
  64. package/esm/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.spec.js +207 -129
  65. package/esm/CommentsContainer/CommentsContainer.test.js +282 -211
  66. package/esm/CommentsContainer/components/CollaborationPopup/CollaborationPopup.test.js +182 -101
  67. package/esm/ConfigureColumnsPopup/ConfigureColumnsPopup.test.js +42 -41
  68. package/esm/ConfirmDeleteDialog/ConfirmDeleteDialog.test.js +77 -28
  69. package/esm/ConfirmationDialog/ConfirmationDialog.test.js +85 -48
  70. package/esm/ConnectionEditor/ConnectionEditor.test.js +300 -283
  71. package/package.json +1 -1
  72. package/cjs/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.specs.js +0 -100
  73. package/cjs/AttributesFiltersButton/components/ActionButtons/ActionButtons.test.d.ts +0 -1
  74. package/cjs/AttributesFiltersButton/components/ActionButtons/ActionButtons.test.js +0 -46
  75. package/cjs/AvatarWithFallback/AvatarWithFallback.specs.d.ts +0 -1
  76. package/cjs/AvatarWithFallback/AvatarWithFallback.specs.js +0 -27
  77. package/cjs/BooleanRadioEditor/components/BooleanEditor/BooleanEditor.test.d.ts +0 -1
  78. package/cjs/BooleanRadioEditor/components/BooleanEditor/BooleanEditor.test.js +0 -27
  79. package/cjs/CollaborationItem/components/Avatar/Avatar.test.d.ts +0 -1
  80. package/cjs/CollaborationItem/components/Avatar/Avatar.test.js +0 -15
  81. package/cjs/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.test.d.ts +0 -1
  82. package/cjs/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.test.js +0 -80
  83. package/esm/ActionsPanel/components/MenuItemRenderer/MenuItemRenderer.spec.d.ts +0 -1
  84. package/esm/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.specs.d.ts +0 -1
  85. package/esm/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.specs.js +0 -95
  86. package/esm/AttributesFiltersButton/components/ActionButtons/ActionButtons.test.d.ts +0 -1
  87. package/esm/AttributesFiltersButton/components/ActionButtons/ActionButtons.test.js +0 -41
  88. package/esm/AvatarWithFallback/AvatarWithFallback.specs.d.ts +0 -1
  89. package/esm/AvatarWithFallback/AvatarWithFallback.specs.js +0 -22
  90. package/esm/BooleanRadioEditor/components/BooleanEditor/BooleanEditor.test.d.ts +0 -1
  91. package/esm/BooleanRadioEditor/components/BooleanEditor/BooleanEditor.test.js +0 -22
  92. package/esm/CollaborationItem/components/Avatar/Avatar.test.d.ts +0 -1
  93. package/esm/CollaborationItem/components/Avatar/Avatar.test.js +0 -10
  94. package/esm/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.test.d.ts +0 -1
  95. package/esm/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.test.js +0 -55
  96. /package/cjs/{ActionsPanel/components/MenuItemRenderer/MenuItemRenderer.spec.d.ts → AvatarWithFallback/AvatarWithFallback.test.d.ts} +0 -0
  97. /package/{cjs/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.specs.d.ts → esm/AvatarWithFallback/AvatarWithFallback.test.d.ts} +0 -0
@@ -46,300 +46,343 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
46
46
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
47
  }
48
48
  };
49
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
50
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
51
- if (ar || !(i in from)) {
52
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
53
- ar[i] = from[i];
54
- }
55
- }
56
- return to.concat(ar || Array.prototype.slice.call(from));
57
- };
58
49
  var __importDefault = (this && this.__importDefault) || function (mod) {
59
50
  return (mod && mod.__esModule) ? mod : { "default": mod };
60
51
  };
61
- var _a, _b;
62
52
  Object.defineProperty(exports, "__esModule", { value: true });
63
53
  var react_1 = __importDefault(require("react"));
64
- var enzyme_1 = require("enzyme");
65
- var test_utils_1 = require("react-dom/test-utils");
66
54
  var mdm_sdk_1 = require("@reltio/mdm-sdk");
55
+ var user_event_1 = __importDefault(require("@testing-library/user-event"));
56
+ var react_2 = require("@testing-library/react");
57
+ var LocalizationProvider_1 = require("@mui/x-date-pickers/LocalizationProvider");
58
+ var AdapterMoment_1 = require("@mui/x-date-pickers/AdapterMoment");
59
+ var test_utils_1 = require("../test-utils");
67
60
  var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
68
- var EditModeAttributesList_1 = require("../EditModeAttributesList");
69
- var EntitySelector_1 = require("../EntitySelector");
70
- var ConnectionRelationTypeSelector_1 = require("../ConnectionRelationTypeSelector");
71
- var ErrorWrapper_1 = require("../ErrorWrapper");
72
61
  var ConnectionEditor_1 = require("./ConnectionEditor");
73
- jest.mock('../EntitySelector', function () { return ({
74
- EntitySelector: function () { return null; }
75
- }); });
76
- jest.mock('../EditModeAttributesList', function () { return ({
77
- EditModeAttributesList: function () { return null; }
78
- }); });
79
- var newConnection = {
80
- relation: {
81
- uri: 'relations/uri$$123',
82
- attributes: {},
83
- type: undefined
84
- },
85
- entity: null
86
- };
87
- var relatedEntity = {
88
- uri: 'entities/entity123',
89
- type: 'configuration/entityTypes/HCP'
90
- };
91
- var metadata = {
92
- uri: 'configuration',
93
- entityTypes: [
94
- {
95
- uri: 'configuration/entityTypes/HCP'
96
- },
97
- {
98
- uri: 'configuration/entityTypes/HCO'
99
- },
100
- {
101
- uri: 'configuration/entityTypes/Committee'
62
+ jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { getLookups: jest.fn(function () { return Promise.resolve(); }), getDependentLookups: jest.fn(function () { return Promise.resolve(); }), resolveLookupsList: jest.fn(function () { return Promise.resolve(); }), typeAheadSearch: jest.fn().mockReturnValue(Promise.resolve([])) })); });
63
+ describe('ConnectionEditor test', function () {
64
+ var newConnection = {
65
+ relation: {
66
+ uri: 'relations/uri$$123',
67
+ attributes: {},
68
+ type: undefined
102
69
  },
103
- {
104
- uri: 'configuration/entityTypes/Location'
105
- }
106
- ],
107
- relationTypes: [
108
- {
109
- uri: 'configuration/relationTypes/HeadNursing',
110
- label: 'Head of Nursing',
111
- startObject: {
112
- objectTypeURI: 'configuration/entityTypes/HCP',
113
- uri: 'configuration/relationTypes/HeadNursing/startObject'
70
+ entity: null
71
+ };
72
+ var relatedEntity = {
73
+ uri: 'entities/entity123',
74
+ type: 'configuration/entityTypes/HCP'
75
+ };
76
+ var metadata = {
77
+ uri: 'configuration',
78
+ entityTypes: [
79
+ {
80
+ uri: 'configuration/entityTypes/HCP',
81
+ label: 'HCP'
82
+ },
83
+ {
84
+ uri: 'configuration/entityTypes/HCO',
85
+ label: 'HCO'
114
86
  },
115
- endObject: {
116
- objectTypeURI: 'configuration/entityTypes/HCO',
117
- uri: 'configuration/relationTypes/HeadNursing/endObject'
87
+ {
88
+ uri: 'configuration/entityTypes/Committee',
89
+ label: 'Committee'
118
90
  },
119
- attributes: [
120
- {
121
- label: 'Affiliation SubType',
122
- name: 'AffiliationSubType',
123
- type: 'String',
124
- lookupCode: 'AFFILIATION_SUB_TYPE_CD',
125
- uri: 'configuration/relationTypes/HCPtoHCA/attributes/AffiliationSubType'
91
+ {
92
+ uri: 'configuration/entityTypes/Location',
93
+ label: 'Location'
94
+ }
95
+ ],
96
+ relationTypes: [
97
+ {
98
+ uri: 'configuration/relationTypes/HeadNursing',
99
+ label: 'Head of Nursing',
100
+ startObject: {
101
+ objectTypeURI: 'configuration/entityTypes/HCP',
102
+ uri: 'configuration/relationTypes/HeadNursing/startObject'
126
103
  },
127
- {
128
- label: 'Primary Affiliation Indicator',
129
- name: 'PrimaryAffiliationIndicator',
130
- type: 'Boolean',
131
- uri: 'configuration/relationTypes/HCPtoHCA/attributes/PrimaryAffiliationIndicator'
104
+ endObject: {
105
+ objectTypeURI: 'configuration/entityTypes/HCO',
106
+ uri: 'configuration/relationTypes/HeadNursing/endObject'
107
+ },
108
+ direction: 'directed',
109
+ attributes: [
110
+ {
111
+ label: 'Affiliation SubType',
112
+ name: 'AffiliationSubType',
113
+ type: 'String',
114
+ lookupCode: 'AFFILIATION_SUB_TYPE_CD',
115
+ uri: 'configuration/relationTypes/HCPtoHCA/attributes/AffiliationSubType'
116
+ },
117
+ {
118
+ label: 'First name',
119
+ name: 'FirstName',
120
+ type: 'String',
121
+ uri: 'configuration/relationTypes/HCPtoHCA/attributes/FirstName'
122
+ },
123
+ {
124
+ label: 'Primary Affiliation Indicator',
125
+ name: 'PrimaryAffiliationIndicator',
126
+ type: 'Boolean',
127
+ uri: 'configuration/relationTypes/HCPtoHCA/attributes/PrimaryAffiliationIndicator'
128
+ },
129
+ {
130
+ label: 'RelFirstLevelNested',
131
+ name: 'RelFirstLevelNested',
132
+ type: 'Nested',
133
+ uri: 'configuration/relationTypes/HCPtoHCA/attributes/RefFirstLevelNested',
134
+ attributes: [
135
+ {
136
+ label: 'FirstLevelNestedSub1',
137
+ name: 'FirstLevelNestedSub1',
138
+ type: 'String',
139
+ lookupCode: 'LANG_CD',
140
+ uri: 'configuration/relationTypes/HCPtoHCA/attributes/RefFirstLevelNested/attributes/FirstLevelNestedSub1'
141
+ }
142
+ ]
143
+ }
144
+ ]
145
+ },
146
+ {
147
+ uri: 'configuration/relationTypes/HasAddress',
148
+ label: 'has address',
149
+ startObject: {
150
+ objectTypeURI: 'configuration/entityTypes/HCP',
151
+ uri: 'configuration/relationTypes/HasAddress/startObject'
132
152
  },
133
- {
134
- label: 'RelFirstLevelNested',
135
- name: 'RelFirstLevelNested',
136
- type: 'Nested',
137
- uri: 'configuration/relationTypes/HCPtoHCA/attributes/RefFirstLevelNested',
138
- attributes: [
139
- {
140
- label: 'FirstLevelNestedSub1',
141
- name: 'FirstLevelNestedSub1',
142
- type: 'String',
143
- lookupCode: 'LANG_CD',
144
- uri: 'configuration/relationTypes/HCPtoHCA/attributes/RefFirstLevelNested/attributes/FirstLevelNestedSub1'
145
- }
146
- ]
153
+ endObject: {
154
+ objectTypeURI: 'configuration/entityTypes/Location',
155
+ uri: 'configuration/relationTypes/HasAddress/endObject'
147
156
  }
148
- ]
149
- },
150
- {
151
- uri: 'configuration/relationTypes/HasAddress',
152
- label: 'has address',
153
- startObject: {
154
- objectTypeURI: 'configuration/entityTypes/HCP',
155
- uri: 'configuration/relationTypes/HasAddress/startObject'
156
157
  },
157
- endObject: {
158
- objectTypeURI: 'configuration/entityTypes/Location',
159
- uri: 'configuration/relationTypes/HasAddress/endObject'
158
+ {
159
+ uri: 'configuration/relationTypes/IsInCommittee',
160
+ label: 'is in committee',
161
+ startObject: {
162
+ objectTypeURI: 'configuration/entityTypes/Committee',
163
+ uri: 'configuration/relationTypes/IsInCommittee/startObject'
164
+ },
165
+ endObject: {
166
+ objectTypeURI: 'configuration/entityTypes/HCP',
167
+ uri: 'configuration/relationTypes/IsInCommittee/endObject'
168
+ }
160
169
  }
161
- },
162
- {
163
- uri: 'configuration/relationTypes/IsInCommittee',
164
- label: 'is in committee',
165
- startObject: {
166
- objectTypeURI: 'configuration/entityTypes/Committee',
167
- uri: 'configuration/relationTypes/IsInCommittee/startObject'
170
+ ]
171
+ };
172
+ var inRelationTypes = [
173
+ __assign(__assign({}, metadata.relationTypes[2]), { startObject: __assign(__assign({}, metadata.relationTypes[2].startObject), { objectType: {
174
+ uri: 'configuration/entityTypes/HCP'
175
+ } }), endObject: __assign(__assign({}, metadata.relationTypes[2].endObject), { objectType: {
176
+ uri: 'configuration/entityTypes/HCO'
177
+ } }) })
178
+ ];
179
+ var outRelationTypes = [
180
+ __assign(__assign({}, metadata.relationTypes[0]), { startObject: __assign(__assign({}, metadata.relationTypes[0].startObject), { objectType: {
181
+ uri: 'configuration/entityTypes/HCP'
182
+ } }), endObject: __assign(__assign({}, metadata.relationTypes[0].endObject), { objectType: {
183
+ uri: 'configuration/entityTypes/HCO'
184
+ } }) }),
185
+ __assign(__assign({}, metadata.relationTypes[1]), { startObject: __assign(__assign({}, metadata.relationTypes[1].startObject), { objectType: {
186
+ uri: 'configuration/entityTypes/HCP'
187
+ } }), endObject: __assign(__assign({}, metadata.relationTypes[1].endObject), { objectType: {
188
+ uri: 'configuration/entityTypes/Location'
189
+ } }) })
190
+ ];
191
+ var initConnection = {
192
+ relation: {
193
+ attributes: {
194
+ FirstName: [
195
+ {
196
+ type: 'configuration/relationTypes/HCPtoHCA/attributes/FirstName',
197
+ ov: true,
198
+ value: 'HCP_5',
199
+ uri: 'relations/19oYeyx1/attributes/FirstName/1dg2njmxf'
200
+ }
201
+ ]
168
202
  },
169
- endObject: {
170
- objectTypeURI: 'configuration/entityTypes/HCP',
171
- uri: 'configuration/relationTypes/IsInCommittee/endObject'
172
- }
173
- }
174
- ]
175
- };
176
- var inRelationTypes = (_a = metadata.relationTypes) === null || _a === void 0 ? void 0 : _a.slice(2, 3);
177
- var outRelationTypes = (_b = metadata.relationTypes) === null || _b === void 0 ? void 0 : _b.slice(0, 2);
178
- var initConnection = {
179
- relation: {
180
- attributes: {
181
- FirstName: [
182
- {
183
- type: 'configuration/entityTypes/HCP/attributes/FirstName',
184
- ov: true,
185
- value: 'HCP_5',
186
- uri: 'entities/19oYeyx1/attributes/FirstName/1dg2njmxf'
187
- }
188
- ]
203
+ uri: 'relation/uri',
204
+ type: 'configuration/relationTypes/HeadNursing',
205
+ direction: 'out',
206
+ startDate: 123
189
207
  },
190
- uri: 'relation/uri',
191
- type: 'configuration/relationTypes/HeadNursing',
192
- direction: 'out',
193
- startDate: 123
194
- },
195
- entity: {
196
- type: 'configuration/entityTypes/HCO',
197
- uri: 'entities/uriHCO'
198
- }
199
- };
200
- var props = {
201
- onChangeAttribute: jest.fn(),
202
- onAddAttributes: jest.fn(),
203
- onRemoveAttribute: jest.fn(),
204
- showEmptyEditors: true
205
- };
206
- var mdmValues = {
207
- metadata: metadata,
208
- globalSearchRequestOptions: {}
209
- };
210
- var setUpMount = function (extraProps) {
211
- var Component = function (props) { return (react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { values: mdmValues },
212
- react_1.default.createElement(ConnectionEditor_1.ConnectionEditor, __assign({}, props)))); };
213
- return (0, enzyme_1.mount)(react_1.default.createElement(Component, __assign({}, props, extraProps)));
214
- };
215
- describe('ConnectionEditor test', function () {
208
+ entity: {
209
+ type: 'configuration/entityTypes/HCO',
210
+ uri: 'entities/uriHCO',
211
+ label: 'initRelationEntity'
212
+ }
213
+ };
214
+ var mdmValues = {
215
+ metadata: metadata,
216
+ globalSearchRequestOptions: {},
217
+ dependentLookups: { editors: {}, structure: {}, initedTypeUris: [] },
218
+ lookups: {}
219
+ };
220
+ var onChangeAttribute = jest.fn();
221
+ var onAddAttributes = jest.fn();
222
+ var onRemoveAttribute = jest.fn();
223
+ var onChangeRelationType = jest.fn();
224
+ var onChangeEntity = jest.fn();
225
+ var defaultProps = {
226
+ connection: initConnection,
227
+ onChangeAttribute: onChangeAttribute,
228
+ onAddAttributes: onAddAttributes,
229
+ onRemoveAttribute: onRemoveAttribute,
230
+ showEmptyEditors: true
231
+ };
232
+ var propsWithRelations = __assign(__assign({}, defaultProps), { connection: newConnection, relatedEntity: relatedEntity, inRelationTypes: inRelationTypes, outRelationTypes: outRelationTypes, onChangeRelationType: onChangeRelationType, onChangeEntity: onChangeEntity });
233
+ var setUp = function (props) {
234
+ if (props === void 0) { props = defaultProps; }
235
+ var Providers = function (_a) {
236
+ var children = _a.children;
237
+ return (react_1.default.createElement(LocalizationProvider_1.LocalizationProvider, { dateAdapter: AdapterMoment_1.AdapterMoment },
238
+ react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { values: mdmValues }, children)));
239
+ };
240
+ var user = user_event_1.default.setup();
241
+ return __assign({ user: user }, (0, react_2.render)(react_1.default.createElement(ConnectionEditor_1.ConnectionEditor, __assign({}, props)), { wrapper: Providers }));
242
+ };
243
+ afterEach(function () {
244
+ jest.clearAllMocks();
245
+ });
216
246
  it('should render EditModeAttributesList', function () {
217
- var _a;
218
- var component = setUpMount({ connection: initConnection });
219
- expect(component.find(EditModeAttributesList_1.EditModeAttributesList)).toHaveLength(1);
220
- expect(component.find(EditModeAttributesList_1.EditModeAttributesList).prop('attrTypes')).toEqual(__spreadArray(__spreadArray([], mdm_sdk_1.ACTIVENESS_ATTR_TYPES, true), (((_a = metadata.relationTypes) === null || _a === void 0 ? void 0 : _a[0].attributes) || []), true));
221
- expect(component.find(EditModeAttributesList_1.EditModeAttributesList).prop('entity')).toEqual({
222
- attributes: initConnection.relation.attributes,
223
- startDate: 123
224
- });
225
- expect(component.find(EditModeAttributesList_1.EditModeAttributesList).prop('showEmptyEditors')).toBe(true);
226
- expect(component.find(EditModeAttributesList_1.EditModeAttributesList).prop('mode')).toBe('Editing');
227
- expect(component.find(EditModeAttributesList_1.EditModeAttributesList).prop('parentUri')).toBe(initConnection.relation.uri);
228
- expect(component.find(EditModeAttributesList_1.EditModeAttributesList).prop('onAddAttributes')).toBe(props.onAddAttributes);
229
- expect(component.find(EditModeAttributesList_1.EditModeAttributesList).prop('onChangeAttribute')).toBe(props.onChangeAttribute);
230
- expect(component.find(EditModeAttributesList_1.EditModeAttributesList).prop('onDeleteAttribute')).toBe(props.onRemoveAttribute);
247
+ setUp();
248
+ expect(react_2.screen.queryByText('First name')).toBeInTheDocument();
249
+ expect(react_2.screen.queryAllByTestId('reltio-edit-attribute')).toHaveLength(6);
231
250
  });
251
+ it('should call onAddAttributes', function () { return __awaiter(void 0, void 0, void 0, function () {
252
+ var user;
253
+ return __generator(this, function (_a) {
254
+ switch (_a.label) {
255
+ case 0:
256
+ user = setUp().user;
257
+ return [4 /*yield*/, user.click(react_2.screen.getByRole('button', { name: 'More attributes' }))];
258
+ case 1:
259
+ _a.sent();
260
+ return [4 /*yield*/, user.click(react_2.screen.getByRole('menuitem', { name: 'First name' }))];
261
+ case 2:
262
+ _a.sent();
263
+ return [4 /*yield*/, user.click(react_2.screen.getByRole('presentation').firstChild)];
264
+ case 3:
265
+ _a.sent();
266
+ expect(onAddAttributes).toHaveBeenCalledWith([
267
+ { attributeType: metadata.relationTypes[0].attributes[1], parentUri: initConnection.relation.uri }
268
+ ]);
269
+ return [2 /*return*/];
270
+ }
271
+ });
272
+ }); });
273
+ it('should call onChangeAttribute', function () { return __awaiter(void 0, void 0, void 0, function () {
274
+ var user, firstNameValueInput;
275
+ return __generator(this, function (_a) {
276
+ switch (_a.label) {
277
+ case 0:
278
+ user = setUp().user;
279
+ firstNameValueInput = react_2.screen.getAllByRole('textbox')[2];
280
+ return [4 /*yield*/, user.type(firstNameValueInput, 'newValue{Enter}')];
281
+ case 1:
282
+ _a.sent();
283
+ expect(onChangeAttribute).toHaveBeenCalledWith({
284
+ attributeType: metadata.relationTypes[0].attributes[1],
285
+ uri: initConnection.relation.attributes.FirstName[0].uri,
286
+ value: 'HCP_5newValue'
287
+ });
288
+ return [2 /*return*/];
289
+ }
290
+ });
291
+ }); });
292
+ it('should call onRemoveAttribute', function () { return __awaiter(void 0, void 0, void 0, function () {
293
+ var user, firstNameDeleteButton;
294
+ return __generator(this, function (_a) {
295
+ switch (_a.label) {
296
+ case 0:
297
+ user = setUp().user;
298
+ firstNameDeleteButton = (0, test_utils_1.getMuiIconsByName)('Delete')[3];
299
+ return [4 /*yield*/, user.click(firstNameDeleteButton)];
300
+ case 1:
301
+ _a.sent();
302
+ expect(onRemoveAttribute).toHaveBeenCalledWith({
303
+ attributeType: metadata.relationTypes[0].attributes[1],
304
+ uri: initConnection.relation.attributes.FirstName[0].uri
305
+ });
306
+ return [2 /*return*/];
307
+ }
308
+ });
309
+ }); });
232
310
  it('should render ConnectionRelationTypeSelector and EntitySelector', function () {
233
- var props = {
234
- connection: initConnection,
235
- relatedEntity: relatedEntity,
236
- inRelationTypes: inRelationTypes,
237
- outRelationTypes: outRelationTypes,
238
- onChangeRelationType: jest.fn(),
239
- onChangeEntity: jest.fn()
240
- };
241
- var component = setUpMount(props);
242
- expect(component.find(ConnectionRelationTypeSelector_1.ConnectionRelationTypeSelector)).toHaveLength(1);
243
- expect(component.find(ErrorWrapper_1.ErrorWrapper)).toHaveLength(1);
244
- expect(component.find(EntitySelector_1.EntitySelector)).toHaveLength(1);
245
- var compatibleRelation = {
246
- relationType: initConnection.relation.type,
247
- direction: initConnection.relation.direction
248
- };
249
- expect(component.find(ConnectionRelationTypeSelector_1.ConnectionRelationTypeSelector).prop('relation')).toEqual(compatibleRelation);
250
- expect(component.find(EntitySelector_1.EntitySelector).prop('onChange')).toBe(props.onChangeEntity);
251
- var compatibleEntity = {
252
- entityUri: initConnection.entity.uri,
253
- entityType: initConnection.entity.type,
254
- entityLabel: '<No label>'
255
- };
256
- expect(component.find(EntitySelector_1.EntitySelector).prop('entity')).toEqual(compatibleEntity);
257
- expect(component.find(EntitySelector_1.EntitySelector).prop('entityTypesUris')).toEqual(['configuration/entityTypes/HCO']);
258
- });
259
- it('should set entityTypesUris prop for EntitySelector', function () {
260
- var props = {
261
- connection: newConnection,
262
- relatedEntity: relatedEntity,
263
- inRelationTypes: inRelationTypes,
264
- outRelationTypes: outRelationTypes,
265
- onChangeRelationType: jest.fn(),
266
- onChangeEntity: jest.fn()
267
- };
268
- var component = setUpMount(props);
269
- expect(component.find(EntitySelector_1.EntitySelector).prop('entityTypesUris')).toEqual([
270
- 'configuration/entityTypes/HCO',
271
- 'configuration/entityTypes/Location',
272
- 'configuration/entityTypes/Committee'
273
- ]);
311
+ setUp(__assign(__assign({}, propsWithRelations), { connection: initConnection }));
312
+ expect(react_2.screen.queryByText('Head of Nursing')).toBeInTheDocument();
313
+ expect(react_2.screen.queryByText('Select HCO profile')).toBeInTheDocument();
274
314
  });
315
+ it('should call onChangeEntity for EntitySelector', function () { return __awaiter(void 0, void 0, void 0, function () {
316
+ var newEntity, wrongEntity, user, profileSelector;
317
+ return __generator(this, function (_a) {
318
+ switch (_a.label) {
319
+ case 0:
320
+ newEntity = {
321
+ uri: 'entities/entityCommittee',
322
+ type: 'configuration/entityTypes/Committee',
323
+ label: 'Committee'
324
+ };
325
+ wrongEntity = {
326
+ uri: 'entities/wrongEntity',
327
+ type: 'configuration/entityTypes/HCP',
328
+ label: 'WrongEntity'
329
+ };
330
+ mdm_sdk_1.typeAheadSearch.mockResolvedValueOnce([newEntity]);
331
+ user = setUp(propsWithRelations).user;
332
+ profileSelector = react_2.screen.getAllByRole('textbox')[1];
333
+ return [4 /*yield*/, user.click(profileSelector)];
334
+ case 1:
335
+ _a.sent();
336
+ expect(react_2.screen.queryByText(wrongEntity.label)).not.toBeInTheDocument();
337
+ return [4 /*yield*/, user.click(react_2.screen.getByRole('menuitem', { name: 'C Committee' }))];
338
+ case 2:
339
+ _a.sent();
340
+ expect(onChangeEntity).toHaveBeenCalledWith(__assign(__assign({}, newEntity), { entityType: metadata.entityTypes[2] }));
341
+ return [2 /*return*/];
342
+ }
343
+ });
344
+ }); });
275
345
  it('should call onChangeRelationType for ConnectionRelationTypeSelector, if relation type was changed', function () { return __awaiter(void 0, void 0, void 0, function () {
276
- var onChangeRelationType, component, newRelationType;
346
+ var user, relationshipTypeSelector;
277
347
  return __generator(this, function (_a) {
278
- onChangeRelationType = jest.fn();
279
- component = setUpMount({
280
- connection: newConnection,
281
- relatedEntity: relatedEntity,
282
- inRelationTypes: inRelationTypes,
283
- outRelationTypes: outRelationTypes,
284
- onChangeRelationType: onChangeRelationType,
285
- onChangeEntity: jest.fn()
286
- });
287
- expect(onChangeRelationType).not.toHaveBeenCalledWith();
288
- newRelationType = {
289
- type: { uri: 'configuration/relationTypes/IsInCommittee' },
290
- direction: mdm_sdk_1.Directions.OUT
291
- };
292
- (0, test_utils_1.act)(function () {
293
- component.find(ConnectionRelationTypeSelector_1.ConnectionRelationTypeSelector).prop('onChange')(newRelationType);
294
- });
295
- component.update();
296
- expect(onChangeRelationType).toHaveBeenCalledWith({
297
- type: newRelationType.type.uri,
298
- direction: newRelationType.direction
299
- });
300
- return [2 /*return*/];
348
+ switch (_a.label) {
349
+ case 0:
350
+ user = setUp(propsWithRelations).user;
351
+ expect(onChangeRelationType).not.toHaveBeenCalled();
352
+ relationshipTypeSelector = react_2.screen.getAllByRole('textbox')[0];
353
+ return [4 /*yield*/, user.click(relationshipTypeSelector)];
354
+ case 1:
355
+ _a.sent();
356
+ return [4 /*yield*/, user.click(react_2.screen.getByRole('menuitem', { name: 'H L has address undefined ↔ undefined' }))];
357
+ case 2:
358
+ _a.sent();
359
+ expect(onChangeRelationType).toHaveBeenCalledWith({
360
+ direction: mdm_sdk_1.Directions.OUT,
361
+ type: 'configuration/relationTypes/HasAddress'
362
+ });
363
+ return [2 /*return*/];
364
+ }
301
365
  });
302
366
  }); });
303
367
  it('should call onChangeRelationType on mount for ConnectionRelationTypeSelector, if available relation type is only one', function () { return __awaiter(void 0, void 0, void 0, function () {
304
- var onChangeRelationType, component;
305
368
  return __generator(this, function (_a) {
306
- onChangeRelationType = jest.fn();
307
- component = setUpMount({
308
- connection: newConnection,
309
- relatedEntity: relatedEntity,
310
- inRelationTypes: inRelationTypes === null || inRelationTypes === void 0 ? void 0 : inRelationTypes.slice(0, 1),
311
- outRelationTypes: [],
312
- onChangeRelationType: onChangeRelationType,
313
- onChangeEntity: jest.fn()
314
- });
315
- expect(component.find(ConnectionRelationTypeSelector_1.ConnectionRelationTypeSelector)).toHaveLength(1);
369
+ setUp(__assign(__assign({}, propsWithRelations), { inRelationTypes: inRelationTypes === null || inRelationTypes === void 0 ? void 0 : inRelationTypes.slice(0, 1), outRelationTypes: [] }));
316
370
  expect(onChangeRelationType).toHaveBeenCalledWith({
317
371
  type: 'configuration/relationTypes/IsInCommittee',
318
- direction: 'in'
372
+ direction: mdm_sdk_1.Directions.IN
319
373
  });
320
374
  return [2 /*return*/];
321
375
  });
322
376
  }); });
323
377
  it('should call onChangeRelationType for ConnectionRelationTypeSelector, after entity selected and compatible relation type is only one', function () { return __awaiter(void 0, void 0, void 0, function () {
324
- var onChangeRelationType, component;
378
+ var rerender, newProps;
325
379
  return __generator(this, function (_a) {
326
- onChangeRelationType = jest.fn();
327
- component = setUpMount({
328
- connection: newConnection,
329
- relatedEntity: relatedEntity,
330
- inRelationTypes: inRelationTypes,
331
- outRelationTypes: outRelationTypes,
332
- onChangeRelationType: onChangeRelationType,
333
- onChangeEntity: jest.fn()
334
- });
335
- expect(component.find(ConnectionRelationTypeSelector_1.ConnectionRelationTypeSelector)).toHaveLength(1);
336
- component.setProps({
337
- connection: __assign(__assign({}, newConnection), { entity: {
380
+ rerender = setUp(propsWithRelations).rerender;
381
+ newProps = __assign(__assign({}, propsWithRelations), { connection: __assign(__assign({}, newConnection), { entity: {
338
382
  uri: 'entities/entityCommittee',
339
383
  type: 'configuration/entityTypes/Committee'
340
- } })
341
- });
342
- component.update();
384
+ } }) });
385
+ rerender(react_1.default.createElement(ConnectionEditor_1.ConnectionEditor, __assign({}, newProps)));
343
386
  expect(onChangeRelationType).toHaveBeenCalledWith({
344
387
  type: 'configuration/relationTypes/IsInCommittee',
345
388
  direction: 'in'
@@ -347,30 +390,4 @@ describe('ConnectionEditor test', function () {
347
390
  return [2 /*return*/];
348
391
  });
349
392
  }); });
350
- it('should call onChangeEntity for EntitySelector', function () { return __awaiter(void 0, void 0, void 0, function () {
351
- var onChangeEntity, component, newEntity;
352
- return __generator(this, function (_a) {
353
- onChangeEntity = jest.fn();
354
- component = setUpMount({
355
- connection: newConnection,
356
- relatedEntity: relatedEntity,
357
- inRelationTypes: inRelationTypes,
358
- outRelationTypes: outRelationTypes,
359
- onChangeRelationType: jest.fn(),
360
- onChangeEntity: onChangeEntity
361
- });
362
- newEntity = {
363
- uri: 'entities/entityCommittee',
364
- type: 'configuration/entityTypes/Committee',
365
- label: 'Committee',
366
- entityType: { uri: 'configuration/entityTypes/Committee' }
367
- };
368
- (0, test_utils_1.act)(function () {
369
- component.find(EntitySelector_1.EntitySelector).prop('onChange')(newEntity);
370
- });
371
- component.update();
372
- expect(onChangeEntity).toHaveBeenCalledWith(newEntity);
373
- return [2 /*return*/];
374
- });
375
- }); });
376
393
  });