@reltio/components 1.4.1896 → 1.4.1898
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.
- package/cjs/ModeSwitcherSelect/ModeSwitcherSelect.d.ts +2 -1
- package/cjs/ModeSwitcherSelect/ModeSwitcherSelect.js +4 -3
- package/cjs/ModeSwitcherSelect/ModeSwitcherSelect.test.js +232 -89
- package/cjs/ModeSwitcherSelect/styles.d.ts +1 -1
- package/cjs/ModeSwitcherSelect/styles.js +18 -0
- package/cjs/contexts/MdmModuleContext/context.d.ts +2 -0
- package/cjs/contexts/MdmModuleContext/hooks.d.ts +2 -1
- package/cjs/features/history/HistoryGraph/components/HistoryCircle/HistoryCircle.js +1 -1
- package/cjs/features/history/HistoryRow/HistoryRow.js +3 -1
- package/cjs/features/history/HistoryTree/HistoryTree.js +2 -7
- package/cjs/features/history/HistoryTree/HistoryTree.specs.js +141 -223
- package/cjs/features/workflow/WorkflowComments/WorkflowComments.js +1 -1
- package/cjs/features/workflow/WorkflowComments/WorkflowCommments.spec.js +6 -0
- package/esm/ModeSwitcherSelect/ModeSwitcherSelect.d.ts +2 -1
- package/esm/ModeSwitcherSelect/ModeSwitcherSelect.js +4 -3
- package/esm/ModeSwitcherSelect/ModeSwitcherSelect.test.js +232 -89
- package/esm/ModeSwitcherSelect/styles.d.ts +1 -1
- package/esm/ModeSwitcherSelect/styles.js +18 -0
- package/esm/contexts/MdmModuleContext/context.d.ts +2 -0
- package/esm/contexts/MdmModuleContext/hooks.d.ts +2 -1
- package/esm/features/history/HistoryGraph/components/HistoryCircle/HistoryCircle.js +1 -1
- package/esm/features/history/HistoryRow/HistoryRow.js +3 -1
- package/esm/features/history/HistoryTree/HistoryTree.js +2 -7
- package/esm/features/history/HistoryTree/HistoryTree.specs.js +141 -223
- package/esm/features/workflow/WorkflowComments/WorkflowComments.js +1 -1
- package/esm/features/workflow/WorkflowComments/WorkflowCommments.spec.js +6 -0
- 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
|
|
59
|
-
var
|
|
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
|
|
100
|
-
|
|
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 ?
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
|
|
132
|
-
expect(
|
|
133
|
-
var
|
|
134
|
-
expect(
|
|
135
|
-
|
|
136
|
-
expect(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
expect(
|
|
144
|
-
|
|
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
|
-
|
|
169
|
-
|
|
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
|
-
(
|
|
183
|
-
|
|
184
|
-
|
|
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
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
(
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
expect(
|
|
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
|
|
218
|
-
|
|
219
|
-
var
|
|
220
|
-
|
|
221
|
-
(
|
|
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
|
|
227
|
-
var
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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
|
-
|
|
268
|
-
|
|
269
|
-
|
|
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
|
-
|
|
286
|
-
|
|
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
|
-
|
|
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
|
-
|
|
317
|
-
expect(
|
|
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('
|
|
338
|
-
var
|
|
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
|
-
|
|
344
|
-
|
|
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
|
-
|
|
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
|
-
|
|
374
|
-
expect(
|
|
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.
|
|
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: {
|