@reltio/components 1.4.1906 → 1.4.1908

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