@reltio/components 1.4.2027 → 1.4.2029

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 (69) hide show
  1. package/cjs/features/crosswalks/CrosswalkRow/DndCrosswalkRow.test.js +0 -1
  2. package/cjs/features/graph/SigmaGraphContainer/SigmaGraphContainer.test.js +5 -14
  3. package/cjs/features/graph/SigmaGraphResizer/SigmaGraphResizer.test.js +11 -9
  4. package/cjs/features/graph/ZoomSlider/ZoomSlider.js +2 -2
  5. package/cjs/features/graph/ZoomSlider/ZoomSlider.test.js +85 -37
  6. package/cjs/features/history/DateRangeSelector/DateRangeSelector.specs.js +188 -117
  7. package/cjs/features/history/HistoryFilterButton/HistoryFilterButton.js +1 -1
  8. package/cjs/features/history/HistoryGraph/components/HistoryCircle/HistoryCircle.specs.js +38 -41
  9. package/cjs/features/history/HistoryGraph/components/HistoryLink/HistoryLink.specs.js +17 -16
  10. package/cjs/features/history/HistoryHeader/HistoryHeader.spec.js +21 -31
  11. package/cjs/features/history/HistoryPanelEmptyState/HistoryPanelEmptyState.specs.js +4 -9
  12. package/cjs/features/history/HistoryRow/HistoryRow.js +1 -1
  13. package/cjs/features/history/HistoryRow/HistoryRow.specs.js +74 -34
  14. package/cjs/features/history/HistoryTree/HistoryTree.js +1 -1
  15. package/cjs/features/history/HistoryView/HistoryView.specs.js +77 -43
  16. package/cjs/features/workflow/AddWorkflowButton/AddWorkflowButton.spec.js +83 -34
  17. package/cjs/features/workflow/AddWorkflowDialog/AddWorkflowDialog.spec.js +20 -0
  18. package/cjs/features/workflow/AttributesChanges/AttributesChanges.js +1 -1
  19. package/cjs/features/workflow/AttributesChanges/components/ChangeView/ChangeView.js +1 -1
  20. package/cjs/features/workflow/AttributesChanges/components/ShowMoreLink/ShowMoreLink.spec.js +81 -24
  21. package/cjs/features/workflow/DueDateField/DueDateField.spec.js +51 -102
  22. package/cjs/features/workflow/PrioritySelector/PrioritySelector.spec.js +62 -133
  23. package/cjs/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.spec.js +438 -124
  24. package/cjs/features/workflow/hooks/useChangeRequest.specs.js +17 -27
  25. package/cjs/features/workflow/hooks/useWorkflowColor.specs.js +23 -47
  26. package/cjs/features/workflow/hooks/useWorkflowDefinitions.js +5 -1
  27. package/features/crosswalks/CrosswalkRow/DndCrosswalkRow.test.js +0 -1
  28. package/features/graph/SigmaGraphContainer/SigmaGraphContainer.test.js +5 -14
  29. package/features/graph/SigmaGraphResizer/SigmaGraphResizer.test.js +11 -9
  30. package/features/graph/ZoomSlider/ZoomSlider.js +2 -2
  31. package/features/graph/ZoomSlider/ZoomSlider.test.js +85 -37
  32. package/features/history/DateRangeSelector/DateRangeSelector.specs.js +188 -117
  33. package/features/history/HistoryFilterButton/HistoryFilterButton.js +1 -1
  34. package/features/history/HistoryGraph/components/HistoryCircle/HistoryCircle.specs.js +38 -41
  35. package/features/history/HistoryGraph/components/HistoryLink/HistoryLink.specs.js +17 -16
  36. package/features/history/HistoryHeader/HistoryHeader.spec.js +21 -31
  37. package/features/history/HistoryPanelEmptyState/HistoryPanelEmptyState.specs.js +4 -9
  38. package/features/history/HistoryRow/HistoryRow.js +1 -1
  39. package/features/history/HistoryRow/HistoryRow.specs.js +74 -34
  40. package/features/history/HistoryTree/HistoryTree.js +1 -1
  41. package/features/history/HistoryView/HistoryView.specs.js +77 -43
  42. package/features/workflow/AddWorkflowButton/AddWorkflowButton.spec.js +83 -34
  43. package/features/workflow/AddWorkflowDialog/AddWorkflowDialog.spec.js +20 -0
  44. package/features/workflow/AttributesChanges/AttributesChanges.js +1 -1
  45. package/features/workflow/AttributesChanges/components/ChangeView/ChangeView.js +1 -1
  46. package/features/workflow/AttributesChanges/components/ShowMoreLink/ShowMoreLink.spec.js +81 -24
  47. package/features/workflow/DueDateField/DueDateField.spec.js +51 -102
  48. package/features/workflow/PrioritySelector/PrioritySelector.spec.js +62 -133
  49. package/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.spec.js +439 -125
  50. package/features/workflow/hooks/useChangeRequest.specs.js +17 -24
  51. package/features/workflow/hooks/useWorkflowColor.specs.js +23 -44
  52. package/features/workflow/hooks/useWorkflowDefinitions.js +5 -1
  53. package/package.json +1 -1
  54. package/cjs/features/workflow/AttributesChanges/AttributesChanges.spec.d.ts +0 -1
  55. package/cjs/features/workflow/AttributesChanges/AttributesChanges.spec.js +0 -249
  56. package/cjs/features/workflow/AttributesChanges/components/ChangeView/ChangeView.spec.d.ts +0 -1
  57. package/cjs/features/workflow/AttributesChanges/components/ChangeView/ChangeView.spec.js +0 -44
  58. package/cjs/features/workflow/AttributesChanges/components/DCRChangesList/DCRChangesList.spec.d.ts +0 -1
  59. package/cjs/features/workflow/AttributesChanges/components/DCRChangesList/DCRChangesList.spec.js +0 -38
  60. package/cjs/features/workflow/AttributesChanges/components/DiffRenderer/DiffRenderer.spec.d.ts +0 -1
  61. package/cjs/features/workflow/AttributesChanges/components/DiffRenderer/DiffRenderer.spec.js +0 -218
  62. package/features/workflow/AttributesChanges/AttributesChanges.spec.d.ts +0 -1
  63. package/features/workflow/AttributesChanges/AttributesChanges.spec.js +0 -244
  64. package/features/workflow/AttributesChanges/components/ChangeView/ChangeView.spec.d.ts +0 -1
  65. package/features/workflow/AttributesChanges/components/ChangeView/ChangeView.spec.js +0 -39
  66. package/features/workflow/AttributesChanges/components/DCRChangesList/DCRChangesList.spec.d.ts +0 -1
  67. package/features/workflow/AttributesChanges/components/DCRChangesList/DCRChangesList.spec.js +0 -33
  68. package/features/workflow/AttributesChanges/components/DiffRenderer/DiffRenderer.spec.d.ts +0 -1
  69. package/features/workflow/AttributesChanges/components/DiffRenderer/DiffRenderer.spec.js +0 -213
