@reltio/components 1.4.1895 → 1.4.1897

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 (27) hide show
  1. package/cjs/ModeSwitcherSelect/ModeSwitcherSelect.d.ts +2 -1
  2. package/cjs/ModeSwitcherSelect/ModeSwitcherSelect.js +4 -3
  3. package/cjs/ModeSwitcherSelect/ModeSwitcherSelect.test.js +232 -89
  4. package/cjs/ModeSwitcherSelect/styles.d.ts +1 -1
  5. package/cjs/ModeSwitcherSelect/styles.js +18 -0
  6. package/cjs/contexts/MdmModuleContext/context.d.ts +2 -0
  7. package/cjs/contexts/MdmModuleContext/hooks.d.ts +2 -1
  8. package/cjs/features/history/HistoryGraph/components/HistoryCircle/HistoryCircle.js +1 -1
  9. package/cjs/features/history/HistoryRow/HistoryRow.js +3 -1
  10. package/cjs/features/history/HistoryTree/HistoryTree.js +2 -7
  11. package/cjs/features/history/HistoryTree/HistoryTree.specs.js +141 -223
  12. package/cjs/features/workflow/WorkflowComments/WorkflowComments.js +1 -1
  13. package/cjs/features/workflow/WorkflowComments/WorkflowCommments.spec.js +6 -0
  14. package/esm/ModeSwitcherSelect/ModeSwitcherSelect.d.ts +2 -1
  15. package/esm/ModeSwitcherSelect/ModeSwitcherSelect.js +4 -3
  16. package/esm/ModeSwitcherSelect/ModeSwitcherSelect.test.js +232 -89
  17. package/esm/ModeSwitcherSelect/styles.d.ts +1 -1
  18. package/esm/ModeSwitcherSelect/styles.js +18 -0
  19. package/esm/contexts/MdmModuleContext/context.d.ts +2 -0
  20. package/esm/contexts/MdmModuleContext/hooks.d.ts +2 -1
  21. package/esm/features/history/HistoryGraph/components/HistoryCircle/HistoryCircle.js +1 -1
  22. package/esm/features/history/HistoryRow/HistoryRow.js +3 -1
  23. package/esm/features/history/HistoryTree/HistoryTree.js +2 -7
  24. package/esm/features/history/HistoryTree/HistoryTree.specs.js +141 -223
  25. package/esm/features/workflow/WorkflowComments/WorkflowComments.js +1 -1
  26. package/esm/features/workflow/WorkflowComments/WorkflowCommments.spec.js +6 -0
  27. package/package.json +2 -2
@@ -51,14 +51,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
51
51
  };
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
53
  var react_1 = __importDefault(require("react"));
54
- var enzyme_1 = require("enzyme");
55
- var test_utils_1 = require("react-dom/test-utils");
56
- var react_resize_detector_1 = __importDefault(require("react-resize-detector"));
57
54
  var ui_i18n_1 = __importDefault(require("ui-i18n"));
58
- var Button_1 = __importDefault(require("@mui/material/Button"));
59
- var LinearLoadIndicator_1 = require("../../../LinearLoadIndicator");
60
- var HistoryGraph_1 = require("../HistoryGraph");
61
- var HistoryRow_1 = require("../HistoryRow");
55
+ var react_2 = require("@testing-library/react");
56
+ var user_event_1 = __importDefault(require("@testing-library/user-event"));
62
57
  var mdm_sdk_1 = require("@reltio/mdm-sdk");
63
58
  var MdmModuleContext_1 = require("../../../contexts/MdmModuleContext");
64
59
  var HistoryTree_1 = require("./HistoryTree");
@@ -72,6 +67,7 @@ var metadata = {
72
67
  { uri: 'configuration/sources/DEA', label: 'DEA' }
73
68
  ]
74
69
  };
