@reltio/components 1.4.1997 → 1.4.1998

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 (139) hide show
  1. package/cjs/features/activity-log/ActivitiesFactory/ActivitiesFactory.d.ts +1 -1
  2. package/cjs/features/activity-log/ActivitiesFactory/ActivitiesFactory.js +1 -1
  3. package/cjs/features/activity-log/ActivitiesFactory/ActivitiesFactory.test.js +267 -0
  4. package/cjs/features/activity-log/ActivitiesFactory/components/CommentActivity/CommentActivity.d.ts +1 -2
  5. package/cjs/features/activity-log/ActivitiesFactory/components/CommentActivity/CommentActivity.js +1 -1
  6. package/cjs/features/activity-log/ActivitiesFactory/components/CommentActivity/CommentActivity.test.js +5 -23
  7. package/cjs/features/activity-log/ActivitiesFactory/components/GroupActivity/GroupActivity.js +2 -2
  8. package/cjs/features/activity-log/ActivitiesFactory/components/GroupActivity/GroupActivity.test.js +3 -23
  9. package/cjs/features/activity-log/ActivitiesFactory/components/MergeActivity/MergeActivity.js +2 -2
  10. package/cjs/features/activity-log/ActivitiesFactory/components/MergeActivity/MergeActivity.test.js +81 -102
  11. package/cjs/features/activity-log/ActivitiesFactory/components/ObjectLabel/ObjectLabel.d.ts +2 -2
  12. package/cjs/features/activity-log/ActivitiesFactory/components/ObjectLabel/ObjectLabel.js +24 -2
  13. package/cjs/features/activity-log/ActivitiesFactory/components/PotentialMatchActivity/PotentialMatchActivity.js +1 -1
  14. package/cjs/features/activity-log/ActivitiesFactory/components/PotentialMatchActivity/PotentialMatchActivity.test.js +69 -48
  15. package/cjs/features/activity-log/ActivitiesFactory/components/ProfileActivity/ProfileActivity.js +2 -2
  16. package/cjs/features/activity-log/ActivitiesFactory/components/ProfileActivity/ProfileActivity.test.js +123 -107
  17. package/cjs/features/activity-log/ActivitiesFactory/components/RelationActivity/RelationActivity.js +2 -2
  18. package/cjs/features/activity-log/ActivitiesFactory/components/RelationActivity/RelationActivity.test.js +128 -115
  19. package/cjs/features/activity-log/ActivitiesFactory/components/SearchActivity/SearchActivity.js +1 -1
  20. package/cjs/features/activity-log/ActivitiesFactory/components/SearchActivity/SearchActivity.test.js +160 -183
  21. package/cjs/features/activity-log/ActivitiesFactory/components/SimpleActivity/SimpleActivity.js +2 -2
  22. package/cjs/features/activity-log/ActivitiesFactory/components/SimpleActivity/SimpleActivity.test.js +44 -28
  23. package/cjs/features/activity-log/ActivitiesFactory/components/SynchronizationIssuesActivity/SynchronizationIssuesActivity.js +4 -5
  24. package/cjs/features/activity-log/ActivitiesFactory/components/SynchronizationIssuesActivity/SynchronizationIssuesActivity.test.js +54 -47
  25. package/cjs/features/activity-log/ActivityLog/ActivityLog.test.js +83 -22
  26. package/cjs/features/activity-log/ActivityLog/components/GroupItem/GroupItem.js +1 -1
  27. package/cjs/features/activity-log/ActivityLogFilter/ActivityLogFilter.test.js +784 -0
  28. package/cjs/features/activity-log/ActivityTitle/ActivityTitle.d.ts +2 -3
  29. package/cjs/features/activity-log/ActivityTitle/ActivityTitle.js +24 -2
  30. package/cjs/features/activity-log/CollapsibleActivityRecords/CollapsibleActivityRecords.test.js +102 -79
  31. package/cjs/features/activity-log/EntityObject/EntityObject.test.js +35 -26
  32. package/cjs/features/activity-log/Field/Field.d.ts +2 -3
  33. package/cjs/features/activity-log/Field/Field.js +24 -2
  34. package/cjs/features/activity-log/PotentialMatchRecord/PotentialMatchRecord.test.js +160 -34
  35. package/cjs/features/activity-log/PotentialMatchRecord/components/PotentialMatchField/PotentialMatchField.js +1 -1
  36. package/cjs/features/activity-log/RecordUpdates/RecordUpdates.test.js +207 -0
  37. package/cjs/features/activity-log/RecordUpdates/components/DeltaField/DeltaField.js +1 -1
  38. package/cjs/features/activity-log/RelationObject/RelationObject.test.js +46 -29
  39. package/cjs/features/activity-log/RelationRecord/RelationRecord.test.js +88 -68
  40. package/esm/features/activity-log/ActivitiesFactory/ActivitiesFactory.d.ts +1 -1
  41. package/esm/features/activity-log/ActivitiesFactory/ActivitiesFactory.js +1 -1
  42. package/esm/features/activity-log/ActivitiesFactory/ActivitiesFactory.test.js +262 -0
  43. package/esm/features/activity-log/ActivitiesFactory/components/CommentActivity/CommentActivity.d.ts +1 -2
  44. package/esm/features/activity-log/ActivitiesFactory/components/CommentActivity/CommentActivity.js +1 -1
  45. package/esm/features/activity-log/ActivitiesFactory/components/CommentActivity/CommentActivity.test.js +5 -23
  46. package/esm/features/activity-log/ActivitiesFactory/components/GroupActivity/GroupActivity.js +2 -2
  47. package/esm/features/activity-log/ActivitiesFactory/components/GroupActivity/GroupActivity.test.js +3 -23
  48. package/esm/features/activity-log/ActivitiesFactory/components/MergeActivity/MergeActivity.js +2 -2
  49. package/esm/features/activity-log/ActivitiesFactory/components/MergeActivity/MergeActivity.test.js +81 -102
  50. package/esm/features/activity-log/ActivitiesFactory/components/ObjectLabel/ObjectLabel.d.ts +2 -2
  51. package/esm/features/activity-log/ActivitiesFactory/components/ObjectLabel/ObjectLabel.js +24 -2
  52. package/esm/features/activity-log/ActivitiesFactory/components/PotentialMatchActivity/PotentialMatchActivity.js +1 -1
  53. package/esm/features/activity-log/ActivitiesFactory/components/PotentialMatchActivity/PotentialMatchActivity.test.js +69 -48
  54. package/esm/features/activity-log/ActivitiesFactory/components/ProfileActivity/ProfileActivity.js +2 -2
  55. package/esm/features/activity-log/ActivitiesFactory/components/ProfileActivity/ProfileActivity.test.js +123 -107
  56. package/esm/features/activity-log/ActivitiesFactory/components/RelationActivity/RelationActivity.js +2 -2
  57. package/esm/features/activity-log/ActivitiesFactory/components/RelationActivity/RelationActivity.test.js +128 -115
  58. package/esm/features/activity-log/ActivitiesFactory/components/SearchActivity/SearchActivity.js +1 -1
  59. package/esm/features/activity-log/ActivitiesFactory/components/SearchActivity/SearchActivity.test.js +160 -183
  60. package/esm/features/activity-log/ActivitiesFactory/components/SimpleActivity/SimpleActivity.js +2 -2
  61. package/esm/features/activity-log/ActivitiesFactory/components/SimpleActivity/SimpleActivity.test.js +44 -28
  62. package/esm/features/activity-log/ActivitiesFactory/components/SynchronizationIssuesActivity/SynchronizationIssuesActivity.js +4 -5
  63. package/esm/features/activity-log/ActivitiesFactory/components/SynchronizationIssuesActivity/SynchronizationIssuesActivity.test.js +54 -47
  64. package/esm/features/activity-log/ActivityLog/ActivityLog.test.js +83 -22
  65. package/esm/features/activity-log/ActivityLog/components/GroupItem/GroupItem.js +1 -1
  66. package/esm/features/activity-log/ActivityLogFilter/ActivityLogFilter.test.js +779 -0
  67. package/esm/features/activity-log/ActivityTitle/ActivityTitle.d.ts +2 -3
  68. package/esm/features/activity-log/ActivityTitle/ActivityTitle.js +24 -2
  69. package/esm/features/activity-log/CollapsibleActivityRecords/CollapsibleActivityRecords.test.js +104 -58
  70. package/esm/features/activity-log/EntityObject/EntityObject.test.js +35 -26
  71. package/esm/features/activity-log/Field/Field.d.ts +2 -3
  72. package/esm/features/activity-log/Field/Field.js +24 -2
  73. package/esm/features/activity-log/PotentialMatchRecord/PotentialMatchRecord.test.js +160 -34
  74. package/esm/features/activity-log/PotentialMatchRecord/components/PotentialMatchField/PotentialMatchField.js +1 -1
  75. package/esm/features/activity-log/RecordUpdates/RecordUpdates.test.js +202 -0
  76. package/esm/features/activity-log/RecordUpdates/components/DeltaField/DeltaField.js +1 -1
  77. package/esm/features/activity-log/RelationObject/RelationObject.test.js +46 -29
  78. package/esm/features/activity-log/RelationRecord/RelationRecord.test.js +88 -68
  79. package/package.json +1 -1
  80. package/cjs/features/activity-log/ActivityExportButton/ActivityExportButton.specs.js +0 -142
  81. package/cjs/features/activity-log/ActivityFilterButton/ActivityFilterButton.specs.js +0 -131
  82. package/cjs/features/activity-log/ActivityFilterEditor/ActivityFilterEditor.specs.js +0 -252
  83. package/cjs/features/activity-log/ActivityFilterEditor/components/ActivitySelector/ActivitySelector.specs.js +0 -158
  84. package/cjs/features/activity-log/ActivityFilterEditor/components/EntityChangedSelectors/EntityChangedSelectors.specs.js +0 -135
  85. package/cjs/features/activity-log/ActivityFilterEditor/components/EntityTypesSelector/EntityTypesSelector.specs.js +0 -65
  86. package/cjs/features/activity-log/ActivityFilterEditor/components/SourceSelector/SourceSelector.specs.d.ts +0 -1
  87. package/cjs/features/activity-log/ActivityFilterEditor/components/SourceSelector/SourceSelector.specs.js +0 -119
  88. package/cjs/features/activity-log/ActivityFilterEditor/editor.test-data.d.ts +0 -25
  89. package/cjs/features/activity-log/ActivityFilterEditor/editor.test-data.js +0 -75
  90. package/cjs/features/activity-log/ActivityLog/components/ActivityItem/ActivityItem.test.d.ts +0 -1
  91. package/cjs/features/activity-log/ActivityLog/components/ActivityItem/ActivityItem.test.js +0 -140
  92. package/cjs/features/activity-log/ActivityLog/components/GroupItem/GroupItem.test.d.ts +0 -1
  93. package/cjs/features/activity-log/ActivityLog/components/GroupItem/GroupItem.test.js +0 -41
  94. package/cjs/features/activity-log/ActivityLogFilter/ActivityLogFilter.specs.d.ts +0 -1
  95. package/cjs/features/activity-log/ActivityLogFilter/ActivityLogFilter.specs.js +0 -87
  96. package/cjs/features/activity-log/ActivityTitle/ActivityTitle.test.d.ts +0 -1
  97. package/cjs/features/activity-log/ActivityTitle/ActivityTitle.test.js +0 -19
  98. package/cjs/features/activity-log/PotentialMatchRecord/components/PotentialMatchField/PotentialMatchField.test.d.ts +0 -1
  99. package/cjs/features/activity-log/PotentialMatchRecord/components/PotentialMatchField/PotentialMatchField.test.js +0 -179
  100. package/cjs/features/activity-log/RecordUpdates/RecordUpdates.specs.d.ts +0 -1
  101. package/cjs/features/activity-log/RecordUpdates/RecordUpdates.specs.js +0 -150
  102. package/cjs/features/activity-log/RecordUpdates/components/DeltaField/DeltaField.test.d.ts +0 -1
  103. package/cjs/features/activity-log/RecordUpdates/components/DeltaField/DeltaField.test.js +0 -124
  104. package/esm/features/activity-log/ActivityExportButton/ActivityExportButton.specs.d.ts +0 -1
  105. package/esm/features/activity-log/ActivityExportButton/ActivityExportButton.specs.js +0 -137
  106. package/esm/features/activity-log/ActivityFilterButton/ActivityFilterButton.specs.d.ts +0 -1
  107. package/esm/features/activity-log/ActivityFilterButton/ActivityFilterButton.specs.js +0 -126
  108. package/esm/features/activity-log/ActivityFilterEditor/ActivityFilterEditor.specs.d.ts +0 -1
  109. package/esm/features/activity-log/ActivityFilterEditor/ActivityFilterEditor.specs.js +0 -247
  110. package/esm/features/activity-log/ActivityFilterEditor/components/ActivitySelector/ActivitySelector.specs.d.ts +0 -1
  111. package/esm/features/activity-log/ActivityFilterEditor/components/ActivitySelector/ActivitySelector.specs.js +0 -153
  112. package/esm/features/activity-log/ActivityFilterEditor/components/EntityChangedSelectors/EntityChangedSelectors.specs.d.ts +0 -1
  113. package/esm/features/activity-log/ActivityFilterEditor/components/EntityChangedSelectors/EntityChangedSelectors.specs.js +0 -130
  114. package/esm/features/activity-log/ActivityFilterEditor/components/EntityTypesSelector/EntityTypesSelector.specs.d.ts +0 -1
  115. package/esm/features/activity-log/ActivityFilterEditor/components/EntityTypesSelector/EntityTypesSelector.specs.js +0 -60
  116. package/esm/features/activity-log/ActivityFilterEditor/components/SourceSelector/SourceSelector.specs.d.ts +0 -1
  117. package/esm/features/activity-log/ActivityFilterEditor/components/SourceSelector/SourceSelector.specs.js +0 -114
  118. package/esm/features/activity-log/ActivityFilterEditor/editor.test-data.d.ts +0 -25
  119. package/esm/features/activity-log/ActivityFilterEditor/editor.test-data.js +0 -72
  120. package/esm/features/activity-log/ActivityLog/components/ActivityItem/ActivityItem.test.d.ts +0 -1
  121. package/esm/features/activity-log/ActivityLog/components/ActivityItem/ActivityItem.test.js +0 -135
  122. package/esm/features/activity-log/ActivityLog/components/GroupItem/GroupItem.test.d.ts +0 -1
  123. package/esm/features/activity-log/ActivityLog/components/GroupItem/GroupItem.test.js +0 -36
  124. package/esm/features/activity-log/ActivityLogFilter/ActivityLogFilter.specs.d.ts +0 -1
  125. package/esm/features/activity-log/ActivityLogFilter/ActivityLogFilter.specs.js +0 -82
  126. package/esm/features/activity-log/ActivityTitle/ActivityTitle.test.d.ts +0 -1
  127. package/esm/features/activity-log/ActivityTitle/ActivityTitle.test.js +0 -14
  128. package/esm/features/activity-log/PotentialMatchRecord/components/PotentialMatchField/PotentialMatchField.test.d.ts +0 -1
  129. package/esm/features/activity-log/PotentialMatchRecord/components/PotentialMatchField/PotentialMatchField.test.js +0 -151
  130. package/esm/features/activity-log/RecordUpdates/RecordUpdates.specs.d.ts +0 -1
  131. package/esm/features/activity-log/RecordUpdates/RecordUpdates.specs.js +0 -122
  132. package/esm/features/activity-log/RecordUpdates/components/DeltaField/DeltaField.test.d.ts +0 -1
  133. package/esm/features/activity-log/RecordUpdates/components/DeltaField/DeltaField.test.js +0 -119
  134. /package/cjs/features/activity-log/{ActivityExportButton/ActivityExportButton.specs.d.ts → ActivitiesFactory/ActivitiesFactory.test.d.ts} +0 -0
  135. /package/cjs/features/activity-log/{ActivityFilterButton/ActivityFilterButton.specs.d.ts → ActivityLogFilter/ActivityLogFilter.test.d.ts} +0 -0
  136. /package/cjs/features/activity-log/{ActivityFilterEditor/ActivityFilterEditor.specs.d.ts → RecordUpdates/RecordUpdates.test.d.ts} +0 -0
  137. /package/{cjs/features/activity-log/ActivityFilterEditor/components/ActivitySelector/ActivitySelector.specs.d.ts → esm/features/activity-log/ActivitiesFactory/ActivitiesFactory.test.d.ts} +0 -0
  138. /package/{cjs/features/activity-log/ActivityFilterEditor/components/EntityChangedSelectors/EntityChangedSelectors.specs.d.ts → esm/features/activity-log/ActivityLogFilter/ActivityLogFilter.test.d.ts} +0 -0
  139. /package/{cjs/features/activity-log/ActivityFilterEditor/components/EntityTypesSelector/EntityTypesSelector.specs.d.ts → esm/features/activity-log/RecordUpdates/RecordUpdates.test.d.ts} +0 -0