@@ -45,153 +45,467 @@ 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
+ };
48
57
  import React from 'react';
49
- import { mount } from 'enzyme';
50
- import { act } from 'react-dom/test-utils';
51
- import { getDataChangeRequest } from '@reltio/mdm-sdk';
52
- import { GenericWorkflowTaskCard } from '../GenericWorkflowTaskCard';
53
- import DcrTaskIcon from '../../../../../icons/DcrTaskIcon';
54
- import { LineDecorator } from '../../../LineDecorator';
55
- import { AttributesChanges } from '../../../AttributesChanges';
58
+ import { render, screen, within } from '@testing-library/react';
59
+ import userEvent from '@testing-library/user-event';
60
+ import moment from 'moment';
61
+ import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
62
+ import { AdapterMoment } from '@mui/x-date-pickers/AdapterMoment';
63
+ import { DCROperationTypes, DCRTypes, getDataChangeRequest, getEntitiesByUris } from '@reltio/mdm-sdk';
64
+ import { useMdmMetadata } from '../../../../../contexts/MdmModuleContext';
56
65
  import { DataChangeRequestTaskCard } from './DataChangeRequestTaskCard';
57
- jest.mock('../GenericWorkflowTaskCard', function () { return ({
58
- // eslint-disable-next-line
59
- GenericWorkflowTaskCard: function (_a) {
60
- var children = _a.children;
61
- return React.createElement("div", null, children);
62
- }
63
- }); });
64
- jest.mock('../../../AttributesChanges', function () { return ({
65
- // eslint-disable-next-line
66
- AttributesChanges: function (_a) {
67
- var children = _a.children;
68
- return React.createElement("div", null, children);
69
- }
70
- }); });
71
- jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { getDataChangeRequest: jest.fn() })); });
66
+ jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { getDataChangeRequest: jest.fn(), getEntitiesByUris: jest.fn() })); });
67
+ jest.mock('../../../../../contexts/MdmModuleContext', function () { return (__assign(__assign({}, jest.requireActual('../../../../../contexts/MdmModuleContext')), { useMdmMetadata: jest.fn() })); });
72
68
  describe('DataChangeRequestTaskCard tests', function () {
69
+ var _a, _b;
70
+ var metadata = {
71
+ entityTypes: [
72
+ {
73
+ uri: 'configuration/entityTypes/Company',
74
+ label: 'Company',
75
+ description: 'Company',
76
+ extendsTypeURI: 'configuration/entityTypes/Organization',
77
+ attributes: [
78
+ {
79
+ label: 'Activation Date',
80
+ name: 'ActivationDate',
81
+ type: 'String',
82
+ uri: 'configuration/entityTypes/Company/attributes/ActivationDate'
83
+ },
84
+ {
85
+ label: 'Name',
86
+ name: 'Name',
87
+ type: 'String',
88
+ uri: 'configuration/entityTypes/Company/attributes/Name'
89
+ },
90
+ {
91
+ dependentLookupCode: 'COUNTRY_CD',
92
+ label: 'Country Code',
93
+ name: 'CountryCode',
94
+ type: 'String',
95
+ uri: 'configuration/entityTypes/Company/attributes/CountryCode'
96
+ },
97
+ {
98
+ label: 'Address',
99
+ name: 'Address',
100
+ type: 'Reference',
101
+ uri: 'configuration/entityTypes/Company/attributes/Address',
102
+ referencedAttributeURIs: ['configuration/entityTypes/Location/attributes/City'],
103
+ referencedEntityTypeURI: 'configuration/entityTypes/Location'
104
+ },
105
+ {
106
+ label: 'NestedFirstLevel',
107
+ name: 'NestedFirstLevel',
108
+ type: 'Nested',
109
+ uri: 'configuration/entityTypes/Company/attributes/NestedFirstLevel',
110
+ attributes: [
111
+ {
112
+ label: 'NestedSecondLevel',
113
+ name: 'NestedSecondLevel',
114
+ type: 'Nested',
115
+ uri: 'configuration/entityTypes/Company/attributes/NestedFirstLevel/attributes/NestedSecondLevel',
116
+ attributes: [
117
+ {
118
+ label: 'FifthLevelSimple4',
119
+ name: 'FifthLevelSimple4',
120
+ type: 'String',
121
+ uri: 'configuration/entityTypes/Company/attributes/NestedFirstLevel/attributes/NestedSecondLevel/attributes/FifthLevelSimple4'
122
+ },
123
+ {
124
+ label: 'FifthLevelSimple5',
125
+ name: 'FifthLevelSimple5',
126
+ type: 'String',
127
+ uri: 'configuration/entityTypes/Company/attributes/NestedFirstLevel/attributes/NestedSecondLevel/attributes/FifthLevelSimple5'
128
+ }
129
+ ]
130
+ }
131
+ ]
132
+ }
133
+ ],
134
+ abstract: false
135
+ },
136
+ {
137
+ uri: 'configuration/entityTypes/Location',
138
+ label: 'Address',
139
+ attributes: [
140
+ {
141
+ label: 'City',
142
+ name: 'City',
143
+ type: 'String',
144
+ uri: 'configuration/entityTypes/Location/attributes/City'
145
+ }
146
+ ],
147
+ abstract: false
148
+ }
149
+ ],
150
+ relationTypes: [
151
+ {
152
+ uri: 'configuration/relationTypes/Managed',
153
+ label: 'Managed',
154
+ startObject: {
155
+ uri: 'configuration/relationTypes/Managed/startObject',
156
+ objectTypeURI: 'configuration/entityTypes/Company'
157
+ },
158
+ endObject: {
159
+ uri: 'configuration/relationTypes/Managed/endObject',
160
+ objectTypeURI: 'configuration/entityTypes/Company'
161
+ },
162
+ attributes: [],
163
+ direction: 'directed'
164
+ }
165
+ ]
166
+ };
167
+ var entityUri = 'entities/00COBWl';
168
+ var relationUri = 'relations/07VxtSE';
169
+ var userName = 'eugeny.sokolov';
170
+ var priorityClass = 'Medium';
171
+ var displayName = 'DCR Review';
172
+ var processDefinitionDisplayName = 'Data Change Request Review';
173
+ var dcrId = '0kCnzFE';
174
+ var dcrUri = "changeRequests/".concat(dcrId);
175
+ var dueDate = 1731825314640;
176
+ var newStartDate = moment('11/15/2024', 'MM/DD/YYYY').valueOf();
73
177
  var task = {
74
- assignee: 'egorshkov',
75
- objectURIs: ['changeRequests/123', 'entities/1RdgehCi'],
76
- createdBy: 'egorshkov',
77
- priorityClass: 'Urgent',
78
- taskType: 'deleteReview',
79
- createTime: 1642148700046,
80
- dueDate: 1642878000000,
81
- taskId: '29931552',
82
- displayName: 'Delete Review',
83
- processDefinitionDisplayName: 'Recommend for Delete'
178
+ assignee: userName,
179
+ processInstanceId: '60260030',
180
+ processType: 'dataChangeRequestReview',
181
+ objectURIs: [dcrUri, entityUri, relationUri],
182
+ suspended: false,
183
+ createdBy: userName,
184
+ priorityClass: priorityClass,
185
+ taskType: 'dcrReview',
186
+ createTime: 1731652514639,
187
+ dueDate: dueDate,
188
+ taskId: '60260042',
189
+ displayName: displayName,
190
+ processDefinitionDisplayName: processDefinitionDisplayName
191
+ };
192
+ var entityLabel = 'EntityLabel';
193
+ var relationEntityLabel = 'RelationEntityLabel';
194
+ var refEntityLabel = 'RefEntityLabel';
195
+ var oldNameValue = 'oldNameValue';
196
+ var newNameValue = 'newNameValue';
197
+ var dcr = {
198
+ uri: 'changeRequests/0kCnzFE',
199
+ createdBy: userName,
200
+ createdTime: 1731652509123,
201
+ updatedBy: userName,
202
+ updatedTime: 1731652511713,
203
+ changes: (_a = {},
204
+ _a[entityUri] = [
205
+ {
206
+ id: '0kCo7lk',
207
+ type: DCRTypes.UPDATE_ATTRIBUTE,
208
+ createdTime: 1731652511713,
209
+ createdBy: userName,
210
+ attributePath: 'Name/xhGw4BJ',
211
+ oldValue: {
212
+ value: oldNameValue
213
+ },
214
+ newValue: {
215
+ value: newNameValue
216
+ },
217
+ attributeType: 'configuration/entityTypes/Company/attributes/Name'
218
+ }
219
+ ],
220
+ _a[relationUri] = [
221
+ {
222
+ id: '0kCnuyy',
223
+ type: DCRTypes.UPDATE_START_DATE,
224
+ createdTime: 1731652509123,
225
+ createdBy: userName,
226
+ newValue: [newStartDate]
227
+ }
228
+ ],
229
+ _a),
230
+ objectsInfo: (_b = {},
231
+ _b[entityUri] = {
232
+ type: 'configuration/entityTypes/Company',
233
+ label: entityLabel
234
+ },
235
+ _b[relationUri] = {
236
+ type: 'configuration/relationTypes/Managed',
237
+ startObjectUri: 'entities/07AWt2z',
238
+ startObjectLabel: relationEntityLabel,
239
+ endObjectUri: entityUri,
240
+ endObjectLabel: entityLabel
241
+ },
242
+ _b['entities/19emZkLd'] = {
243
+ type: 'configuration/entityTypes/Location',
244
+ label: refEntityLabel
245
+ },
246
+ _b),
247
+ type: 'configuration/changeRequestTypes/default',
248
+ state: 'AWAITING_REVIEW'
249
+ };
250
+ var entities = [
251
+ {
252
+ uri: 'entities/07AWt2z',
253
+ type: 'configuration/entityTypes/Company',
254
+ label: relationEntityLabel
255
+ }
256
+ ];
257
+ var setUp = function () {
258
+ var user = userEvent.setup();
259
+ var Providers = function (_a) {
260
+ var children = _a.children;
261
+ return (React.createElement(LocalizationProvider, { dateAdapter: AdapterMoment }, children));
262
+ };
263
+ return __assign(__assign({}, render(React.createElement(DataChangeRequestTaskCard, { task: task }), { wrapper: Providers })), { user: user });
84
264
  };
85
- var resolveGetDataChangeRequest;
86
265
  beforeAll(function () {
87
- getDataChangeRequest.mockImplementation(function () {
88
- return new Promise(function (resolve) {
89
- resolveGetDataChangeRequest = function (dcr) { return resolve(dcr); };
90
- });
91
- });
266
+ getEntitiesByUris.mockResolvedValue(entities);
267
+ });
268
+ beforeEach(function () {
269
+ useMdmMetadata.mockReturnValue(metadata);
92
270
  });
93
271
  afterEach(function () {
94
272
  jest.clearAllMocks();
95
273
  });
96
274
  it('should render main parts', function () { return __awaiter(void 0, void 0, void 0, function () {
97
- var dcr, component;
275
+ var user, changesContainers;
98
276
  return __generator(this, function (_a) {
99
277
  switch (_a.label) {
100
278
  case 0:
101
- dcr = {
102
- changes: {
103
- 'entities/1': []
104
- },
105
- objectsInfo: {
106
- 'entities/1': {}
107
- }
108
- };
109
- component = mount(React.createElement(DataChangeRequestTaskCard, { task: task }));
110
- expect(component.find(GenericWorkflowTaskCard).length).toBe(1);
111
- expect(component.find(GenericWorkflowTaskCard).props()).toMatchObject({
112
- task: task,
113
- Icon: DcrTaskIcon
114
- });
115
- expect(component.find(GenericWorkflowTaskCard).length).toBe(1);
116
- expect(component.find(LineDecorator).length).toBe(0);
117
- expect(component.find('AttributesChanges').length).toBe(0);
118
- return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
119
- return __generator(this, function (_a) {
120
- resolveGetDataChangeRequest(dcr);
121
- return [2 /*return*/];
122
- });
123
- }); })];
279
+ getDataChangeRequest.mockResolvedValue(dcr);
280
+ user = setUp().user;
281
+ expect(screen.getByTestId('SvgDcrTaskIcon')).toBeInTheDocument();
282
+ expect(screen.getByText(processDefinitionDisplayName)).toBeInTheDocument();
283
+ expect(screen.getByText(moment(dueDate).format('MM/DD/YYYY'))).toBeInTheDocument();
284
+ expect(screen.getByText(dcrId)).toBeInTheDocument();
285
+ expect(screen.getByText(userName)).toBeInTheDocument();
286
+ expect(screen.getByText(displayName)).toBeInTheDocument();
287
+ return [4 /*yield*/, user.click(screen.getByTestId('collapse-button'))];
124
288
  case 1:
125
289
  _a.sent();
126
- component.update();
127
- expect(component.find(GenericWorkflowTaskCard).length).toBe(1);
128
- expect(component.find(LineDecorator).length).toBe(1);
129
- expect(component.find(LineDecorator).prop('last')).toBe(true);
130
- expect(component.find(LineDecorator).find(AttributesChanges).length).toBe(1);
131
- expect(component.find(LineDecorator).find(AttributesChanges).props()).toMatchObject({
132
- entityInfo: { uri: 'entities/1' },
133
- relationsInfo: [],
134
- changes: dcr.changes,
135
- objectsInfo: dcr.objectsInfo,
136
- dcrUri: task.objectURIs[0]
137
- });
290
+ changesContainers = screen.getAllByTestId('changes-container');
291
+ expect(changesContainers).toHaveLength(2);
292
+ expect(within(changesContainers[0]).getByText('Name')).toBeInTheDocument();
293
+ expect(within(changesContainers[0]).getByText(entityLabel)).toBeInTheDocument();
294
+ expect(within(changesContainers[0]).getByText(new RegExp("^".concat(oldNameValue, ".*").concat(newNameValue, "$")))).toBeInTheDocument();
295
+ expect(within(changesContainers[0]).getByTestId('arrow-right')).toBeInTheDocument();
296
+ expect(within(changesContainers[0]).getByText(DCROperationTypes.EDITED)).toBeInTheDocument();
297
+ expect(within(changesContainers[1]).getByText(relationEntityLabel)).toBeInTheDocument();
298
+ expect(within(changesContainers[1]).getByText('Relationships')).toBeInTheDocument();
299
+ expect(within(changesContainers[1]).getByText('Managed')).toBeInTheDocument();
300
+ expect(within(changesContainers[1]).getByText(entityLabel)).toBeInTheDocument();
301
+ expect(within(changesContainers[1]).getByText('Start date')).toBeInTheDocument();
302
+ expect(within(changesContainers[1]).getByText(moment(newStartDate).format('MM/DD/YYYY'))).toBeInTheDocument();
303
+ expect(within(changesContainers[1]).getByText(DCROperationTypes.ADDED)).toBeInTheDocument();
304
+ expect(within(changesContainers[1]).queryByTestId('arrow-right')).not.toBeInTheDocument();
138
305
  return [2 /*return*/];
139
306
  }
140
307
  });
141
308
  }); });
