@reltio/components 1.4.2154 → 1.4.2155
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/CollaborationItem/IntegrationCollaborationItem.test.js +1 -0
- package/CollaborationItem/components/Comment/Comment.test.js +1 -0
- package/CollaborationItem/components/SendMessageArea/SendMessageArea.test.js +1 -1
- package/ScreenProfileBand/ScreenProfileBand.test.js +1 -1
- package/cjs/CollaborationItem/IntegrationCollaborationItem.test.js +1 -0
- package/cjs/CollaborationItem/components/Comment/Comment.test.js +1 -0
- package/cjs/CollaborationItem/components/SendMessageArea/SendMessageArea.test.js +1 -1
- package/cjs/ScreenProfileBand/ScreenProfileBand.test.js +1 -1
- package/cjs/contexts/CollaborationContext/index.d.ts +2 -0
- package/cjs/contexts/CollaborationContext/index.js +2 -1
- package/cjs/hooks/useCollaboration/useCollaboration.d.ts +1 -0
- package/cjs/hooks/useCollaboration/useCollaboration.js +43 -11
- package/cjs/hooks/useCollaboration/useCollaboration.test.js +243 -92
- package/contexts/CollaborationContext/index.d.ts +2 -0
- package/contexts/CollaborationContext/index.js +2 -1
- package/hooks/useCollaboration/useCollaboration.d.ts +1 -0
- package/hooks/useCollaboration/useCollaboration.js +44 -12
- package/hooks/useCollaboration/useCollaboration.test.js +244 -93
- package/package.json +2 -2
|
@@ -56,10 +56,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
56
56
|
};
|
|
57
57
|
import React from 'react';
|
|
58
58
|
import { renderHook, act } from '@testing-library/react-hooks';
|
|
59
|
-
import { getCommentsCount, getComment, createComment, createReply, deleteComment, updateComment, getComments, deleteReply, updateReply } from '@reltio/mdm-sdk';
|
|
59
|
+
import { getCommentsCount, getTotalCommentsCount, getComment, createComment, createReply, deleteComment, updateComment, getComments, deleteReply, updateReply } from '@reltio/mdm-sdk';
|
|
60
60
|
import { MdmModuleProvider } from '../../contexts/MdmModuleContext';
|
|
61
61
|
import { useCollaboration } from './useCollaboration';
|
|
62
|
-
jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { getCommentsCount: jest.fn(), getComment: jest.fn(), createComment: jest.fn(), createReply: jest.fn(), updateComment: jest.fn(), deleteComment: jest.fn(), getComments: jest.fn(), deleteReply: jest.fn(), updateReply: jest.fn() })); });
|
|
62
|
+
jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { getCommentsCount: jest.fn(), getTotalCommentsCount: jest.fn(), getComment: jest.fn(), createComment: jest.fn(), createReply: jest.fn(), updateComment: jest.fn(), deleteComment: jest.fn(), getComments: jest.fn(), deleteReply: jest.fn(), updateReply: jest.fn() })); });
|
|
63
63
|
describe('useCollaboration behaviour', function () {
|
|
64
64
|
var defaultMdmValues = {
|
|
65
65
|
uiPath: 'https://localhost:3000/ui/alenat',
|
|
@@ -77,28 +77,54 @@ describe('useCollaboration behaviour', function () {
|
|
|
77
77
|
return renderHook(useCollaboration, { initialProps: props, wrapper: Providers });
|
|
78
78
|
};
|
|
79
79
|
beforeEach(function () {
|
|
80
|
-
jest.clearAllMocks();
|
|
81
80
|
getComment.mockResolvedValue({ commentId: 'commentId' });
|
|
82
81
|
getCommentsCount.mockResolvedValue([{ objectId: 'uri1', comments: [] }]);
|
|
82
|
+
getTotalCommentsCount.mockResolvedValue({ total: 1 });
|
|
83
|
+
});
|
|
84
|
+
afterEach(function () {
|
|
85
|
+
jest.resetAllMocks();
|
|
83
86
|
});
|
|
84
87
|
it('should not call getCommentsCount if collaboration is not enabled', function () {
|
|
85
88
|
var mdmValues = __assign(__assign({}, defaultMdmValues), { collaborationPath: undefined, isCollaborationEnabled: false });
|
|
86
89
|
var result = setUp({ mdmValues: mdmValues }).result;
|
|
87
90
|
expect(result.current.commentsMap).toBe(null);
|
|
91
|
+
expect(result.current.totalCommentsCount).toBe(null);
|
|
88
92
|
expect(getCommentsCount).not.toHaveBeenCalled();
|
|
93
|
+
expect(getTotalCommentsCount).not.toHaveBeenCalled();
|
|
89
94
|
});
|
|
95
|
+
it('should not call getCommentsCount if totalCommentsCount is 0', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
96
|
+
var result;
|
|
97
|
+
return __generator(this, function (_a) {
|
|
98
|
+
switch (_a.label) {
|
|
99
|
+
case 0:
|
|
100
|
+
getTotalCommentsCount.mockResolvedValue({ total: 0 });
|
|
101
|
+
result = setUp().result;
|
|
102
|
+
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
103
|
+
return __generator(this, function (_a) {
|
|
104
|
+
switch (_a.label) {
|
|
105
|
+
case 0: return [4 /*yield*/, Promise.resolve()];
|
|
106
|
+
case 1:
|
|
107
|
+
_a.sent();
|
|
108
|
+
return [2 /*return*/];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}); })];
|
|
112
|
+
case 1:
|
|
113
|
+
_a.sent();
|
|
114
|
+
expect(getCommentsCount).not.toHaveBeenCalled();
|
|
115
|
+
expect(result.current.commentsMap).toEqual({});
|
|
116
|
+
return [2 /*return*/];
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}); });
|
|
90
120
|
it('should call getCommentsCount if collaboration is enabled and uris is undefined and update commentsMap value', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
91
121
|
var result;
|
|
92
122
|
return __generator(this, function (_a) {
|
|
93
123
|
switch (_a.label) {
|
|
94
124
|
case 0:
|
|
95
125
|
getCommentsCount.mockResolvedValueOnce([]);
|
|
126
|
+
getTotalCommentsCount.mockResolvedValueOnce({ total: 1 });
|
|
96
127
|
result = setUp().result;
|
|
97
|
-
expect(getCommentsCount).toHaveBeenCalledWith({
|
|
98
|
-
uris: [],
|
|
99
|
-
tenant: 'alenat',
|
|
100
|
-
collaborationPath: defaultMdmValues.collaborationPath
|
|
101
|
-
});
|
|
102
128
|
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
103
129
|
return __generator(this, function (_a) {
|
|
104
130
|
switch (_a.label) {
|
|
@@ -111,12 +137,17 @@ describe('useCollaboration behaviour', function () {
|
|
|
111
137
|
}); })];
|
|
112
138
|
case 1:
|
|
113
139
|
_a.sent();
|
|
140
|
+
expect(getCommentsCount).toHaveBeenCalledWith({
|
|
141
|
+
uris: [],
|
|
142
|
+
tenant: 'alenat',
|
|
143
|
+
collaborationPath: defaultMdmValues.collaborationPath
|
|
144
|
+
});
|
|
114
145
|
expect(result.current.commentsMap).toEqual({});
|
|
115
146
|
return [2 /*return*/];
|
|
116
147
|
}
|
|
117
148
|
});
|
|
118
149
|
}); });
|
|
119
|
-
it('should call getCommentsCount if collaboration is enabled and update commentsMap value', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
150
|
+
it('should call getCommentsCount if collaboration is enabled and totalCommentsCount is more then 0 and update commentsMap value', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
120
151
|
var comments, result;
|
|
121
152
|
return __generator(this, function (_a) {
|
|
122
153
|
switch (_a.label) {
|
|
@@ -126,12 +157,8 @@ describe('useCollaboration behaviour', function () {
|
|
|
126
157
|
{ commentId: 'id2', status: 'open', replies: 2 }
|
|
127
158
|
];
|
|
128
159
|
getCommentsCount.mockResolvedValueOnce([{ objectId: 'uri1', comments: comments }]);
|
|
160
|
+
getTotalCommentsCount.mockResolvedValueOnce({ total: 2 });
|
|
129
161
|
result = setUp({ props: { objectIds: ['uri1'] } }).result;
|
|
130
|
-
expect(getCommentsCount).toHaveBeenCalledWith({
|
|
131
|
-
uris: ['uri1'],
|
|
132
|
-
tenant: 'alenat',
|
|
133
|
-
collaborationPath: defaultMdmValues.collaborationPath
|
|
134
|
-
});
|
|
135
162
|
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
136
163
|
return __generator(this, function (_a) {
|
|
137
164
|
switch (_a.label) {
|
|
@@ -144,19 +171,24 @@ describe('useCollaboration behaviour', function () {
|
|
|
144
171
|
}); })];
|
|
145
172
|
case 1:
|
|
146
173
|
_a.sent();
|
|
174
|
+
expect(getCommentsCount).toHaveBeenCalledWith({
|
|
175
|
+
uris: ['uri1'],
|
|
176
|
+
tenant: 'alenat',
|
|
177
|
+
collaborationPath: defaultMdmValues.collaborationPath
|
|
178
|
+
});
|
|
147
179
|
expect(result.current.commentsMap).toEqual({ uri1: comments });
|
|
148
180
|
return [2 /*return*/];
|
|
149
181
|
}
|
|
150
182
|
});
|
|
151
183
|
}); });
|
|
152
|
-
it('should set commentsMap value as null in case of unsuccessful request', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
184
|
+
it('should set commentsMap value as null in case of unsuccessful getCommentsCount request', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
153
185
|
var result;
|
|
154
186
|
return __generator(this, function (_a) {
|
|
155
187
|
switch (_a.label) {
|
|
156
188
|
case 0:
|
|
157
|
-
|
|
189
|
+
getTotalCommentsCount.mockResolvedValueOnce({ total: 1 });
|
|
190
|
+
getCommentsCount.mockRejectedValueOnce(new Error('Fail'));
|
|
158
191
|
result = setUp().result;
|
|
159
|
-
expect(getCommentsCount).toHaveBeenCalled();
|
|
160
192
|
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
161
193
|
return __generator(this, function (_a) {
|
|
162
194
|
switch (_a.label) {
|
|
@@ -169,6 +201,7 @@ describe('useCollaboration behaviour', function () {
|
|
|
169
201
|
}); })];
|
|
170
202
|
case 1:
|
|
171
203
|
_a.sent();
|
|
204
|
+
expect(getCommentsCount).toHaveBeenCalled();
|
|
172
205
|
expect(result.current.commentsMap).toBe(null);
|
|
173
206
|
return [2 /*return*/];
|
|
174
207
|
}
|
|
@@ -190,7 +223,20 @@ describe('useCollaboration behaviour', function () {
|
|
|
190
223
|
return Promise.resolve([{ objectId: 'uri2', comments: secondComments }]);
|
|
191
224
|
}
|
|
192
225
|
});
|
|
226
|
+
getTotalCommentsCount.mockResolvedValueOnce({ total: 3 });
|
|
193
227
|
result = setUp({ props: { objectIds: ['uri1'] } }).result;
|
|
228
|
+
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
229
|
+
return __generator(this, function (_a) {
|
|
230
|
+
switch (_a.label) {
|
|
231
|
+
case 0: return [4 /*yield*/, Promise.resolve()];
|
|
232
|
+
case 1:
|
|
233
|
+
_a.sent();
|
|
234
|
+
return [2 /*return*/];
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}); })];
|
|
238
|
+
case 1:
|
|
239
|
+
_a.sent();
|
|
194
240
|
expect(getCommentsCount).toHaveBeenCalledWith({
|
|
195
241
|
uris: ['uri1'],
|
|
196
242
|
tenant: 'alenat',
|
|
@@ -202,7 +248,7 @@ describe('useCollaboration behaviour', function () {
|
|
|
202
248
|
return [2 /*return*/];
|
|
203
249
|
});
|
|
204
250
|
}); })];
|
|
205
|
-
case
|
|
251
|
+
case 2:
|
|
206
252
|
_a.sent();
|
|
207
253
|
expect(getCommentsCount).toHaveBeenCalledWith({
|
|
208
254
|
uris: ['uri2'],
|
|
@@ -230,7 +276,20 @@ describe('useCollaboration behaviour', function () {
|
|
|
230
276
|
return Promise.resolve([{ objectId: 'uri2', comments: secondComments }]);
|
|
231
277
|
}
|
|
232
278
|
});
|
|
279
|
+
getTotalCommentsCount.mockResolvedValue({ total: 3 });
|
|
233
280
|
_a = setUp({ props: { objectIds: ['uri1'] } }), result = _a.result, rerender = _a.rerender;
|
|
281
|
+
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
282
|
+
return __generator(this, function (_a) {
|
|
283
|
+
switch (_a.label) {
|
|
284
|
+
case 0: return [4 /*yield*/, Promise.resolve()];
|
|
285
|
+
case 1:
|
|
286
|
+
_a.sent();
|
|
287
|
+
return [2 /*return*/];
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
}); })];
|
|
291
|
+
case 1:
|
|
292
|
+
_b.sent();
|
|
234
293
|
expect(getCommentsCount).toHaveBeenCalledWith({
|
|
235
294
|
uris: ['uri1'],
|
|
236
295
|
tenant: 'alenat',
|
|
@@ -248,7 +307,7 @@ describe('useCollaboration behaviour', function () {
|
|
|
248
307
|
}
|
|
249
308
|
});
|
|
250
309
|
}); })];
|
|
251
|
-
case
|
|
310
|
+
case 2:
|
|
252
311
|
_b.sent();
|
|
253
312
|
expect(getCommentsCount).toHaveBeenCalledWith({
|
|
254
313
|
uris: ['uri2'],
|
|
@@ -385,7 +444,12 @@ describe('useCollaboration behaviour', function () {
|
|
|
385
444
|
replies: 2
|
|
386
445
|
}
|
|
387
446
|
];
|
|
388
|
-
|
|
447
|
+
getTotalCommentsCount.mockResolvedValueOnce({ total: 3 });
|
|
448
|
+
getCommentsCount
|
|
449
|
+
.mockResolvedValueOnce([{ objectId: 'uri1', comments: comments }])
|
|
450
|
+
.mockResolvedValueOnce([
|
|
451
|
+
{ objectId: 'uri1', comments: __spreadArray(__spreadArray([], comments, true), [{ commentId: 'commentId', replies: 0, status: 'open' }], false) }
|
|
452
|
+
]);
|
|
389
453
|
createComment.mockResolvedValueOnce([{ commentId: 'commentId' }]);
|
|
390
454
|
result = setUp().result;
|
|
391
455
|
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -403,33 +467,16 @@ describe('useCollaboration behaviour', function () {
|
|
|
403
467
|
expect(result.current.commentsMap).toEqual({ uri1: comments });
|
|
404
468
|
expect(result.current.currentComment).toBe(null);
|
|
405
469
|
expect(result.current.sending).toBe(false);
|
|
406
|
-
act(function () {
|
|
407
|
-
result.current.createComment({
|
|
408
|
-
content: 'content',
|
|
409
|
-
namedUsers: [],
|
|
410
|
-
objectType: 'entity',
|
|
411
|
-
relatedObjectUris: ['uri1'],
|
|
412
|
-
uri: 'uri1'
|
|
413
|
-
});
|
|
414
|
-
});
|
|
415
|
-
expect(result.current.sending).toBe(true);
|
|
416
|
-
expect(createComment).toHaveBeenCalledWith({
|
|
417
|
-
collaborationPath: '123',
|
|
418
|
-
tenant: 'alenat',
|
|
419
|
-
data: {
|
|
420
|
-
objectId: 'uri1',
|
|
421
|
-
content: 'content',
|
|
422
|
-
relatedObjectUris: ['uri1'],
|
|
423
|
-
objectType: 'entity',
|
|
424
|
-
visibility: 'public',
|
|
425
|
-
namedUsers: [],
|
|
426
|
-
permanentLink: 'https://tst-01.reltio.com/nui/alenat/profile?entityUri=entities%2F2jWtLtNc&commentId=%7BcommentId%7D'
|
|
427
|
-
}
|
|
428
|
-
});
|
|
429
470
|
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
430
471
|
return __generator(this, function (_a) {
|
|
431
472
|
switch (_a.label) {
|
|
432
|
-
case 0: return [4 /*yield*/,
|
|
473
|
+
case 0: return [4 /*yield*/, result.current.createComment({
|
|
474
|
+
content: 'content',
|
|
475
|
+
namedUsers: [],
|
|
476
|
+
objectType: 'entity',
|
|
477
|
+
relatedObjectUris: ['uri1'],
|
|
478
|
+
uri: 'uri1'
|
|
479
|
+
})];
|
|
433
480
|
case 1:
|
|
434
481
|
_a.sent();
|
|
435
482
|
return [2 /*return*/];
|
|
@@ -446,15 +493,23 @@ describe('useCollaboration behaviour', function () {
|
|
|
446
493
|
uri1: __spreadArray(__spreadArray([], comments, true), [{ commentId: 'commentId', replies: 0, status: 'open' }], false)
|
|
447
494
|
});
|
|
448
495
|
createComment.mockResolvedValueOnce([{ commentId: 'commentId2' }]);
|
|
496
|
+
getCommentsCount.mockResolvedValueOnce([
|
|
497
|
+
{ objectId: 'uri1', comments: __spreadArray(__spreadArray([], comments, true), [{ commentId: 'commentId', replies: 0, status: 'open' }], false) },
|
|
498
|
+
{ objectId: 'uri2', comments: [{ commentId: 'commentId2', replies: 0, status: 'open' }] }
|
|
499
|
+
]);
|
|
449
500
|
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
450
501
|
return __generator(this, function (_a) {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
502
|
+
switch (_a.label) {
|
|
503
|
+
case 0: return [4 /*yield*/, result.current.createComment({
|
|
504
|
+
content: 'content',
|
|
505
|
+
namedUsers: [],
|
|
506
|
+
objectType: 'entity',
|
|
507
|
+
uri: 'uri2'
|
|
508
|
+
})];
|
|
509
|
+
case 1:
|
|
510
|
+
_a.sent();
|
|
511
|
+
return [2 /*return*/];
|
|
512
|
+
}
|
|
458
513
|
});
|
|
459
514
|
}); })];
|
|
460
515
|
case 3:
|
|
@@ -483,7 +538,14 @@ describe('useCollaboration behaviour', function () {
|
|
|
483
538
|
{ commentId: 'id1', content: 'first comment', status: 'open', replies: [] },
|
|
484
539
|
{ commentId: 'id2', content: 'second comment', status: 'open', replies: [] }
|
|
485
540
|
];
|
|
486
|
-
getCommentsCount
|
|
541
|
+
getCommentsCount
|
|
542
|
+
.mockResolvedValueOnce([{ objectId: 'uri1', comments: commentsCount }])
|
|
543
|
+
.mockResolvedValueOnce([
|
|
544
|
+
{ objectId: 'uri1', comments: [commentsCount[0], { commentId: 'id2', status: 'open', replies: 3 }] }
|
|
545
|
+
])
|
|
546
|
+
.mockResolvedValueOnce([
|
|
547
|
+
{ objectId: 'uri1', comments: [commentsCount[0], { commentId: 'id2', status: 'resolved', replies: 4 }] }
|
|
548
|
+
]);
|
|
487
549
|
getComments.mockResolvedValue({ items: comments });
|
|
488
550
|
getComment.mockResolvedValueOnce({
|
|
489
551
|
commentId: 'id2',
|
|
@@ -616,7 +678,11 @@ describe('useCollaboration behaviour', function () {
|
|
|
616
678
|
{ commentId: 'id1', status: 'open', content: 'first comment', replies: [] },
|
|
617
679
|
{ commentId: 'id2', status: 'open', content: 'second comment', replies: [] }
|
|
618
680
|
];
|
|
619
|
-
getCommentsCount
|
|
681
|
+
getCommentsCount
|
|
682
|
+
.mockResolvedValueOnce([{ objectId: 'uri1', comments: commentsCount }])
|
|
683
|
+
.mockResolvedValueOnce([
|
|
684
|
+
{ objectId: 'uri1', comments: [commentsCount[0], { commentId: 'id2', status: 'resolved', replies: 3 }] }
|
|
685
|
+
]);
|
|
620
686
|
getComment.mockResolvedValueOnce({ commentId: 'id2', replies: [] });
|
|
621
687
|
getComments.mockResolvedValue({ items: comments });
|
|
622
688
|
createReply.mockResolvedValueOnce([{ content: '', action: 'resolve' }]);
|
|
@@ -689,7 +755,11 @@ describe('useCollaboration behaviour', function () {
|
|
|
689
755
|
{ commentId: 'id1', status: 'open', content: 'first comment', replies: [] },
|
|
690
756
|
{ commentId: 'id2', status: 'open', content: 'second comment', replies: [] }
|
|
691
757
|
];
|
|
692
|
-
getCommentsCount
|
|
758
|
+
getCommentsCount
|
|
759
|
+
.mockResolvedValueOnce([{ objectId: 'uri1', comments: commentsCount }])
|
|
760
|
+
.mockResolvedValueOnce([
|
|
761
|
+
{ objectId: 'uri1', comments: [commentsCount[0], { commentId: 'id2', status: 'open', replies: 3 }] }
|
|
762
|
+
]);
|
|
693
763
|
getComment.mockResolvedValueOnce({ commentId: 'id2', replies: [] });
|
|
694
764
|
getComments.mockResolvedValue({
|
|
695
765
|
items: comments
|
|
@@ -862,9 +932,12 @@ describe('useCollaboration behaviour', function () {
|
|
|
862
932
|
{ commentId: 'id1', content: 'text 1', status: 'open', replies: [] },
|
|
863
933
|
{ commentId: 'id2', content: 'text2', status: 'open', replies: [] }
|
|
864
934
|
];
|
|
865
|
-
expectedCommentsCount =
|
|
866
|
-
expectedComments =
|
|
867
|
-
|
|
935
|
+
expectedCommentsCount = [{ commentId: 'id2', status: 'open', replies: 0 }];
|
|
936
|
+
expectedComments = [{ commentId: 'id2', content: 'text2', status: 'open', replies: [] }];
|
|
937
|
+
getTotalCommentsCount.mockResolvedValueOnce({ total: 2 });
|
|
938
|
+
getCommentsCount
|
|
939
|
+
.mockResolvedValueOnce([{ objectId: 'uri1', comments: commentsCount }])
|
|
940
|
+
.mockResolvedValueOnce([{ objectId: 'uri1', comments: expectedCommentsCount }]);
|
|
868
941
|
getComments.mockResolvedValueOnce({ items: comments });
|
|
869
942
|
deleteComment.mockResolvedValueOnce('');
|
|
870
943
|
result = setUp().result;
|
|
@@ -879,28 +952,20 @@ describe('useCollaboration behaviour', function () {
|
|
|
879
952
|
expect(result.current.comments).toEqual(comments);
|
|
880
953
|
expect(result.current.commentsMap).toEqual({ uri1: commentsCount });
|
|
881
954
|
expect(result.current.sending).toBe(false);
|
|
882
|
-
act(function () {
|
|
883
|
-
result.current.deleteComment({ commentId: 'id1', uri: 'uri1' });
|
|
884
|
-
});
|
|
885
|
-
expect(result.current.sending).toBe(true);
|
|
886
|
-
expect(deleteComment).toHaveBeenCalledWith({
|
|
887
|
-
collaborationPath: '123',
|
|
888
|
-
tenant: 'alenat',
|
|
889
|
-
commentId: 'id1'
|
|
890
|
-
});
|
|
891
955
|
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
892
956
|
return __generator(this, function (_a) {
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
case 1:
|
|
896
|
-
_a.sent();
|
|
897
|
-
return [2 /*return*/];
|
|
898
|
-
}
|
|
957
|
+
result.current.deleteComment({ commentId: 'id1', uri: 'uri1' });
|
|
958
|
+
return [2 /*return*/];
|
|
899
959
|
});
|
|
900
960
|
}); })];
|
|
901
961
|
case 2:
|
|
902
962
|
_a.sent();
|
|
903
963
|
expect(result.current.sending).toBe(false);
|
|
964
|
+
expect(deleteComment).toHaveBeenCalledWith({
|
|
965
|
+
collaborationPath: '123',
|
|
966
|
+
tenant: 'alenat',
|
|
967
|
+
commentId: 'id1'
|
|
968
|
+
});
|
|
904
969
|
expect(result.current.commentsMap).toEqual({
|
|
905
970
|
uri1: expectedCommentsCount
|
|
906
971
|
});
|
|
@@ -918,13 +983,23 @@ describe('useCollaboration behaviour', function () {
|
|
|
918
983
|
{ commentId: 'id1', status: 'open', replies: 1 },
|
|
919
984
|
{ commentId: 'id2', status: 'open', replies: 2 }
|
|
920
985
|
];
|
|
921
|
-
|
|
986
|
+
getTotalCommentsCount.mockResolvedValueOnce({ total: commentsCount.length });
|
|
987
|
+
getCommentsCount
|
|
988
|
+
.mockResolvedValueOnce([{ objectId: 'uri1', comments: commentsCount }])
|
|
989
|
+
.mockResolvedValueOnce([
|
|
990
|
+
{ objectId: 'uri1', comments: [commentsCount[0], { commentId: 'id2', status: 'open', replies: 2 }] },
|
|
991
|
+
{ objectId: 'uri2', comments: [] }
|
|
992
|
+
]);
|
|
922
993
|
createReply.mockResolvedValueOnce([{ content: 'reply message' }]);
|
|
923
994
|
result = setUp().result;
|
|
924
995
|
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
925
996
|
return __generator(this, function (_a) {
|
|
926
|
-
|
|
927
|
-
|
|
997
|
+
switch (_a.label) {
|
|
998
|
+
case 0: return [4 /*yield*/, Promise.resolve()];
|
|
999
|
+
case 1:
|
|
1000
|
+
_a.sent();
|
|
1001
|
+
return [2 /*return*/];
|
|
1002
|
+
}
|
|
928
1003
|
});
|
|
929
1004
|
}); })];
|
|
930
1005
|
case 1:
|
|
@@ -941,6 +1016,9 @@ describe('useCollaboration behaviour', function () {
|
|
|
941
1016
|
uri: 'uri2'
|
|
942
1017
|
})];
|
|
943
1018
|
case 1:
|
|
1019
|
+
_a.sent();
|
|
1020
|
+
return [4 /*yield*/, Promise.resolve()];
|
|
1021
|
+
case 2:
|
|
944
1022
|
_a.sent();
|
|
945
1023
|
return [2 /*return*/];
|
|
946
1024
|
}
|
|
@@ -967,14 +1045,23 @@ describe('useCollaboration behaviour', function () {
|
|
|
967
1045
|
];
|
|
968
1046
|
expectedCommentsCount = [{ commentId: 'id1', status: 'open', replies: 0 }];
|
|
969
1047
|
expectedComments = [{ commentId: 'id1', content: 'text 1', status: 'open', replies: [] }];
|
|
970
|
-
|
|
1048
|
+
getTotalCommentsCount.mockResolvedValueOnce({ total: 2 }).mockResolvedValueOnce({ total: 1 });
|
|
1049
|
+
getCommentsCount
|
|
1050
|
+
.mockResolvedValueOnce([{ objectId: 'uri1', comments: commentsCount }])
|
|
1051
|
+
.mockResolvedValueOnce([{ objectId: 'uri1', comments: expectedCommentsCount }]);
|
|
971
1052
|
getComments.mockResolvedValue({ items: comments });
|
|
972
1053
|
deleteReply.mockResolvedValueOnce('');
|
|
973
1054
|
result = setUp().result;
|
|
974
1055
|
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
975
1056
|
return __generator(this, function (_a) {
|
|
976
|
-
|
|
977
|
-
|
|
1057
|
+
switch (_a.label) {
|
|
1058
|
+
case 0:
|
|
1059
|
+
result.current.getComments('uri');
|
|
1060
|
+
return [4 /*yield*/, Promise.resolve()];
|
|
1061
|
+
case 1:
|
|
1062
|
+
_a.sent();
|
|
1063
|
+
return [2 /*return*/];
|
|
1064
|
+
}
|
|
978
1065
|
});
|
|
979
1066
|
}); })];
|
|
980
1067
|
case 1:
|
|
@@ -982,24 +1069,16 @@ describe('useCollaboration behaviour', function () {
|
|
|
982
1069
|
expect(result.current.comments).toEqual(comments);
|
|
983
1070
|
expect(result.current.commentsMap).toEqual({ uri1: commentsCount });
|
|
984
1071
|
expect(result.current.sending).toBe(false);
|
|
985
|
-
act(function () {
|
|
986
|
-
result.current.deleteReply({
|
|
987
|
-
commentId: 'id1',
|
|
988
|
-
uri: 'uri1',
|
|
989
|
-
reply: comments[0].replies[0]
|
|
990
|
-
});
|
|
991
|
-
});
|
|
992
|
-
expect(result.current.sending).toBe(true);
|
|
993
|
-
expect(deleteReply).toHaveBeenCalledWith({
|
|
994
|
-
collaborationPath: '123',
|
|
995
|
-
tenant: 'alenat',
|
|
996
|
-
commentId: 'id1',
|
|
997
|
-
replyId: 'replyId1'
|
|
998
|
-
});
|
|
999
1072
|
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1000
1073
|
return __generator(this, function (_a) {
|
|
1001
1074
|
switch (_a.label) {
|
|
1002
|
-
case 0:
|
|
1075
|
+
case 0:
|
|
1076
|
+
result.current.deleteReply({
|
|
1077
|
+
commentId: 'id1',
|
|
1078
|
+
uri: 'uri1',
|
|
1079
|
+
reply: comments[0].replies[0]
|
|
1080
|
+
});
|
|
1081
|
+
return [4 /*yield*/, Promise.resolve()];
|
|
1003
1082
|
case 1:
|
|
1004
1083
|
_a.sent();
|
|
1005
1084
|
return [2 /*return*/];
|
|
@@ -1009,6 +1088,12 @@ describe('useCollaboration behaviour', function () {
|
|
|
1009
1088
|
case 2:
|
|
1010
1089
|
_a.sent();
|
|
1011
1090
|
expect(result.current.sending).toBe(false);
|
|
1091
|
+
expect(deleteReply).toHaveBeenCalledWith({
|
|
1092
|
+
collaborationPath: '123',
|
|
1093
|
+
tenant: 'alenat',
|
|
1094
|
+
commentId: 'id1',
|
|
1095
|
+
replyId: 'replyId1'
|
|
1096
|
+
});
|
|
1012
1097
|
expect(result.current.commentsMap).toEqual({
|
|
1013
1098
|
uri1: expectedCommentsCount
|
|
1014
1099
|
});
|
|
@@ -1040,6 +1125,7 @@ describe('useCollaboration behaviour', function () {
|
|
|
1040
1125
|
updateReply.mockResolvedValueOnce(editedReply);
|
|
1041
1126
|
getComment.mockResolvedValueOnce(initialComment);
|
|
1042
1127
|
getComments.mockResolvedValueOnce({ items: initialComments });
|
|
1128
|
+
getTotalCommentsCount.mockResolvedValue({ total: 2 });
|
|
1043
1129
|
result = setUp().result;
|
|
1044
1130
|
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1045
1131
|
return __generator(this, function (_a) {
|
|
@@ -1096,6 +1182,7 @@ describe('useCollaboration behaviour', function () {
|
|
|
1096
1182
|
return __generator(this, function (_a) {
|
|
1097
1183
|
switch (_a.label) {
|
|
1098
1184
|
case 0:
|
|
1185
|
+
getTotalCommentsCount.mockResolvedValue({ total: 1 });
|
|
1099
1186
|
result = setUp().result;
|
|
1100
1187
|
expect(result.current.getCommentState('attrUri', 'commentUri')).toEqual({});
|
|
1101
1188
|
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -1138,6 +1225,7 @@ describe('useCollaboration behaviour', function () {
|
|
|
1138
1225
|
return __generator(this, function (_a) {
|
|
1139
1226
|
switch (_a.label) {
|
|
1140
1227
|
case 0:
|
|
1228
|
+
getTotalCommentsCount.mockResolvedValue({ total: 1 });
|
|
1141
1229
|
result = setUp().result;
|
|
1142
1230
|
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1143
1231
|
return __generator(this, function (_a) {
|
|
@@ -1174,6 +1262,7 @@ describe('useCollaboration behaviour', function () {
|
|
|
1174
1262
|
return __generator(this, function (_a) {
|
|
1175
1263
|
switch (_a.label) {
|
|
1176
1264
|
case 0:
|
|
1265
|
+
getTotalCommentsCount.mockResolvedValue({ total: 1 });
|
|
1177
1266
|
result = setUp().result;
|
|
1178
1267
|
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1179
1268
|
return __generator(this, function (_a) {
|
|
@@ -1230,4 +1319,66 @@ describe('useCollaboration behaviour', function () {
|
|
|
1230
1319
|
}
|
|
1231
1320
|
});
|
|
1232
1321
|
}); });
|
|
1322
|
+
describe('totalCommentsCount behavior', function () {
|
|
1323
|
+
it('should not call getTotalCommentsCount if collaboration is not enabled', function () {
|
|
1324
|
+
var mdmValues = __assign(__assign({}, defaultMdmValues), { collaborationPath: undefined, isCollaborationEnabled: false });
|
|
1325
|
+
var result = setUp({ mdmValues: mdmValues }).result;
|
|
1326
|
+
expect(result.current.totalCommentsCount).toBe(null);
|
|
1327
|
+
expect(getTotalCommentsCount).not.toHaveBeenCalled();
|
|
1328
|
+
});
|
|
1329
|
+
it('should call getTotalCommentsCount if collaboration is enabled and update totalCommentsCount value', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1330
|
+
var result;
|
|
1331
|
+
return __generator(this, function (_a) {
|
|
1332
|
+
switch (_a.label) {
|
|
1333
|
+
case 0:
|
|
1334
|
+
getTotalCommentsCount.mockResolvedValueOnce({ total: 15 });
|
|
1335
|
+
result = setUp().result;
|
|
1336
|
+
expect(getTotalCommentsCount).toHaveBeenCalledWith({
|
|
1337
|
+
relatedObjectUri: '1',
|
|
1338
|
+
collaborationPath: '123',
|
|
1339
|
+
tenant: 'alenat'
|
|
1340
|
+
});
|
|
1341
|
+
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1342
|
+
return __generator(this, function (_a) {
|
|
1343
|
+
switch (_a.label) {
|
|
1344
|
+
case 0: return [4 /*yield*/, Promise.resolve()];
|
|
1345
|
+
case 1:
|
|
1346
|
+
_a.sent();
|
|
1347
|
+
return [2 /*return*/];
|
|
1348
|
+
}
|
|
1349
|
+
});
|
|
1350
|
+
}); })];
|
|
1351
|
+
case 1:
|
|
1352
|
+
_a.sent();
|
|
1353
|
+
expect(result.current.totalCommentsCount).toBe(15);
|
|
1354
|
+
return [2 /*return*/];
|
|
1355
|
+
}
|
|
1356
|
+
});
|
|
1357
|
+
}); });
|
|
1358
|
+
it('should set totalCommentsCount as null in case of unsuccessful request', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1359
|
+
var result;
|
|
1360
|
+
return __generator(this, function (_a) {
|
|
1361
|
+
switch (_a.label) {
|
|
1362
|
+
case 0:
|
|
1363
|
+
getTotalCommentsCount.mockRejectedValueOnce(new Error('Network error'));
|
|
1364
|
+
result = setUp().result;
|
|
1365
|
+
expect(getTotalCommentsCount).toHaveBeenCalled();
|
|
1366
|
+
return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1367
|
+
return __generator(this, function (_a) {
|
|
1368
|
+
switch (_a.label) {
|
|
1369
|
+
case 0: return [4 /*yield*/, Promise.resolve()];
|
|
1370
|
+
case 1:
|
|
1371
|
+
_a.sent();
|
|
1372
|
+
return [2 /*return*/];
|
|
1373
|
+
}
|
|
1374
|
+
});
|
|
1375
|
+
}); })];
|
|
1376
|
+
case 1:
|
|
1377
|
+
_a.sent();
|
|
1378
|
+
expect(result.current.totalCommentsCount).toBe(null);
|
|
1379
|
+
return [2 /*return*/];
|
|
1380
|
+
}
|
|
1381
|
+
});
|
|
1382
|
+
}); });
|
|
1383
|
+
});
|
|
1233
1384
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2155",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE FILE",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"@fluentui/react-context-selector": "^9.1.26",
|
|
12
12
|
"@googlemaps/markerclusterer": "^2.5.3",
|
|
13
13
|
"@react-sigma/core": "3.4.0",
|
|
14
|
-
"@reltio/mdm-sdk": "^1.4.
|
|
14
|
+
"@reltio/mdm-sdk": "^1.4.1976",
|
|
15
15
|
"@vis.gl/react-google-maps": "^1.3.0",
|
|
16
16
|
"d3-cloud": "^1.2.5",
|
|
17
17
|
"d3-geo": "^2.0.1",
|