70
+ var historyEvent = { aStamp: 1633089195406, overrideUri: 'entities/123' };
75
71
  var historyData = {
76
72
  historyLanes: {
77
73
  'entities/123': {
@@ -96,15 +92,8 @@ var historyData = {
96
92
  }
97
93
  ]
98
94
  };
99
- var defaultMdmValues = {
100
- metadata: metadata,
101
- mode: mdm_sdk_1.Mode.Viewing
102
- };
103
- var mdmActions = {
104
- setHistoryEvent: jest.fn(),
105
- clearHistoryEvent: jest.fn(),
106
- modeUpdated: jest.fn()
107
- };
95
+ var mdmActions = { setHistoryEvent: jest.fn(), clearHistoryEvent: jest.fn(), modeUpdateRequested: jest.fn() };
96
+ var defaultMdmValues = { metadata: metadata, mode: mdm_sdk_1.Mode.Viewing };
108
97
  var defaultProps = {
109
98
  historyData: historyData,
110
99
  isLoading: false,
@@ -115,12 +104,15 @@ var defaultProps = {
115
104
  findPreviousChange: function (index) { return historyData.rows[index + 1]; }
116
105
  };
117
106
  var setUp = function (_a) {
118
- var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? defaultProps : _c, _d = _b.mdmValues, mdmValues = _d === void 0 ? defaultMdmValues : _d;
119
- return (0, enzyme_1.mount)(react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { values: mdmValues, actions: mdmActions },
120
- react_1.default.createElement(HistoryTree_1.HistoryTree, __assign({}, props))));
107
+ var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? {} : _c, _d = _b.mdmValues, mdmValues = _d === void 0 ? defaultMdmValues : _d;
108
+ var user = user_event_1.default.setup();
109
+ var Providers = function (_a) {
110
+ var children = _a.children;
111
+ return (react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { values: mdmValues, actions: mdmActions }, children));
112
+ };
113
+ return __assign({ user: user }, (0, react_2.render)(react_1.default.createElement(HistoryTree_1.HistoryTree, __assign({}, defaultProps, props)), { wrapper: Providers }));
121
114
  };