142
- it('should render main parts with several AttributesChanges', function () { return __awaiter(void 0, void 0, void 0, function () {
143
- var dcr, component, lineDecorators, attributeChangesPanels;
144
- return __generator(this, function (_a) {
145
- switch (_a.label) {
309
+ it('should work correctly with nested attributes', function () { return __awaiter(void 0, void 0, void 0, function () {
310
+ var nestedAttrName, subNestedAttrName, subSubNestedAttr1, addedNestedValue, changedWithNested, dcrWithNested, user;
311
+ var _a, _b;
312
+ return __generator(this, function (_c) {
313
+ switch (_c.label) {
146
314
  case 0:
147
- dcr = {
148
- changes: {
149
- 'entities/1': [{ id: '3K9w4sys', type: 'CREATE_ENTITY' }],
150
- 'relations/1': [{ id: '3K9w51VO', type: 'INSERT_ATTRIBUTE' }]
151
- },
152
- objectsInfo: {
153
- 'entities/1': {},
154
- 'entities/2': {},
155
- 'relations/1': { startObjectUri: 'entities/2' }
156
- }
157
- };
158
- component = mount(React.createElement(DataChangeRequestTaskCard, { task: task }));
159
- expect(component.find(GenericWorkflowTaskCard).length).toBe(1);
160
- expect(component.find(GenericWorkflowTaskCard).props()).toMatchObject({
161
- task: task,
162
- Icon: DcrTaskIcon
163
- });
164
- expect(component.find(GenericWorkflowTaskCard).length).toBe(1);
165
- expect(component.find(LineDecorator).length).toBe(0);
166
- expect(component.find('AttributesChanges').length).toBe(0);
167
- return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
168
- return __generator(this, function (_a) {
169
- resolveGetDataChangeRequest(dcr);
170
- return [2 /*return*/];
171
- });
172
- }); })];
315
+ nestedAttrName = 'NestedFirstLevel';
316
+ subNestedAttrName = 'NestedSecondLevel';
317
+ subSubNestedAttr1 = 'FifthLevelSimple4';
318
+ addedNestedValue = 'addedNestedValue';
319
+ changedWithNested = (_a = {},
320
+ _a[entityUri] = [
321
+ {
322
+ id: '0kCoGIG',
323
+ type: DCRTypes.INSERT_ATTRIBUTE,
324
+ createdTime: 1731652511713,
325
+ createdBy: userName,
326
+ attributePath: nestedAttrName,
327
+ newValue: {
328
+ value: (_b = {},
329
+ _b[subNestedAttrName] = [
330
+ {
331
+ value: {
332
+ FifthLevelSimple4: [
333
+ {
334
+ value: addedNestedValue
335
+ }
336
+ ]
337
+ }
338
+ }
339
+ ],
340
+ _b)
341
+ },
342
+ attributeType: 'configuration/entityTypes/Company/attributes/NestedFirstLevel'
343
+ }
344
+ ],
345
+ _a);
346
+ dcrWithNested = __assign(__assign({}, dcr), { changes: changedWithNested });
347
+ getDataChangeRequest.mockResolvedValue(dcrWithNested);
348
+ user = setUp().user;
349
+ return [4 /*yield*/, user.click(screen.getByTestId('collapse-button'))];
173
350
  case 1:
174
- _a.sent();
175
- component.update();
176
- expect(component.find(GenericWorkflowTaskCard).length).toBe(1);
177
- lineDecorators = component.find(LineDecorator);
178
- expect(lineDecorators.length).toBe(2);
179
- expect(lineDecorators.at(0).prop('last')).toBe(false);
180
- expect(lineDecorators.at(1).prop('last')).toBe(true);
181
- attributeChangesPanels = component.find(AttributesChanges);
182
- expect(attributeChangesPanels.length).toBe(2);
183
- expect(attributeChangesPanels.at(0).props()).toMatchObject({
184
- entityInfo: { uri: 'entities/1' },
185
- relationsInfo: [],
186
- changes: dcr.changes,
187
- objectsInfo: dcr.objectsInfo
188
- });
189
- expect(attributeChangesPanels.at(1).props()).toMatchObject({
190
- entityInfo: { uri: 'entities/2' },
191
- relationsInfo: [{ startObjectUri: 'entities/2' }],
192
- changes: dcr.changes,
193
- objectsInfo: dcr.objectsInfo
194
- });
351
+ _c.sent();
352
+ expect(screen.getByText(nestedAttrName)).toBeInTheDocument();
353
+ expect(screen.getByText(subNestedAttrName)).toBeInTheDocument();
354
+ expect(screen.getByText(subSubNestedAttr1)).toBeInTheDocument();
355
+ expect(screen.getByText(DCROperationTypes.ADDED)).toBeInTheDocument();
356
+ expect(screen.queryByTestId('arrow-right')).not.toBeInTheDocument();
357
+ return [2 /*return*/];
358
+ }
359
+ });
360
+ }); });
361
+ it('should work correctly with reference attributes', function () { return __awaiter(void 0, void 0, void 0, function () {
362
+ var attributePath, refAttributeName, addedRefValue, changedWithRef, dcrWithRef, user;
363
+ var _a;
364
+ return __generator(this, function (_b) {
365
+ switch (_b.label) {
366
+ case 0:
367
+ attributePath = 'Address';
368
+ refAttributeName = 'City';
369
+ addedRefValue = 'addedRefValue';
370
+ changedWithRef = (_a = {},
371
+ _a[entityUri] = [
372
+ {
373
+ id: '0kCoC20',
374
+ type: DCRTypes.INSERT_ATTRIBUTE,
375
+ createdTime: 1731652511713,
376
+ createdBy: 'eugeny.sokolov',
377
+ attributePath: attributePath,
378
+ newValue: {
379
+ value: {
380
+ City: [
381
+ {
382
+ value: addedRefValue
383
+ }
384
+ ]
385
+ },
386
+ refEntity: {
387
+ objectURI: 'entities/19emZkLd'
388
+ }
389
+ },
390
+ attributeType: 'configuration/entityTypes/Company/attributes/Address'
391
+ }
392
+ ],
393
+ _a);
394
+ dcrWithRef = __assign(__assign({}, dcr), { changes: changedWithRef });
395
+ getDataChangeRequest.mockResolvedValue(dcrWithRef);
396
+ user = setUp().user;
397
+ return [4 /*yield*/, user.click(screen.getByTestId('collapse-button'))];
398
+ case 1:
399
+ _b.sent();
400
+ expect(screen.getByText(attributePath)).toBeInTheDocument();
401
+ expect(screen.getByText(refAttributeName)).toBeInTheDocument();
402
+ expect(screen.getByText(refEntityLabel)).toBeInTheDocument();
403
+ expect(screen.getByText(addedRefValue)).toBeInTheDocument();
404
+ expect(screen.getByText(DCROperationTypes.ADDED)).toBeInTheDocument();
405
+ expect(screen.queryByTestId('arrow-right')).not.toBeInTheDocument();
406
+ return [2 /*return*/];
407
+ }
408
+ });
409
+ }); });
410
+ it('should render ShowMoreLink if length of merged changes more than 3', function () { return __awaiter(void 0, void 0, void 0, function () {
411
+ var bigChanges, dcrWithBigChanges, user;
412
+ var _a;
413
+ return __generator(this, function (_b) {
414
+ switch (_b.label) {
415
+ case 0:
416
+ bigChanges = (_a = {},
417
+ _a[entityUri] = __spreadArray(__spreadArray([], dcr.changes[entityUri], true), [
418
+ {
419
+ attributePath: 'CountryCode',
420
+ attributeType: 'configuration/entityTypes/Company/attributes/CountryCode',
421
+ id: '41cb3c0i',
422
+ newValue: { value: 'Bahamas', lookupCode: 'BS', lookupRawValue: 'BS', pin: true },
423
+ type: DCRTypes.INSERT_ATTRIBUTE
424
+ },
425
+ {
426
+ attributePath: 'ActivationDate',
427
+ attributeType: 'configuration/entityTypes/Company/attributes/ActivationDate',
428
+ id: '41cb3t3k',
429
+ newValue: { value: '12.10.2011' },
430
+ type: DCRTypes.INSERT_ATTRIBUTE
431
+ },
432
+ {
433
+ attributePath: 'CountryCode/3AqlrpfGa',
434
+ attributeType: 'configuration/entityTypes/Company/attributes/CountryCode',
435
+ id: '41cb3gGy',
436
+ newValue: { value: 'Chile', lookupCode: 'CL', lookupRawValue: 'Chile', pin: true },
437
+ oldValue: { value: 'Chile', lookupCode: 'CL', lookupRawValue: 'Chile', pin: true },
438
+ type: DCRTypes.IGNORE_ATTRIBUTE
439
+ }
440
+ ], false),
441
+ _a);
442
+ dcrWithBigChanges = __assign(__assign({}, dcr), { changes: bigChanges });
443
+ getDataChangeRequest.mockResolvedValue(dcrWithBigChanges);
444
+ user = setUp().user;
445
+ return [4 /*yield*/, user.click(screen.getByTestId('collapse-button'))];
446
+ case 1:
447
+ _b.sent();
448
+ expect(screen.getByText('Country Code')).toBeInTheDocument();
449
+ expect(screen.getByText('Bahamas (BS)')).toBeInTheDocument();
450
+ expect(screen.getByText('Activation Date')).toBeInTheDocument();
451
+ expect(screen.getByText('12.10.2011')).toBeInTheDocument();
452
+ expect(screen.getByText('Name')).toBeInTheDocument();
453
+ expect(screen.queryByText('Chile (CL)')).not.toBeInTheDocument();
454
+ return [4 /*yield*/, user.click(screen.getByText('View 1 more suggestions'))];
455
+ case 2:
456
+ _b.sent();
457
+ expect(screen.getByText('Chile (CL)')).toBeInTheDocument();
458
+ return [4 /*yield*/, user.click(screen.getByText('View less suggestions'))];
459
+ case 3:
460
+ _b.sent();
461
+ expect(screen.queryByText('Chile (CL)')).not.toBeInTheDocument();
462
+ return [2 /*return*/];
463
+ }
464
+ });
465
+ }); });
466
+ it('should create correct link for new entity', function () { return __awaiter(void 0, void 0, void 0, function () {
467
+ var changesWithNewEntity, dcrWithNewEntity, user, linkElement, href;
468
+ var _a;
469
+ return __generator(this, function (_b) {
470
+ switch (_b.label) {
471
+ case 0:
472
+ changesWithNewEntity = (_a = {},
473
+ _a[entityUri] = [
474
+ {
475
+ id: '3aMaA7ds',
476
+ type: DCRTypes.CREATE_ENTITY,
477
+ createdBy: 'alan.khugaev',
478
+ newValue: {
479
+ uri: 'entities/1WNHTsJw',
480
+ type: 'configuration/entityTypes/HCA',
481
+ attributes: {
482
+ CountryCode: [
483
+ {
484
+ value: 'Germany',
485
+ lookupCode: 'DE',
486
+ lookupRawValue: 'DE'
487
+ }
488
+ ],
489
+ ActivationDate: [
490
+ {
491
+ value: '12.10.2011'
492
+ }
493
+ ]
494
+ },
495
+ isFavorite: false
496
+ }
497
+ }
498
+ ],
499
+ _a);
500
+ dcrWithNewEntity = __assign(__assign({}, dcr), { changes: changesWithNewEntity });
501
+ getDataChangeRequest.mockResolvedValue(dcrWithNewEntity);
502
+ user = setUp().user;
503
+ return [4 /*yield*/, user.click(screen.getByTestId('collapse-button'))];
504
+ case 1:
505
+ _b.sent();
506
+ linkElement = screen.getByRole('link');
507
+ href = linkElement.getAttribute('href');
508
+ expect(href).toMatch(new RegExp("".concat(dcrUri, "/changes/").concat(entityUri, "$")));
195
509
  return [2 /*return*/];
196
510
  }
197
511
  });