@@ -1,137 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
- return new (P || (P = Promise))(function (resolve, reject) {
15
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
- step((generator = generator.apply(thisArg, _arguments || [])).next());
19
- });
20
- };
21
- var __generator = (this && this.__generator) || function (thisArg, body) {
22
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
23
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
- function verb(n) { return function (v) { return step([n, v]); }; }
25
- function step(op) {
26
- if (f) throw new TypeError("Generator is already executing.");
27
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
- if (y = 0, t) op = [op[0] & 2, t.value];
30
- switch (op[0]) {
31
- case 0: case 1: t = op; break;
32
- case 4: _.label++; return { value: op[1], done: false };
33
- case 5: _.label++; y = op[1]; op = [0]; continue;
34
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
- default:
36
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
- if (t[2]) _.ops.pop();
41
- _.trys.pop(); continue;
42
- }
43
- op = body.call(thisArg, _);
44
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
- }
47
- };
48
- import React from 'react';
49
- import { mount } from 'enzyme';
50
- import { act } from 'react-dom/test-utils';
51
- import { ActivityExportButton } from './ActivityExportButton';
52
- import { SmallIconButton } from '../../../SmallIconButton';
53
- import { exportActivities, DateRangeTypes } from '@reltio/mdm-sdk';
54
- import { DropDownMenuButton } from '../../../DropDownMenuButton';
55
- import Snackbar from '@mui/material/Snackbar';
56
- import { MdmModuleProvider } from '../../../contexts/MdmModuleContext';
57
- jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { exportActivities: jest.fn() })); });
58
- var filters = {
59
- users: [],
60
- activities: [],
61
- dateRange: {
62
- type: DateRangeTypes.WITHIN,
63
- period: [4, 'month']
64
- }
65
- };
66
- var defaultProps = {
67
- filters: filters,
68
- exportTypes: ['csv', 'json']
69
- };
70
- var defaultExportPath = 'exportPath/';
71
- var defaultTenant = 'sokol';
72
- var defaultMdmValues = {
73
- exportPath: defaultExportPath,
74
- tenant: { id: defaultTenant, name: defaultTenant }
75
- };
76
- var defaultMdmActions = {
77
- openConsoleApp: jest.fn()
78
- };
79
- var setUp = function (_a) {
80
- var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? defaultProps : _c, _d = _b.mdmActions, mdmActions = _d === void 0 ? defaultMdmActions : _d, _e = _b.mdmValues, mdmValues = _e === void 0 ? defaultMdmValues : _e;
81
- return mount(React.createElement(MdmModuleProvider, { values: mdmValues, actions: mdmActions },
82
- React.createElement(ActivityExportButton, __assign({}, props))));
83
- };
84
- describe('ActivityExportButton tests', function () {
85
- beforeAll(function () {
86
- exportActivities.mockImplementation(function () { return new Promise(function (resolve) { return resolve({}); }); });
87
- });
88
- it('should render correct default state', function () {
89
- var wrapper = setUp();
90
- expect(wrapper.find(SmallIconButton).length).toBe(1);
91
- expect(wrapper.find(DropDownMenuButton).length).toBe(1);
92
- });
93
- it('should not render dropdown menu when exportTypes are empty', function () {
94
- var props = __assign(__assign({}, defaultProps), { exportTypes: [] });
95
- var wrapper = setUp({ props: props });
96
- expect(wrapper.find(SmallIconButton).length).toBe(1);
97
- expect(wrapper.find(DropDownMenuButton).length).toBe(0);
98
- });
99
- it('should not render dropdown menu when exportTypes are passed and export permitted', function () {
100
- var wrapper = setUp();
101
- expect(wrapper.find(SmallIconButton).length).toBe(1);
102
- expect(wrapper.find(DropDownMenuButton).length).toBe(1);
103
- var menuItemsProps = wrapper.find(DropDownMenuButton).prop('menuItems');
104
- expect(menuItemsProps.map(function (item) { return item.text; })).toEqual(['CSV', 'JSON']);
105
- });
106
- it('should open snackbar on export button click', function () { return __awaiter(void 0, void 0, void 0, function () {
107
- var props, wrapper, button;
108
- return __generator(this, function (_a) {
109
- switch (_a.label) {
110
- case 0:
111
- props = __assign(__assign({}, defaultProps), { exportTypes: [] });
112
- wrapper = setUp({ props: props });
113
- button = wrapper.find(SmallIconButton);
114
- expect(button.length).toBe(1);
115
- expect(button.prop('aria-label')).toBe('Export');
116
- return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
117
- return __generator(this, function (_a) {
118
- button.find('button').simulate('click');
119
- return [2 /*return*/];
120
- });
121
- }); })];
122
- case 1:
123
- _a.sent();
124
- wrapper.update();
125
- expect(wrapper.find(Snackbar).prop('open')).toBeTruthy();
126
- expect(exportActivities).toHaveBeenCalledWith({
127
- exportPath: 'exportPath/',
128
- options: {
129
- filter: expect.stringMatching(/^\(gte\(timestamp, [0-9]+\)\) and \(not equals\(user, 'collaboration-service'\)\)$/)
130
- },
131
- tenant: 'sokol'
132
- });
133
- return [2 /*return*/];
134
- }
135
- });
136
- }); });
137
- });
@@ -1,126 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- import React from 'react';
13
- import { shallow } from 'enzyme';
14
- import { act } from 'react-dom/test-utils';
15
- import { DateRangeTypes } from '@reltio/mdm-sdk';
16
- import { ActivityTypes } from '../types';
17
- import { SmallIconButtonWithTooltip } from '../../../SmallIconButton';
18
- import { ActivityFilterEditor } from '../ActivityFilterEditor';
19
- import { ActivityFilterButton } from './ActivityFilterButton';
20
- describe('ActivityFilterButton tests', function () {
21
- var filter = {
22
- users: [],
23
- activities: [],
24
- dateRange: {
25
- type: DateRangeTypes.WITHIN,
26
- period: [4, 'month']
27
- }
28
- };
29
- var props = {
30
- filter: filter,
31
- entityType: {
32
- uri: 'configuration/entityTypes/Contact',
33
- label: 'Contact',
34
- attributes: []
35
- },
36
- onChange: jest.fn()
37
- };
38
- it('should render correctly', function () {
39
- var wrapper = shallow(React.createElement(ActivityFilterButton, __assign({}, props)));
40
- var button = wrapper.find(SmallIconButtonWithTooltip);
41
- expect(button).toHaveLength(1);
42
- expect(button.hasClass('activeIcon')).toBe(false);
43
- expect(wrapper.find(ActivityFilterEditor).props()).toMatchObject({
44
- open: false,
45
- value: props.filter,
46
- entityType: props.entityType
47
- });
48
- });
49
- it('should have active filter icon if filter changed', function () {
50
- var wrapper = shallow(React.createElement(ActivityFilterButton, __assign({}, props)));
51
- expect(wrapper.find(SmallIconButtonWithTooltip).hasClass('activeIcon')).toBe(false);
52
- wrapper.setProps({ filter: __assign(__assign({}, filter), { users: ['123'] }) });
53
- expect(wrapper.find(SmallIconButtonWithTooltip).hasClass('activeIcon')).toBe(true);
54
- });
55
- it('should open editor on button click', function () {
56
- var wrapper = shallow(React.createElement(ActivityFilterButton, __assign({}, props)));
57
- expect(wrapper.find(ActivityFilterEditor).prop('open')).toBe(false);
58
- act(function () {
59
- wrapper.find(SmallIconButtonWithTooltip).simulate('click');
60
- });
61
- expect(wrapper.find(ActivityFilterEditor).prop('open')).toBe(true);
62
- });
63
- it('should call props.onChange and close editor when ActivityFilterEditor onApply is invoke', function () {
64
- var newFilterValue = {
65
- users: ['ivanov'],
66
- activities: [ActivityTypes.MODEL_UPDATED],
67
- dateRange: {
68
- type: DateRangeTypes.AGO,
69
- period: [1, 'day']
70
- }
71
- };
72
- var wrapper = shallow(React.createElement(ActivityFilterButton, __assign({}, props)));
73
- act(function () {
74
- wrapper.find(SmallIconButtonWithTooltip).simulate('click');
75
- });
76
- expect(wrapper.find(ActivityFilterEditor).prop('open')).toBe(true);
77
- act(function () {
78
- wrapper.find(ActivityFilterEditor).prop('onApply')(newFilterValue);
79
- });
80
- expect(props.onChange).toHaveBeenCalledWith(newFilterValue);
81
- expect(wrapper.find(ActivityFilterEditor).prop('open')).toBe(false);
82
- });
83
- it('should call props.onChange with correct filter if dateRange is not valid', function () {
84
- var newFilterValue = {
85
- users: ['ivanov'],
86
- activities: [ActivityTypes.MODEL_UPDATED],
87
- dateRange: {
88
- type: DateRangeTypes.AGO,
89
- period: [null, 'day']
90
- }
91
- };
92
- var wrapper = shallow(React.createElement(ActivityFilterButton, __assign({}, props)));
93
- act(function () {
94
- wrapper.find(SmallIconButtonWithTooltip).simulate('click');
95
- });
96
- expect(wrapper.find(ActivityFilterEditor).prop('open')).toBe(true);
97
- act(function () {
98
- wrapper.find(ActivityFilterEditor).prop('onApply')(newFilterValue);
99
- });
100
- expect(props.onChange).toHaveBeenCalledWith({
101
- users: ['ivanov'],
102
- activities: [ActivityTypes.MODEL_UPDATED],
103
- dateRange: props.filter.dateRange
104
- });
105
- expect(wrapper.find(ActivityFilterEditor).prop('open')).toBe(false);
106
- });
107
- it('should close editor when ActivityFilterEditor onCancel is invoke', function () {
108
- var wrapper = shallow(React.createElement(ActivityFilterButton, __assign({}, props)));
109
- act(function () {
110
- wrapper.find(SmallIconButtonWithTooltip).simulate('click');
111
- });
112
- expect(wrapper.find(ActivityFilterEditor).prop('open')).toBe(true);
113
- act(function () {
114
- wrapper.find(ActivityFilterEditor).prop('onCancel')();
115
- });
116
- expect(wrapper.find(ActivityFilterEditor).prop('open')).toBe(false);
117
- });
118
- it('should clear filter when ActivityFilterEditor onClear is invoke', function () {
119
- var initialFilter = props.filter;
120
- var wrapper = shallow(React.createElement(ActivityFilterButton, __assign({}, props)));
121
- act(function () {
122
- wrapper.find(ActivityFilterEditor).prop('onClear')();
123
- });
124
- expect(props.onChange).toHaveBeenCalledWith(__assign({}, initialFilter));
125
- });
126
- });
@@ -1,247 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
- return new (P || (P = Promise))(function (resolve, reject) {
15
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
- step((generator = generator.apply(thisArg, _arguments || [])).next());
19
- });
20
- };
21
- var __generator = (this && this.__generator) || function (thisArg, body) {
22
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
23
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
- function verb(n) { return function (v) { return step([n, v]); }; }
25
- function step(op) {
26
- if (f) throw new TypeError("Generator is already executing.");
27
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
- if (y = 0, t) op = [op[0] & 2, t.value];
30
- switch (op[0]) {
31
- case 0: case 1: t = op; break;
32
- case 4: _.label++; return { value: op[1], done: false };
33
- case 5: _.label++; y = op[1]; op = [0]; continue;
34
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
- default:
36
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
- if (t[2]) _.ops.pop();
41
- _.trys.pop(); continue;
42
- }
43
- op = body.call(thisArg, _);
44
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
- }
47
- };
48
- import React from 'react';
49
- import { render, screen, within } from '@testing-library/react';
50
- import userEvent from '@testing-library/user-event';
51
- import { getAllUsersForTenant, DateRangeTypes } from '@reltio/mdm-sdk';
52
- import { ActivityFilterEditor } from './ActivityFilterEditor';
53
- import { metadata, usersResponse, value } from './editor.test-data';
54
- import { MdmModuleProvider } from '../../../contexts/MdmModuleContext';
55
- import { ActivityTypes } from '../types';
56
- jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { getAllUsersForTenant: jest.fn() })); });
57
- describe('ActivityFilterEditor tests', function () {
58
- var defaultProps = {
59
- value: value,
60
- open: true,
61
- anchorEl: document.createElement('div'),
62
- onApply: jest.fn(),
63
- onCancel: jest.fn(),
64
- onClear: jest.fn()
65
- };
66
- var setUp = function (props) {
67
- if (props === void 0) { props = {}; }
68
- var user = userEvent.setup();
69
- var Providers = function (_a) {
70
- var children = _a.children;
71
- return (React.createElement(MdmModuleProvider, { values: { metadata: metadata } }, children));
72
- };
73
- return __assign({ user: user }, render(React.createElement(ActivityFilterEditor, __assign({}, defaultProps, props)), { wrapper: Providers }));
74
- };
75
- beforeAll(function () {
76
- getAllUsersForTenant.mockResolvedValue(usersResponse);
77
- });
78
- beforeEach(function () {
79
- jest.clearAllMocks();
80
- });
81
- it('should render correct default state', function () {
82
- setUp();
83
- var activitySelector = screen.getByTestId('activity-selector');
84
- expect(within(activitySelector).getByText('Activity')).toBeInTheDocument();
85
- expect(within(activitySelector).getByText('Model was updated')).toBeInTheDocument();
86
- expect(within(activitySelector).getByText('Comment added')).toBeInTheDocument();
87
- var dateRangeSelector = screen.getByTestId('date-range-selector');
88
- expect(within(dateRangeSelector).getByText('Date')).toBeInTheDocument();
89
- expect(within(dateRangeSelector).getByText('Within the last')).toBeInTheDocument();
90
- expect(within(dateRangeSelector).getAllByRole('spinbutton')[0]).toHaveValue(4);
91
- var userSelector = screen.getByTestId('user-selector');
92
- expect(within(userSelector).getByText('User')).toBeInTheDocument();
93
- expect(within(userSelector).getByText('username1')).toBeInTheDocument();
94
- expect(within(userSelector).getByText('username2')).toBeInTheDocument();
95
- expect(screen.queryByTestId('entity-types-selector')).not.toBeInTheDocument();
96
- expect(screen.queryByTestId('attribute-selector')).not.toBeInTheDocument();
97
- expect(screen.queryByTestId('source-selector')).not.toBeInTheDocument();
98
- expect(screen.getByText('Clear all')).toBeInTheDocument();
99
- expect(screen.getByText('Cancel')).toBeInTheDocument();
100
- expect(screen.getByText('Apply')).toBeInTheDocument();
101
- });
102
- it('should render correct default state for ENTITY_CHANGED', function () {
103
- var filterValue = __assign(__assign({}, value), { activities: [ActivityTypes.ENTITY_CHANGED] });
104
- var entityType = { uri: 'test', attributes: [] };
105
- setUp({ value: filterValue, entityType: entityType });
106
- expect(screen.getByTestId('activity-selector')).toBeInTheDocument();
107
- expect(screen.queryByTestId('entity-types-selector')).not.toBeInTheDocument();
108
- expect(screen.getByTestId('date-range-selector')).toBeInTheDocument();
109
- expect(screen.getByTestId('user-selector')).toBeInTheDocument();
110
- var attributeSelector = screen.getByTestId('attribute-selector');
111
- expect(within(attributeSelector).getByText('Attribute')).toBeInTheDocument();
112
- expect(within(attributeSelector).getByText('Activity')).toBeInTheDocument();
113
- var sourceSelector = screen.getByTestId('source-selector');
114
- expect(within(sourceSelector).getByText('Source')).toBeInTheDocument();
115
- expect(within(sourceSelector).getByText('Reltio')).toBeInTheDocument();
116
- });
117
- it('should hide filter when props.open = false', function () {
118
- var container = setUp({ open: false }).container;
119
- expect(container).toBeEmptyDOMElement();
120
- });
121
- it('should clear current value and call props.onClear on Clear all button click', function () { return __awaiter(void 0, void 0, void 0, function () {
122
- var user, userSelector, activitySelector;
123
- return __generator(this, function (_a) {
124
- switch (_a.label) {
125
- case 0:
126
- user = setUp().user;
127
- userSelector = screen.getByTestId('user-selector');
128
- expect(within(userSelector).getByText('username1')).toBeInTheDocument();
129
- activitySelector = screen.getByTestId('activity-selector');
130
- expect(within(activitySelector).getByText('Model was updated')).toBeInTheDocument();
131
- return [4 /*yield*/, user.click(screen.getByText('Clear all'))];
132
- case 1:
133
- _a.sent();
134
- expect(within(userSelector).queryByText('username1')).not.toBeInTheDocument();
135
- expect(within(userSelector).queryByText('username2')).not.toBeInTheDocument();
136
- expect(within(activitySelector).queryByText('Model was updated')).not.toBeInTheDocument();
137
- expect(within(activitySelector).queryByText('Comment added')).not.toBeInTheDocument();
138
- expect(defaultProps.onClear).toHaveBeenCalled();
139
- return [2 /*return*/];
140
- }
141
- });
142
- }); });
143
- it('should call onCancel when click on Cancel button', function () { return __awaiter(void 0, void 0, void 0, function () {
144
- var user;
145
- return __generator(this, function (_a) {
146
- switch (_a.label) {
147
- case 0:
148
- user = setUp().user;
149
- return [4 /*yield*/, user.click(screen.getByText('Cancel'))];
150
- case 1:
151
- _a.sent();
152
- expect(defaultProps.onCancel).toHaveBeenCalled();
153
- return [2 /*return*/];
154
- }
155
- });
156
- }); });
157
- it('should call onApply when click on Apply button', function () { return __awaiter(void 0, void 0, void 0, function () {
158
- var user;
159
- return __generator(this, function (_a) {
160
- switch (_a.label) {
161
- case 0:
162
- user = setUp().user;
163
- return [4 /*yield*/, user.type(screen.getAllByRole('spinbutton')[0], '5')];
164
- case 1:
165
- _a.sent();
166
- return [4 /*yield*/, user.click(screen.getByText('Apply'))];
167
- case 2:
168
- _a.sent();
169
- expect(defaultProps.onApply).toHaveBeenCalledWith(__assign(__assign({}, defaultProps.value), { dateRange: {
170
- type: DateRangeTypes.WITHIN,
171
- period: [45, 'month']
172
- } }));
173
- return [2 /*return*/];
174
- }
175
- });
176
- }); });
177
- it('should correctly change filter onPropChange calls', function () { return __awaiter(void 0, void 0, void 0, function () {
178
- var filterValue, entityType, user, attributeSelector;
179
- return __generator(this, function (_a) {
180
- switch (_a.label) {
181
- case 0:
182
- filterValue = __assign(__assign({}, value), { activities: [ActivityTypes.ENTITY_CHANGED] });
183
- entityType = metadata.entityTypes[1];
184
- user = setUp({ value: filterValue, entityType: entityType }).user;
185
- attributeSelector = screen.getByTestId('attribute-selector');
186
- return [4 /*yield*/, user.click(within(attributeSelector).getByRole('combobox'))];
187
- case 1:
188
- _a.sent();
189
- return [4 /*yield*/, user.click(screen.getByRole('menuitem', { name: 'Activity' }))];
190
- case 2:
191
- _a.sent();
192
- return [4 /*yield*/, user.click(screen.getByText('Apply'))];
193
- case 3:
194
- _a.sent();
195
- expect(defaultProps.onApply).toHaveBeenCalledWith(__assign(__assign({}, filterValue), { attributes: [] }));
196
- return [2 /*return*/];
197
- }
198
- });
199
- }); });
200
- it('should clear attributes on entityTypes filter changes', function () { return __awaiter(void 0, void 0, void 0, function () {
201
- var filterValue, user, entityTypeSelector, newEntityTypes;
202
- return __generator(this, function (_a) {
203
- switch (_a.label) {
204
- case 0:
205
- filterValue = __assign(__assign({}, value), { activities: [ActivityTypes.ENTITY_CHANGED] });
206
- user = setUp({ value: filterValue }).user;
207
- entityTypeSelector = screen.getByTestId('entity-types-selector');
208
- return [4 /*yield*/, user.click(within(entityTypeSelector).getByRole('combobox'))];
209
- case 1:
210
- _a.sent();
211
- return [4 /*yield*/, user.click(screen.getByRole('option', { name: 'HCA' }))];
212
- case 2:
213
- _a.sent();
214
- newEntityTypes = [metadata.entityTypes[1]];
215
- return [4 /*yield*/, user.click(screen.getByText('Apply'))];
216
- case 3:
217
- _a.sent();
218
- expect(defaultProps.onApply).toHaveBeenCalledWith(__assign(__assign({}, filterValue), { entityTypes: newEntityTypes, attributes: [] }));
219
- return [2 /*return*/];
220
- }
221
- });
222
- }); });
223
- it('should clear attributes, entityTypes, sources on activities filter changes', function () { return __awaiter(void 0, void 0, void 0, function () {
224
- var filterValue, entityType, user, activitySelector, textbox;
225
- return __generator(this, function (_a) {
226
- switch (_a.label) {
227
- case 0:
228
- filterValue = __assign(__assign({}, value), { activities: [] });
229
- entityType = { uri: 'test', attributes: [] };
230
- user = setUp({ value: filterValue, entityType: entityType }).user;
231
- activitySelector = screen.getByTestId('activity-selector');
232
- textbox = within(activitySelector).getByRole('combobox');
233
- return [4 /*yield*/, user.click(textbox)];
234
- case 1:
235
- _a.sent();
236
- return [4 /*yield*/, user.click(screen.getByText('Profile updated'))];
237
- case 2:
238
- _a.sent();
239
- return [4 /*yield*/, user.click(screen.getByText('Apply'))];
240
- case 3:
241
- _a.sent();
242
- expect(defaultProps.onApply).toHaveBeenCalledWith(__assign(__assign({}, filterValue), { activities: [ActivityTypes.ENTITY_CHANGED], attributes: [], sources: [], entityTypes: [] }));
243
- return [2 /*return*/];
244
- }
245
- });
246
- }); });
247
- });