122
115
  describe('HistoryTree tests', function () {
123
- var historyEvent = { aStamp: 1633089195406, overrideUri: 'entities/123' };
124
116
  beforeAll(function () {
125
117
  jest.spyOn(Element.prototype, 'clientHeight', 'get').mockReturnValue(100);
126
118
  });
@@ -128,149 +120,135 @@ describe('HistoryTree tests', function () {
128
120
  jest.clearAllMocks();
129
121
  });
130
122
  it('should render correct default state', function () {
131
- var wrapper = setUp();
132
- expect(wrapper.find(LinearLoadIndicator_1.LinearLoadIndicator).length).toBe(0);
133
- var graph = wrapper.find('.graph');
134
- expect(graph.length).toBe(1);
135
- expect(graph.hasClass('shadow')).toBe(false);
136
- expect(graph.find(HistoryGraph_1.HistoryGraph).length).toBe(1);
137
- expect(graph.find(HistoryGraph_1.HistoryGraph).prop('graphData')).toEqual({
138
- historyLanes: historyData.historyLanes,
139
- rows: historyData.rows.map(function (row) { return (__assign(__assign({}, row), { height: 100 })); })
140
- });
141
- expect(graph.find(react_resize_detector_1.default).length).toBe(1);
142
- var history = wrapper.find('.history');
143
- expect(history.length).toBe(1);
144
- var historyRows = history.find(HistoryRow_1.HistoryRow);
145
- expect(historyRows.length).toBe(2);
146
- historyRows.forEach(function (row, i) {
147
- expect(row.prop('change')).toBe(historyData.rows[i]);
148
- expect(row.prop('isCurrent')).toBe(i === 0);
149
- expect(row.prop('isSelected')).toBe(i === 0);
150
- });
151
- var buttonContainer = wrapper.find('.buttonContainer');
152
- expect(buttonContainer.length).toBe(0);
153
- });
154
- it('should show "load more" button and call onLoadMore prop on click if canLoadMore === true', function () {
155
- var onLoadMore = defaultProps.onLoadMore;
156
- var props = __assign(__assign({}, defaultProps), { canLoadMore: true });
157
- var wrapper = setUp({ props: props });
158
- expect(onLoadMore).not.toBeCalled();
159
- var buttonContainer = wrapper.find('.buttonContainer');
160
- expect(buttonContainer.length).toBe(1);
161
- var button = buttonContainer.find(Button_1.default).find('button');
162
- expect(button.length).toBe(1);
163
- expect(button.text()).toBe('Show more');
164
- button.simulate('click');
165
- expect(onLoadMore).toBeCalled();
123
+ setUp();
124
+ expect(react_2.screen.getByTestId('reltio-history-graph')).toBeInTheDocument();
125
+ var rows = react_2.screen.getAllByTestId('history-row');
126
+ expect(rows).toHaveLength(2);
127
+ var current = rows[0], unmerged = rows[1];
128
+ expect(current).toHaveClass('selected');
129
+ (0, react_2.within)(current).getByText('Current view');
130
+ (0, react_2.within)(current).getByText('user1');
131
+ (0, react_2.within)(unmerged).getByText(ui_i18n_1.default.date(historyData.rows[1].timestamp, 'L LT'));
132
+ (0, react_2.within)(unmerged).getByText('Profile un-merged');
133
+ (0, react_2.within)(unmerged).getByText('user2');
134
+ (0, react_2.within)(unmerged).getByText(ui_i18n_1.default.date(historyData.rows[1].timestamp, 'L LT'));
135
+ expect(react_2.screen.queryByTestId('reltio-linear-load-indicator')).not.toBeInTheDocument();
136
+ expect(react_2.screen.queryByText('Show more')).not.toBeInTheDocument();
166
137
  });
138
+ it('should show "load more" button and call onLoadMore prop on click if canLoadMore === true', function () { return __awaiter(void 0, void 0, void 0, function () {
139
+ var user;
140
+ return __generator(this, function (_a) {
141
+ switch (_a.label) {
142
+ case 0:
143
+ user = setUp({ props: { canLoadMore: true } }).user;
144
+ return [4 /*yield*/, user.click(react_2.screen.getByText('Show more'))];
145
+ case 1:
146
+ _a.sent();
147
+ expect(defaultProps.onLoadMore).toBeCalled();
148
+ return [2 /*return*/];
149
+ }
150
+ });
151
+ }); });
167
152
  it('should show loading indicator if isLoading === true', function () {
168
- var props = __assign(__assign({}, defaultProps), { isLoading: true });
169
- var wrapper = setUp({ props: props });
170
- expect(wrapper.find(LinearLoadIndicator_1.LinearLoadIndicator).length).toBe(1);
153
+ setUp({ props: { isLoading: true } });
154
+ expect(react_2.screen.getByTestId('reltio-linear-load-indicator')).toBeInTheDocument();
171
155
  });
172
- it('should show shadow if content scrollable right', function () {
173
- var wrapper = setUp();
174
- var graph = wrapper.find('.graph');
175
- var reactResizeDetector = wrapper.find(react_resize_detector_1.default);
176
- expect(graph.length).toBe(1);
177
- expect(graph.hasClass('shadow')).toBe(false);
178
- expect(reactResizeDetector.length).toBe(1);
156
+ it('should show shadow if content is scrollable right', function () {
179
157
  jest.spyOn(Element.prototype, 'clientWidth', 'get').mockReturnValue(100);
180
158
  jest.spyOn(Element.prototype, 'scrollWidth', 'get').mockReturnValue(150);
181
159
  jest.spyOn(Element.prototype, 'scrollLeft', 'get').mockReturnValueOnce(0);
182
- (0, test_utils_1.act)(function () {
183
- var onResize = reactResizeDetector.prop('onResize');
184
- onResize();
185
- });
186
- wrapper.update();
187
- expect(wrapper.find('.graph').hasClass('shadow')).toBe(true);
188
- jest.spyOn(Element.prototype, 'scrollLeft', 'get').mockReturnValueOnce(50);
189
- (0, test_utils_1.act)(function () {
190
- wrapper.find('.graph').simulate('scroll');
191
- });
192
- wrapper.update();
193
- expect(wrapper.find('.graph').hasClass('shadow')).toBe(false);
194
- });
195
- it('should render the latest event as selected if props.historyEvent is undefined', function () {
196
- var wrapper = setUp();
197
- var historyRows = wrapper.find(HistoryRow_1.HistoryRow);
198
- expect(historyRows.at(0).prop('isSelected')).toBeTruthy();
199
- expect(historyRows.at(1).prop('isSelected')).toBeFalsy();
160
+ setUp();
161
+ var graph = react_2.screen.getByTestId('reltio-history-graph');
162
+ react_2.fireEvent.scroll(graph.parentElement);
163
+ expect(graph.parentElement).toHaveClass('shadow');
200
164
  });
201
- it('should render correct selected row', function () {
202
- var props = __assign(__assign({}, defaultProps), { historyEvent: historyEvent });
203
- var wrapper = setUp({ props: props });
204
- var historyRows = wrapper.find(HistoryRow_1.HistoryRow);
205
- expect(historyRows.at(0).prop('isSelected')).toBeFalsy();
206
- expect(historyRows.at(1).prop('isSelected')).toBeTruthy();
165
+ it('should not show shadow if content is not scrollable right', function () {
166
+ jest.spyOn(Element.prototype, 'clientWidth', 'get').mockReturnValue(100);
167
+ jest.spyOn(Element.prototype, 'scrollWidth', 'get').mockReturnValue(100);
168
+ jest.spyOn(Element.prototype, 'scrollLeft', 'get').mockReturnValueOnce(0);
169
+ setUp();
170
+ var graph = react_2.screen.getByTestId('reltio-history-graph');
171
+ react_2.fireEvent.scroll(graph.parentElement);
172
+ expect(graph.parentElement).not.toHaveClass('shadow');
207
173
  });
208
- it('should dipatch setHistoryEvent when invoke HistoryRow prop onClick', function () {
209
- var setHistoryEvent = mdmActions.setHistoryEvent;
210
- var wrapper = setUp();
211
- (0, test_utils_1.act)(function () {
212
- wrapper.find(HistoryRow_1.HistoryRow).at(1).prop('onClick')();
213
- });
214
- var event = { aStamp: 1633089195406, overrideUri: null };
215
- expect(setHistoryEvent).toBeCalledWith(event);
174
+ it('should not show shadow if content is scrollable right but you scrolled right already', function () {
175
+ jest.spyOn(Element.prototype, 'clientWidth', 'get').mockReturnValue(100);
176
+ jest.spyOn(Element.prototype, 'scrollWidth', 'get').mockReturnValue(150);
177
+ jest.spyOn(Element.prototype, 'scrollLeft', 'get').mockReturnValueOnce(50);
178
+ setUp();
179
+ var graph = react_2.screen.getByTestId('reltio-history-graph');
180
+ react_2.fireEvent.scroll(graph.parentElement);
181
+ expect(graph.parentElement).not.toHaveClass('shadow');
216
182
  });
217
- it('should dipatch clearHistoryEvent when invoke HistoryRow prop onClick on selected event', function () {
218
- var clearHistoryEvent = mdmActions.clearHistoryEvent;
219
- var props = __assign(__assign({}, defaultProps), { historyEvent: historyEvent });
220
- var wrapper = setUp({ props: props });
221
- (0, test_utils_1.act)(function () {
222
- wrapper.find(HistoryRow_1.HistoryRow).at(1).prop('onClick')();
223
- });
224
- expect(clearHistoryEvent).toHaveBeenCalled();
183
+ it('should render correct selected row', function () {
184
+ setUp({ props: { historyEvent: historyEvent } });
185
+ var rows = react_2.screen.getAllByTestId('history-row');
186
+ expect(rows[0]).not.toHaveClass('selected');
187
+ expect(rows[1]).toHaveClass('selected');
225
188
  });
226
- it('should dipatch clearHistoryEvent when invoke HistoryRow prop onClick on the latest event', function () {
227
- var clearHistoryEvent = mdmActions.clearHistoryEvent;
228
- var props = __assign(__assign({}, defaultProps), { historyEvent: historyEvent });
229
- var wrapper = setUp({ props: props });
230
- (0, test_utils_1.act)(function () {
231
- wrapper.find(HistoryRow_1.HistoryRow).at(0).prop('onClick')();
189
+ it('should dispatch setHistoryEvent when invoke HistoryRow prop onClick', function () { return __awaiter(void 0, void 0, void 0, function () {
190
+ var user;
191
+ return __generator(this, function (_a) {
192
+ switch (_a.label) {
193
+ case 0:
194
+ user = setUp().user;
195
+ return [4 /*yield*/, user.click(react_2.screen.getAllByTestId('history-row')[1])];
196
+ case 1:
197
+ _a.sent();
198
+ expect(mdmActions.clearHistoryEvent).not.toHaveBeenCalled();
199
+ expect(mdmActions.setHistoryEvent).toHaveBeenCalledWith({ aStamp: 1633089195406, overrideUri: null });
200
+ return [2 /*return*/];
201
+ }
232
202
  });
233
- expect(clearHistoryEvent).toHaveBeenCalled();
234
- });
235
- it('should not dipatch clearHistoryEvent when invoke HistoryRow prop onClick on the latest event if props.historyEvent is undefined', function () {
236
- var clearHistoryEvent = mdmActions.clearHistoryEvent;
237
- var wrapper = setUp();
238
- (0, test_utils_1.act)(function () {
239
- wrapper.find(HistoryRow_1.HistoryRow).at(0).prop('onClick')();
203
+ }); });
204
+ it('should dispatch clearHistoryEvent when click on selected view', function () { return __awaiter(void 0, void 0, void 0, function () {
205
+ var user;
206
+ return __generator(this, function (_a) {
207
+ switch (_a.label) {
208
+ case 0:
209
+ user = setUp({ props: { historyEvent: historyEvent } }).user;
210
+ return [4 /*yield*/, user.click(react_2.screen.getAllByTestId('history-row')[1])];
211
+ case 1:
212
+ _a.sent();
213
+ expect(mdmActions.clearHistoryEvent).toHaveBeenCalled();
214
+ expect(mdmActions.setHistoryEvent).not.toHaveBeenCalled();
215
+ return [2 /*return*/];
216
+ }
240
217
  });
241
- expect(clearHistoryEvent).not.toBeCalled();
242
- });
243
- it('should dipatch modeUpdated and setHistoryEvent when invoke HistoryRow prop onClick in Editing mode and apply confirmation', function () {
244
- var confirm = jest.spyOn(window, 'confirm').mockReturnValue(true);
245
- var modeUpdated = mdmActions.modeUpdated, setHistoryEvent = mdmActions.setHistoryEvent;
246
- var mdmValues = __assign(__assign({}, defaultMdmValues), { mode: mdm_sdk_1.Mode.Editing });
247
- var wrapper = setUp({ mdmValues: mdmValues });
248
- (0, test_utils_1.act)(function () {
249
- wrapper.find(HistoryRow_1.HistoryRow).at(1).prop('onClick')();
218
+ }); });
219
+ it('should dispatch clearHistoryEvent when click on current view', function () { return __awaiter(void 0, void 0, void 0, function () {
220
+ var user;
221
+ return __generator(this, function (_a) {
222
+ switch (_a.label) {
223
+ case 0:
224
+ user = setUp({ props: { historyEvent: historyEvent } }).user;
225
+ return [4 /*yield*/, user.click(react_2.screen.getAllByTestId('history-row')[0])];
226
+ case 1:
227
+ _a.sent();
228
+ expect(mdmActions.clearHistoryEvent).toHaveBeenCalled();
229
+ expect(mdmActions.setHistoryEvent).not.toHaveBeenCalled();
230
+ return [2 /*return*/];
231
+ }
250
232
  });
251
- var event = {
252
- aStamp: 1633089195406,
253
- overrideUri: null
254
- };
255
- expect(confirm).toHaveBeenCalledWith(ui_i18n_1.default.text('Are you sure you want to go in history mode? All your changes will be lost.'));
256
- expect(modeUpdated).toHaveBeenCalledWith(mdm_sdk_1.Mode.Viewing);
257
- expect(setHistoryEvent).toHaveBeenCalledWith(event);
258
- });
259
- it('should dipatch nothing when invoke HistoryRow prop onClick in Editing mode and cancel confirmation', function () {
260
- var confirm = jest.spyOn(window, 'confirm').mockReturnValue(false);
261
- var modeUpdated = mdmActions.modeUpdated, setHistoryEvent = mdmActions.setHistoryEvent, clearHistoryEvent = mdmActions.clearHistoryEvent;
262
- var mdmValues = __assign(__assign({}, defaultMdmValues), { mode: mdm_sdk_1.Mode.Editing });
263
- var wrapper = setUp({ mdmValues: mdmValues });
264
- (0, test_utils_1.act)(function () {
265
- wrapper.find(HistoryRow_1.HistoryRow).at(1).prop('onClick')();
233
+ }); });
234
+ it('should dispatch modeUpdateRequested and setHistoryEvent when click in Editing mode', function () { return __awaiter(void 0, void 0, void 0, function () {
235
+ var user;
236
+ return __generator(this, function (_a) {
237
+ switch (_a.label) {
238
+ case 0:
239
+ user = setUp({ mdmValues: __assign(__assign({}, defaultMdmValues), { mode: mdm_sdk_1.Mode.Editing }) }).user;
240
+ return [4 /*yield*/, user.click(react_2.screen.getAllByTestId('history-row')[1])];
241
+ case 1:
242
+ _a.sent();
243
+ expect(mdmActions.clearHistoryEvent).not.toHaveBeenCalled();
244
+ expect(mdmActions.setHistoryEvent).toHaveBeenCalledWith({ aStamp: 1633089195406, overrideUri: null });
245
+ expect(mdmActions.modeUpdateRequested).toHaveBeenCalledWith(mdm_sdk_1.Mode.Viewing);
246
+ return [2 /*return*/];
247
+ }
266
248
  });
267
- expect(confirm).toHaveBeenCalledWith(ui_i18n_1.default.text('Are you sure you want to go in history mode? All your changes will be lost.'));
268
- expect(clearHistoryEvent).not.toHaveBeenCalled();
269
- expect(setHistoryEvent).not.toHaveBeenCalled();
270
- expect(modeUpdated).not.toHaveBeenCalled();
271
- });
272
- it('handleHistoryCircleMouseOver handler should work correctly when crosswalks exist', function () { return __awaiter(void 0, void 0, void 0, function () {
273
- var crosswalks, wrapper, graphData;
249
+ }); });
250
+ it('should request circle label correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
251
+ var crosswalks, user;
274
252
  return __generator(this, function (_a) {
275
253
  switch (_a.label) {
276
254
  case 0:
@@ -282,96 +260,36 @@ describe('HistoryTree tests', function () {
282
260
  { type: 'configuration/sources/MDS' }
283
261
  ];
284
262
  mdm_sdk_1.getEntity.mockImplementation(function () { return Promise.resolve({ crosswalks: crosswalks }); });
285
- wrapper = setUp();
286
- graphData = {
287
- historyLanes: historyData.historyLanes,
288
- rows: historyData.rows.map(function (row) { return (__assign(__assign({}, row), { height: 100 })); })
289
- };
290
- expect(wrapper.find(HistoryGraph_1.HistoryGraph).prop('graphData')).toEqual(graphData);
291
- return [4 /*yield*/, (0, test_utils_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
292
- var onHistoryCircleMouseOver;
293
- return __generator(this, function (_a) {
294
- onHistoryCircleMouseOver = wrapper.find(HistoryGraph_1.HistoryGraph).prop('onHistoryCircleMouseOver');
295
- if (onHistoryCircleMouseOver) {
296
- onHistoryCircleMouseOver('entities/123', 1636456567409, 0);
297
- }
298
- return [2 /*return*/];
299
- });
300
- }); })];
263
+ user = setUp().user;
264
+ return [4 /*yield*/, user.hover(react_2.screen.getAllByTestId('history-circle')[0])];
301
265
  case 1:
302
266
  _a.sent();
303
- expect(mdm_sdk_1.getEntity).toHaveBeenCalledWith('entities/123', {
304
- time: 1636456567409,
305
- select: 'crosswalks'
306
- });
307
- expect(mdm_sdk_1.getEntity.mock.calls.length).toBe(1);
308
- return [4 /*yield*/, (0, test_utils_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
309
- return __generator(this, function (_a) {
310
- Promise.resolve();
311
- return [2 /*return*/];
312
- });
313
- }); })];
267
+ expect(mdm_sdk_1.getEntity).toHaveBeenCalledWith('entities/123', { time: 1636456567409, select: 'crosswalks' });
268
+ return [4 /*yield*/, user.hover(react_2.screen.getAllByTestId('history-circle')[0])];
314
269
  case 2:
315
270
  _a.sent();
316
- wrapper.update();
317
- expect(wrapper.find(HistoryGraph_1.HistoryGraph).prop('graphData')).toEqual(__assign(__assign({}, graphData), { rows: [__assign(__assign({}, graphData.rows[0]), { label: 'AMA, Reltio, DEA' }), graphData.rows[1]] }));
318
- return [4 /*yield*/, (0, test_utils_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
319
- var onHistoryCircleMouseOver;
320
- return __generator(this, function (_a) {
321
- onHistoryCircleMouseOver = wrapper.find(HistoryGraph_1.HistoryGraph).prop('onHistoryCircleMouseOver');
322
- if (onHistoryCircleMouseOver) {
323
- onHistoryCircleMouseOver('entities/123', 1636456567409, 0);
324
- }
325
- return [2 /*return*/];
326
- });
327
- }); })];
328
- case 3:
329
- _a.sent();
330
- expect(mdm_sdk_1.getEntity.mock.calls.length).toBe(1);
331
- wrapper.update();
332
- expect(wrapper.find(HistoryGraph_1.HistoryGraph).prop('graphData')).toEqual(__assign(__assign({}, graphData), { rows: [__assign(__assign({}, graphData.rows[0]), { label: 'AMA, Reltio, DEA' }), graphData.rows[1]] }));
271
+ react_2.screen.getByText('AMA, Reltio, DEA');
272
+ expect(mdm_sdk_1.getEntity).toHaveBeenCalledTimes(1);
333
273
  return [2 /*return*/];
334
274
  }
335
275
  });
336
276
  }); });
337
- it('handleHistoryCircleMouseOver handler should work correctly when crosswalks do not exist', function () { return __awaiter(void 0, void 0, void 0, function () {
338
- var wrapper, graphData;
277
+ it('should work correctly when there is no crosswalks for circle', function () { return __awaiter(void 0, void 0, void 0, function () {
278
+ var user;
339
279
  return __generator(this, function (_a) {
340
280
  switch (_a.label) {
341
281
  case 0:
342
282
  mdm_sdk_1.getEntity.mockImplementation(function () { return Promise.resolve({}); });
343
- wrapper = setUp();
344
- graphData = {
345
- historyLanes: historyData.historyLanes,
346
- rows: historyData.rows.map(function (row) { return (__assign(__assign({}, row), { height: 100 })); })
347
- };
348
- expect(wrapper.find(HistoryGraph_1.HistoryGraph).prop('graphData')).toEqual(graphData);
349
- return [4 /*yield*/, (0, test_utils_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
350
- var onHistoryCircleMouseOver;
351
- return __generator(this, function (_a) {
352
- onHistoryCircleMouseOver = wrapper.find(HistoryGraph_1.HistoryGraph).prop('onHistoryCircleMouseOver');
353
- if (onHistoryCircleMouseOver) {
354
- onHistoryCircleMouseOver('entities/123', 1636456567409, 0);
355
- }
356
- return [2 /*return*/];
357
- });
358
- }); })];
283
+ user = setUp().user;
284
+ return [4 /*yield*/, user.hover(react_2.screen.getAllByTestId('history-circle')[0])];
359
285
  case 1:
360
286
  _a.sent();
361
- expect(mdm_sdk_1.getEntity).toHaveBeenCalledWith('entities/123', {
362
- time: 1636456567409,
363
- select: 'crosswalks'
364
- });
365
- return [4 /*yield*/, (0, test_utils_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
366
- return __generator(this, function (_a) {
367
- Promise.resolve();
368
- return [2 /*return*/];
369
- });
370
- }); })];
287
+ expect(mdm_sdk_1.getEntity).toHaveBeenCalledWith('entities/123', { time: 1636456567409, select: 'crosswalks' });
288
+ return [4 /*yield*/, user.hover(react_2.screen.getAllByTestId('history-circle')[0])];
371
289
  case 2:
372
290
  _a.sent();
373
- wrapper.update();
374
- expect(wrapper.find(HistoryGraph_1.HistoryGraph).prop('graphData')).toEqual(__assign(__assign({}, graphData), { rows: [__assign(__assign({}, graphData.rows[0]), { label: 'No data' }), graphData.rows[1]] }));
291
+ react_2.screen.getByText('No data');
292
+ expect(mdm_sdk_1.getEntity).toHaveBeenCalledTimes(1);
375
293
  return [2 /*return*/];
376
294
  }
377
295
  });
@@ -92,6 +92,6 @@ var WorkflowComments = function (_a) {
92
92
  react_1.default.createElement(SmallIconButton_1.SmallIconButton, { icon: Send_1.default, disabled: comment.length === 0, onClick: sendComment, "data-reltio-id": "send-button" })), classes: { root: styles.filledInputRoot }, placeholder: ui_i18n_1.default.text('Write a comment'), value: comment, onKeyPress: handleKeyPress, onChange: handleChange, disableUnderline: true, multiline: true })),
93
93
  react_1.default.createElement("div", { className: styles.modeSwitcherWrapper },
94
94
  buttonsGroup.length === 1 && (react_1.default.createElement(Button_1.default, { variant: "outlined", onClick: buttonsGroup[0].onClick, disabled: actionRequestIsInProgress }, buttonsGroup[0].label)),
95
- buttonsGroup.length > 1 && (react_1.default.createElement(ModeSwitcherSelect_1.ModeSwitcherSelect, { buttonsGroup: buttonsGroup, value: currentAction, disabled: actionRequestIsInProgress })))));
95
+ buttonsGroup.length > 1 && (react_1.default.createElement(ModeSwitcherSelect_1.ModeSwitcherSelect, { buttonsGroup: buttonsGroup, value: currentAction, loading: actionRequestIsInProgress, disabled: actionRequestIsInProgress })))));
96
96
  };
97
97
  exports.WorkflowComments = WorkflowComments;
@@ -235,4 +235,10 @@ describe('WorkflowComments tests', function () {
235
235
  it('should not crash if preferredAction is undefined and workflowActions is empty array', function () {
236
236
  setUp({ props: __assign(__assign({}, defaultProps), { preferredAction: undefined, workflowActions: [] }) });
237
237
  });
238
+ it('should disabled action button and add loading if actionRequestIsInProgress is true', function () {
239
+ setUp({ props: __assign(__assign({}, defaultProps), { actionRequestIsInProgress: true }) });
240
+ var button = react_2.screen.getByRole('button', { name: 'Delete' });
241
+ expect(button).toHaveClass('Mui-disabled');
242
+ react_2.screen.getByTestId('mode-loading-spinner');
243
+ });
238
244
  });
@@ -13,8 +13,9 @@ type ModeSwitcherSelectProps = {
13
13
  buttonsGroup?: Button[];
14
14
  value: string;
15
15
  onChange?: (value: string) => void;
16
+ loading?: boolean;
16
17
  disabled?: boolean;
17
18
  variant?: 'normal' | 'thin';
18
19
  };
19
- export declare const ModeSwitcherSelect: ({ optionsGroup, buttonsGroup, value, onChange, disabled, variant }: ModeSwitcherSelectProps) => JSX.Element;
20
+ export declare const ModeSwitcherSelect: ({ optionsGroup, buttonsGroup, value, onChange, loading, disabled, variant }: ModeSwitcherSelectProps) => JSX.Element;
20
21
  export {};
@@ -26,10 +26,11 @@ import MenuItem from '@mui/material/MenuItem';
26
26
  import Box from '@mui/material/Box';
27
27
  import Typography from '@mui/material/Typography';
28
28
  import Tooltip from '@mui/material/Tooltip';
29
+ import CircularProgress from '@mui/material/CircularProgress';
29
30
  import { useStyles } from './styles';
30
31
  var isButton = function (value) { return 'onClick' in value; };
31
32
  export var ModeSwitcherSelect = function (_a) {
32
- var _b = _a.optionsGroup, optionsGroup = _b === void 0 ? [] : _b, _c = _a.buttonsGroup, buttonsGroup = _c === void 0 ? [] : _c, value = _a.value, onChange = _a.onChange, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.variant, variant = _e === void 0 ? 'normal' : _e;
33
+ var _b = _a.optionsGroup, optionsGroup = _b === void 0 ? [] : _b, _c = _a.buttonsGroup, buttonsGroup = _c === void 0 ? [] : _c, value = _a.value, onChange = _a.onChange, _d = _a.loading, loading = _d === void 0 ? false : _d, _e = _a.disabled, disabled = _e === void 0 ? false : _e, _f = _a.variant, variant = _f === void 0 ? 'normal' : _f;
33
34
  var styles = useStyles();
34
35
  var handleChange = function (e) {
35
36
  var value = e.target.value;
@@ -60,14 +61,14 @@ export var ModeSwitcherSelect = function (_a) {
60
61
  React.createElement(Typography, { className: styles.menuItemDescription }, description)))));
61
62
  });
62
63
  };
63
- return (React.createElement(Select, { classes: {
64
+ return (React.createElement(Select, { className: styles.select, classes: {
64
65
  select: classnames(styles.root, styles[variant]),
65
66
  icon: classnames(styles.arrowIcon, styles[variant]),
66
67
  outlined: styles.outlined
67
68
  }, value: value, onChange: handleChange, variant: "outlined", renderValue: function (value) {
68
69
  var _a = optionsGroup.find(propEq('value', value)) || {}, IconComponent = _a.icon, _b = _a.label, label = _b === void 0 ? value : _b;
69
70
  return (React.createElement(Box, { className: styles.currentValue },
70
- IconComponent && React.createElement(IconComponent, { className: styles.currentValueIcon }),
71
+ loading ? (React.createElement(CircularProgress, { size: "1em", "data-reltio-id": "mode-loading-spinner", className: styles.currentValueIcon })) : (IconComponent && React.createElement(IconComponent, { className: styles.currentValueIcon })),
71
72
  React.createElement(Tooltip, { title: label },
72
73
  React.createElement(Typography, { className: styles.currentValueText }, label))));
73
74
  }, MenuProps: {