@reltio/components 1.4.2155 → 1.4.2156

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.
@@ -51,7 +51,7 @@ import { getCommentsCount, getAllUsersForTenant, Mode } from '@reltio/mdm-sdk';
51
51
  import { ScreenProfileBand } from './ScreenProfileBand';
52
52
  import { MdmModuleProvider } from '../contexts/MdmModuleContext';
53
53
  import { ActionsHookProvider } from '../contexts/ActionsHookContext';
54
- jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { getCommentsCount: jest.fn(), getTotalCommentsCount: jest.fn(function () { return Promise.resolve({ total: 1 }); }), getAllUsersForTenant: jest.fn() })); });
54
+ jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { getCommentsCount: jest.fn(), getAllUsersForTenant: jest.fn() })); });
55
55
  var defaultEntity = {
56
56
  uri: 'entities/uri1',
57
57
  type: 'configuration/entityTypes/HCO',
@@ -56,7 +56,7 @@ var mdm_sdk_1 = require("@reltio/mdm-sdk");
56
56
  var ScreenProfileBand_1 = require("./ScreenProfileBand");
57
57
  var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
58
58
  var ActionsHookContext_1 = require("../contexts/ActionsHookContext");
59
- jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { getCommentsCount: jest.fn(), getTotalCommentsCount: jest.fn(function () { return Promise.resolve({ total: 1 }); }), getAllUsersForTenant: jest.fn() })); });
59
+ jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { getCommentsCount: jest.fn(), getAllUsersForTenant: jest.fn() })); });
60
60
  var defaultEntity = {
61
61
  uri: 'entities/uri1',
62
62
  type: 'configuration/entityTypes/HCO',
@@ -3,8 +3,9 @@ type Props = {
3
3
  objectIds?: string[];
4
4
  objectTypes?: CollaborationObjectTypes[];
5
5
  enabled?: boolean;
6
+ needsTotalCount?: boolean;
6
7
  };
7
- export declare const useCollaboration: ({ objectIds, objectTypes, enabled }: Props) => {
8
+ export declare const useCollaboration: ({ objectIds, objectTypes, enabled, needsTotalCount }: Props) => {
8
9
  clearCurrentComment: () => void;
9
10
  comments: Comment[];
10
11
  commentsMap: CommentsMap;
@@ -38,19 +38,19 @@ var getUpdatedReplies = function (comment, reply) {
38
38
  var defaultObjectIds = [];
39
39
  var catchErrorInRequest = function (e) { return console.warn('Collaboration error', e); };
40
40
  var useCollaboration = function (_a) {
41
- var _b = _a.objectIds, objectIds = _b === void 0 ? defaultObjectIds : _b, objectTypes = _a.objectTypes, _c = _a.enabled, enabled = _c === void 0 ? true : _c;
41
+ var _b = _a.objectIds, objectIds = _b === void 0 ? defaultObjectIds : _b, objectTypes = _a.objectTypes, _c = _a.enabled, enabled = _c === void 0 ? true : _c, _d = _a.needsTotalCount, needsTotalCount = _d === void 0 ? false : _d;
42
42
  var entity = (0, MdmModuleContext_1.useMdmEntity)();
43
43
  var tenant = (0, MdmModuleContext_1.useMdmTenant)();
44
44
  var collaborationPath = (0, MdmModuleContext_1.useMdmCollaborationPath)();
45
45
  var isCollaborationEnabled = (0, MdmModuleContext_1.useMdmIsCollaborationEnabled)() && enabled;
46
- var _d = (0, react_1.useState)(null), pageToken = _d[0], setPageToken = _d[1];
47
- var _e = (0, react_1.useState)([]), comments = _e[0], setComments = _e[1];
48
- var _f = (0, react_1.useState)(null), commentsMap = _f[0], setCommentsMap = _f[1];
49
- var _g = (0, react_1.useState)(null), totalCommentsCount = _g[0], setTotalCommentsCount = _g[1];
50
- var _h = (0, react_1.useState)(null), currentComment = _h[0], setCurrentComment = _h[1];
51
- var _j = (0, react_1.useState)(false), sending = _j[0], setSending = _j[1];
52
- var _k = (0, react_1.useState)(false), loading = _k[0], setLoading = _k[1];
53
- var _l = (0, react_1.useState)({}), collaborationStateMap = _l[0], setCollaborationStateMap = _l[1];
46
+ var _e = (0, react_1.useState)(null), pageToken = _e[0], setPageToken = _e[1];
47
+ var _f = (0, react_1.useState)([]), comments = _f[0], setComments = _f[1];
48
+ var _g = (0, react_1.useState)(null), commentsMap = _g[0], setCommentsMap = _g[1];
49
+ var _h = (0, react_1.useState)(null), totalCommentsCount = _h[0], setTotalCommentsCount = _h[1];
50
+ var _j = (0, react_1.useState)(null), currentComment = _j[0], setCurrentComment = _j[1];
51
+ var _k = (0, react_1.useState)(false), sending = _k[0], setSending = _k[1];
52
+ var _l = (0, react_1.useState)(false), loading = _l[0], setLoading = _l[1];
53
+ var _m = (0, react_1.useState)({}), collaborationStateMap = _m[0], setCollaborationStateMap = _m[1];
54
54
  var addCommentsToCommentsMap = (0, react_1.useCallback)(function (commentsMap) {
55
55
  setCommentsMap(function (currentCommentsMap) { return (__assign(__assign({}, currentCommentsMap), commentsMap)); });
56
56
  }, []);
@@ -58,18 +58,16 @@ var useCollaboration = function (_a) {
58
58
  var isCollaborationEnabledForEntity = isCollaborationEnabled && entityUri && !(0, mdm_sdk_1.isTempUri)(entityUri);
59
59
  var getCommentsCount = (0, react_1.useCallback)(function (objectIds, shouldResetCommentsMap) {
60
60
  if (shouldResetCommentsMap === void 0) { shouldResetCommentsMap = false; }
61
- if (!isCollaborationEnabledForEntity || totalCommentsCount == null) {
62
- return setCommentsMap(null);
63
- }
64
- if (totalCommentsCount === 0) {
65
- return shouldResetCommentsMap && setCommentsMap({});
61
+ if (!isCollaborationEnabledForEntity) {
62
+ setCommentsMap(null);
63
+ return;
66
64
  }
67
65
  var onError = function (e) {
68
66
  console.warn('Collaboration error', e);
69
67
  setCommentsMap(null);
70
68
  };
71
69
  (0, ramda_1.pipe)(mdm_sdk_1.getCommentsCount, (0, ramda_1.andThen)((0, ramda_1.map)((0, ramda_1.props)(['objectId', 'comments']))), (0, ramda_1.andThen)(ramda_1.fromPairs), (0, ramda_1.andThen)(shouldResetCommentsMap ? setCommentsMap : addCommentsToCommentsMap), (0, ramda_1.otherwise)(onError))({ uris: objectIds, tenant: tenant, collaborationPath: collaborationPath });
72
- }, [addCommentsToCommentsMap, collaborationPath, isCollaborationEnabledForEntity, tenant, totalCommentsCount]);
70
+ }, [addCommentsToCommentsMap, collaborationPath, isCollaborationEnabledForEntity, tenant]);
73
71
  var getTotalCommentsCount = (0, react_1.useCallback)(function () {
74
72
  if (isCollaborationEnabledForEntity) {
75
73
  var onError = function (e) {
@@ -87,8 +85,10 @@ var useCollaboration = function (_a) {
87
85
  }
88
86
  }, [isCollaborationEnabledForEntity, collaborationPath, entityUri, tenant]);
89
87
  (0, react_1.useEffect)(function () {
90
- getTotalCommentsCount();
91
- }, [getTotalCommentsCount]);
88
+ if (needsTotalCount) {
89
+ getTotalCommentsCount();
90
+ }
91
+ }, [getTotalCommentsCount, needsTotalCount]);
92
92
  (0, react_1.useEffect)(function () {
93
93
  getCommentsCount(objectIds, true);
94
94
  }, [objectIds, getCommentsCount]);
@@ -127,16 +127,22 @@ var useCollaboration = function (_a) {
127
127
  setComments((0, ramda_1.map)((0, ramda_1.when)((0, ramda_1.propEq)('commentId', comment.commentId), (0, ramda_1.always)(comment))));
128
128
  };
129
129
  var deleteCommentFromState = function (commentId, uri) {
130
+ var repliesCountFromComments;
131
+ var repliesCountFromCommentsMap;
130
132
  setCurrentComment(null);
131
133
  setCommentsMap(function (prevCommentsMap) {
132
134
  var _a;
135
+ var _b, _c;
136
+ repliesCountFromCommentsMap = (_c = (_b = prevCommentsMap === null || prevCommentsMap === void 0 ? void 0 : prevCommentsMap[uri]) === null || _b === void 0 ? void 0 : _b.find(function (c) { return c.commentId === commentId; })) === null || _c === void 0 ? void 0 : _c.replies;
133
137
  var comments = prevCommentsMap[uri] || [];
134
138
  return __assign(__assign({}, prevCommentsMap), (_a = {}, _a[uri] = comments.filter(function (c) { return c.commentId !== commentId; }), _a));
135
139
  });
136
140
  setComments(function (prevComments) {
141
+ var _a;
142
+ repliesCountFromComments = (_a = prevComments.find(function (comment) { return comment.commentId === commentId; })) === null || _a === void 0 ? void 0 : _a.replies.length;
137
143
  return prevComments.filter(function (comment) { return comment.commentId !== commentId; });
138
144
  });
139
- setTotalCommentsCount(function (prevCount) { return Math.max((prevCount || 0) - 1, 0); });
145
+ setTotalCommentsCount(function (prevCount) { var _a; return Math.max((prevCount || 0) - (1 + ((_a = repliesCountFromComments !== null && repliesCountFromComments !== void 0 ? repliesCountFromComments : repliesCountFromCommentsMap) !== null && _a !== void 0 ? _a : 0)), 0); });
140
146
  };
141
147
  var createComment = (0, react_1.useCallback)(function (_a) {
142
148
  var content = _a.content, namedUsers = _a.namedUsers, objectType = _a.objectType, uri = _a.uri, relatedObjectUris = _a.relatedObjectUris;
@@ -97,31 +97,6 @@ describe('useCollaboration behaviour', function () {
97
97
  expect(mdm_sdk_1.getCommentsCount).not.toHaveBeenCalled();
98
98
  expect(mdm_sdk_1.getTotalCommentsCount).not.toHaveBeenCalled();
99
99
  });
100
- it('should not call getCommentsCount if totalCommentsCount is 0', function () { return __awaiter(void 0, void 0, void 0, function () {
101
- var result;
102
- return __generator(this, function (_a) {
103
- switch (_a.label) {
104
- case 0:
105
- mdm_sdk_1.getTotalCommentsCount.mockResolvedValue({ total: 0 });
106
- result = setUp().result;
107
- return [4 /*yield*/, (0, react_hooks_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
108
- return __generator(this, function (_a) {
109
- switch (_a.label) {
110
- case 0: return [4 /*yield*/, Promise.resolve()];
111
- case 1:
112
- _a.sent();
113
- return [2 /*return*/];
114
- }
115
- });
116
- }); })];
117
- case 1:
118
- _a.sent();
119
- expect(mdm_sdk_1.getCommentsCount).not.toHaveBeenCalled();
120
- expect(result.current.commentsMap).toEqual({});
121
- return [2 /*return*/];
122
- }
123
- });
124
- }); });
125
100
  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 () {
126
101
  var result;
127
102
  return __generator(this, function (_a) {
@@ -152,7 +127,7 @@ describe('useCollaboration behaviour', function () {
152
127
  }
153
128
  });
154
129
  }); });
155
- 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 () {
130
+ it('should call getCommentsCount if collaboration is enabled and update commentsMap value', function () { return __awaiter(void 0, void 0, void 0, function () {
156
131
  var comments, result;
157
132
  return __generator(this, function (_a) {
158
133
  switch (_a.label) {
@@ -162,8 +137,12 @@ describe('useCollaboration behaviour', function () {
162
137
  { commentId: 'id2', status: 'open', replies: 2 }
163
138
  ];
164
139
  mdm_sdk_1.getCommentsCount.mockResolvedValueOnce([{ objectId: 'uri1', comments: comments }]);
165
- mdm_sdk_1.getTotalCommentsCount.mockResolvedValueOnce({ total: 2 });
166
140
  result = setUp({ props: { objectIds: ['uri1'] } }).result;
141
+ expect(mdm_sdk_1.getCommentsCount).toHaveBeenCalledWith({
142
+ uris: ['uri1'],
143
+ tenant: 'alenat',
144
+ collaborationPath: defaultMdmValues.collaborationPath
145
+ });
167
146
  return [4 /*yield*/, (0, react_hooks_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
168
147
  return __generator(this, function (_a) {
169
148
  switch (_a.label) {
@@ -176,24 +155,19 @@ describe('useCollaboration behaviour', function () {
176
155
  }); })];
177
156
  case 1:
178
157
  _a.sent();
179
- expect(mdm_sdk_1.getCommentsCount).toHaveBeenCalledWith({
180
- uris: ['uri1'],
181
- tenant: 'alenat',
182
- collaborationPath: defaultMdmValues.collaborationPath
183
- });
184
158
  expect(result.current.commentsMap).toEqual({ uri1: comments });
185
159
  return [2 /*return*/];
186
160
  }
187
161
  });
188
162
  }); });
189
- it('should set commentsMap value as null in case of unsuccessful getCommentsCount request', function () { return __awaiter(void 0, void 0, void 0, function () {
163
+ it('should set commentsMap value as null in case of unsuccessful request', function () { return __awaiter(void 0, void 0, void 0, function () {
190
164
  var result;
191
165
  return __generator(this, function (_a) {
192
166
  switch (_a.label) {
193
167
  case 0:
194
- mdm_sdk_1.getTotalCommentsCount.mockResolvedValueOnce({ total: 1 });
195
- mdm_sdk_1.getCommentsCount.mockRejectedValueOnce(new Error('Fail'));
168
+ mdm_sdk_1.getCommentsCount.mockRejectedValueOnce(null);
196
169
  result = setUp().result;
170
+ expect(mdm_sdk_1.getCommentsCount).toHaveBeenCalled();
197
171
  return [4 /*yield*/, (0, react_hooks_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
198
172
  return __generator(this, function (_a) {
199
173
  switch (_a.label) {
@@ -206,7 +180,6 @@ describe('useCollaboration behaviour', function () {
206
180
  }); })];
207
181
  case 1:
208
182
  _a.sent();
209
- expect(mdm_sdk_1.getCommentsCount).toHaveBeenCalled();
210
183
  expect(result.current.commentsMap).toBe(null);
211
184
  return [2 /*return*/];
212
185
  }
@@ -228,20 +201,7 @@ describe('useCollaboration behaviour', function () {
228
201
  return Promise.resolve([{ objectId: 'uri2', comments: secondComments }]);
229
202
  }
230
203
  });
231
- mdm_sdk_1.getTotalCommentsCount.mockResolvedValueOnce({ total: 3 });
232
204
  result = setUp({ props: { objectIds: ['uri1'] } }).result;
233
- return [4 /*yield*/, (0, react_hooks_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
234
- return __generator(this, function (_a) {
235
- switch (_a.label) {
236
- case 0: return [4 /*yield*/, Promise.resolve()];
237
- case 1:
238
- _a.sent();
239
- return [2 /*return*/];
240
- }
241
- });
242
- }); })];
243
- case 1:
244
- _a.sent();
245
205
  expect(mdm_sdk_1.getCommentsCount).toHaveBeenCalledWith({
246
206
  uris: ['uri1'],
247
207
  tenant: 'alenat',
@@ -253,7 +213,7 @@ describe('useCollaboration behaviour', function () {
253
213
  return [2 /*return*/];
254
214
  });
255
215
  }); })];
256
- case 2:
216
+ case 1:
257
217
  _a.sent();
258
218
  expect(mdm_sdk_1.getCommentsCount).toHaveBeenCalledWith({
259
219
  uris: ['uri2'],
@@ -281,20 +241,7 @@ describe('useCollaboration behaviour', function () {
281
241
  return Promise.resolve([{ objectId: 'uri2', comments: secondComments }]);
282
242
  }
283
243
  });
284
- mdm_sdk_1.getTotalCommentsCount.mockResolvedValue({ total: 3 });
285
244
  _a = setUp({ props: { objectIds: ['uri1'] } }), result = _a.result, rerender = _a.rerender;
286
- return [4 /*yield*/, (0, react_hooks_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
287
- return __generator(this, function (_a) {
288
- switch (_a.label) {
289
- case 0: return [4 /*yield*/, Promise.resolve()];
290
- case 1:
291
- _a.sent();
292
- return [2 /*return*/];
293
- }
294
- });
295
- }); })];
296
- case 1:
297
- _b.sent();
298
245
  expect(mdm_sdk_1.getCommentsCount).toHaveBeenCalledWith({
299
246
  uris: ['uri1'],
300
247
  tenant: 'alenat',
@@ -312,7 +259,7 @@ describe('useCollaboration behaviour', function () {
312
259
  }
313
260
  });
314
261
  }); })];
315
- case 2:
262
+ case 1:
316
263
  _b.sent();
317
264
  expect(mdm_sdk_1.getCommentsCount).toHaveBeenCalledWith({
318
265
  uris: ['uri2'],
@@ -449,12 +396,7 @@ describe('useCollaboration behaviour', function () {
449
396
  replies: 2
450
397
  }
451
398
  ];
452
- mdm_sdk_1.getTotalCommentsCount.mockResolvedValueOnce({ total: 3 });
453
- mdm_sdk_1.getCommentsCount
454
- .mockResolvedValueOnce([{ objectId: 'uri1', comments: comments }])
455
- .mockResolvedValueOnce([
456
- { objectId: 'uri1', comments: __spreadArray(__spreadArray([], comments, true), [{ commentId: 'commentId', replies: 0, status: 'open' }], false) }
457
- ]);
399
+ mdm_sdk_1.getCommentsCount.mockResolvedValueOnce([{ objectId: 'uri1', comments: comments }]);
458
400
  mdm_sdk_1.createComment.mockResolvedValueOnce([{ commentId: 'commentId' }]);
459
401
  result = setUp().result;
460
402
  return [4 /*yield*/, (0, react_hooks_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
@@ -472,16 +414,33 @@ describe('useCollaboration behaviour', function () {
472
414
  expect(result.current.commentsMap).toEqual({ uri1: comments });
473
415
  expect(result.current.currentComment).toBe(null);
474
416
  expect(result.current.sending).toBe(false);
417
+ (0, react_hooks_1.act)(function () {
418
+ result.current.createComment({
419
+ content: 'content',
420
+ namedUsers: [],
421
+ objectType: 'entity',
422
+ relatedObjectUris: ['uri1'],
423
+ uri: 'uri1'
424
+ });
425
+ });
426
+ expect(result.current.sending).toBe(true);
427
+ expect(mdm_sdk_1.createComment).toHaveBeenCalledWith({
428
+ collaborationPath: '123',
429
+ tenant: 'alenat',
430
+ data: {
431
+ objectId: 'uri1',
432
+ content: 'content',
433
+ relatedObjectUris: ['uri1'],
434
+ objectType: 'entity',
435
+ visibility: 'public',
436
+ namedUsers: [],
437
+ permanentLink: 'https://tst-01.reltio.com/nui/alenat/profile?entityUri=entities%2F2jWtLtNc&commentId=%7BcommentId%7D'
438
+ }
439
+ });
475
440
  return [4 /*yield*/, (0, react_hooks_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
476
441
  return __generator(this, function (_a) {
477
442
  switch (_a.label) {
478
- case 0: return [4 /*yield*/, result.current.createComment({
479
- content: 'content',
480
- namedUsers: [],
481
- objectType: 'entity',
482
- relatedObjectUris: ['uri1'],
483
- uri: 'uri1'
484
- })];
443
+ case 0: return [4 /*yield*/, Promise.resolve()];
485
444
  case 1:
486
445
  _a.sent();
487
446
  return [2 /*return*/];
@@ -498,23 +457,15 @@ describe('useCollaboration behaviour', function () {
498
457
  uri1: __spreadArray(__spreadArray([], comments, true), [{ commentId: 'commentId', replies: 0, status: 'open' }], false)
499
458
  });
500
459
  mdm_sdk_1.createComment.mockResolvedValueOnce([{ commentId: 'commentId2' }]);
501
- mdm_sdk_1.getCommentsCount.mockResolvedValueOnce([
502
- { objectId: 'uri1', comments: __spreadArray(__spreadArray([], comments, true), [{ commentId: 'commentId', replies: 0, status: 'open' }], false) },
503
- { objectId: 'uri2', comments: [{ commentId: 'commentId2', replies: 0, status: 'open' }] }
504
- ]);
505
460
  return [4 /*yield*/, (0, react_hooks_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
506
461
  return __generator(this, function (_a) {
507
- switch (_a.label) {
508
- case 0: return [4 /*yield*/, result.current.createComment({
509
- content: 'content',
510
- namedUsers: [],
511
- objectType: 'entity',
512
- uri: 'uri2'
513
- })];
514
- case 1:
515
- _a.sent();
516
- return [2 /*return*/];
517
- }
462
+ result.current.createComment({
463
+ content: 'content',
464
+ namedUsers: [],
465
+ objectType: 'entity',
466
+ uri: 'uri2'
467
+ });
468
+ return [2 /*return*/];
518
469
  });
519
470
  }); })];
520
471
  case 3:
@@ -543,14 +494,7 @@ describe('useCollaboration behaviour', function () {
543
494
  { commentId: 'id1', content: 'first comment', status: 'open', replies: [] },
544
495
  { commentId: 'id2', content: 'second comment', status: 'open', replies: [] }
545
496
  ];
546
- mdm_sdk_1.getCommentsCount
547
- .mockResolvedValueOnce([{ objectId: 'uri1', comments: commentsCount }])
548
- .mockResolvedValueOnce([
549
- { objectId: 'uri1', comments: [commentsCount[0], { commentId: 'id2', status: 'open', replies: 3 }] }
550
- ])
551
- .mockResolvedValueOnce([
552
- { objectId: 'uri1', comments: [commentsCount[0], { commentId: 'id2', status: 'resolved', replies: 4 }] }
553
- ]);
497
+ mdm_sdk_1.getCommentsCount.mockResolvedValue([{ objectId: 'uri1', comments: commentsCount }]);
554
498
  mdm_sdk_1.getComments.mockResolvedValue({ items: comments });
555
499
  mdm_sdk_1.getComment.mockResolvedValueOnce({
556
500
  commentId: 'id2',
@@ -683,11 +627,7 @@ describe('useCollaboration behaviour', function () {
683
627
  { commentId: 'id1', status: 'open', content: 'first comment', replies: [] },
684
628
  { commentId: 'id2', status: 'open', content: 'second comment', replies: [] }
685
629
  ];
686
- mdm_sdk_1.getCommentsCount
687
- .mockResolvedValueOnce([{ objectId: 'uri1', comments: commentsCount }])
688
- .mockResolvedValueOnce([
689
- { objectId: 'uri1', comments: [commentsCount[0], { commentId: 'id2', status: 'resolved', replies: 3 }] }
690
- ]);
630
+ mdm_sdk_1.getCommentsCount.mockResolvedValueOnce([{ objectId: 'uri1', comments: commentsCount }]);
691
631
  mdm_sdk_1.getComment.mockResolvedValueOnce({ commentId: 'id2', replies: [] });
692
632
  mdm_sdk_1.getComments.mockResolvedValue({ items: comments });
693
633
  mdm_sdk_1.createReply.mockResolvedValueOnce([{ content: '', action: 'resolve' }]);
@@ -760,11 +700,7 @@ describe('useCollaboration behaviour', function () {
760
700
  { commentId: 'id1', status: 'open', content: 'first comment', replies: [] },
761
701
  { commentId: 'id2', status: 'open', content: 'second comment', replies: [] }
762
702
  ];
763
- mdm_sdk_1.getCommentsCount
764
- .mockResolvedValueOnce([{ objectId: 'uri1', comments: commentsCount }])
765
- .mockResolvedValueOnce([
766
- { objectId: 'uri1', comments: [commentsCount[0], { commentId: 'id2', status: 'open', replies: 3 }] }
767
- ]);
703
+ mdm_sdk_1.getCommentsCount.mockResolvedValueOnce([{ objectId: 'uri1', comments: commentsCount }]);
768
704
  mdm_sdk_1.getComment.mockResolvedValueOnce({ commentId: 'id2', replies: [] });
769
705
  mdm_sdk_1.getComments.mockResolvedValue({
770
706
  items: comments
@@ -937,12 +873,9 @@ describe('useCollaboration behaviour', function () {
937
873
  { commentId: 'id1', content: 'text 1', status: 'open', replies: [] },
938
874
  { commentId: 'id2', content: 'text2', status: 'open', replies: [] }
939
875
  ];
940
- expectedCommentsCount = [{ commentId: 'id2', status: 'open', replies: 0 }];
941
- expectedComments = [{ commentId: 'id2', content: 'text2', status: 'open', replies: [] }];
942
- mdm_sdk_1.getTotalCommentsCount.mockResolvedValueOnce({ total: 2 });
943
- mdm_sdk_1.getCommentsCount
944
- .mockResolvedValueOnce([{ objectId: 'uri1', comments: commentsCount }])
945
- .mockResolvedValueOnce([{ objectId: 'uri1', comments: expectedCommentsCount }]);
876
+ expectedCommentsCount = commentsCount.slice(1);
877
+ expectedComments = comments.slice(1);
878
+ mdm_sdk_1.getCommentsCount.mockResolvedValueOnce([{ objectId: 'uri1', comments: commentsCount }]);
946
879
  mdm_sdk_1.getComments.mockResolvedValueOnce({ items: comments });
947
880
  mdm_sdk_1.deleteComment.mockResolvedValueOnce('');
948
881
  result = setUp().result;
@@ -957,20 +890,28 @@ describe('useCollaboration behaviour', function () {
957
890
  expect(result.current.comments).toEqual(comments);
958
891
  expect(result.current.commentsMap).toEqual({ uri1: commentsCount });
959
892
  expect(result.current.sending).toBe(false);
893
+ (0, react_hooks_1.act)(function () {
894
+ result.current.deleteComment({ commentId: 'id1', uri: 'uri1' });
895
+ });
896
+ expect(result.current.sending).toBe(true);
897
+ expect(mdm_sdk_1.deleteComment).toHaveBeenCalledWith({
898
+ collaborationPath: '123',
899
+ tenant: 'alenat',
900
+ commentId: 'id1'
901
+ });
960
902
  return [4 /*yield*/, (0, react_hooks_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
961
903
  return __generator(this, function (_a) {
962
- result.current.deleteComment({ commentId: 'id1', uri: 'uri1' });
963
- return [2 /*return*/];
904
+ switch (_a.label) {
905
+ case 0: return [4 /*yield*/, Promise.resolve()];
906
+ case 1:
907
+ _a.sent();
908
+ return [2 /*return*/];
909
+ }
964
910
  });
965
911
  }); })];
966
912
  case 2:
967
913
  _a.sent();
968
914
  expect(result.current.sending).toBe(false);
969
- expect(mdm_sdk_1.deleteComment).toHaveBeenCalledWith({
970
- collaborationPath: '123',
971
- tenant: 'alenat',
972
- commentId: 'id1'
973
- });
974
915
  expect(result.current.commentsMap).toEqual({
975
916
  uri1: expectedCommentsCount
976
917
  });
@@ -988,23 +929,13 @@ describe('useCollaboration behaviour', function () {
988
929
  { commentId: 'id1', status: 'open', replies: 1 },
989
930
  { commentId: 'id2', status: 'open', replies: 2 }
990
931
  ];
991
- mdm_sdk_1.getTotalCommentsCount.mockResolvedValueOnce({ total: commentsCount.length });
992
- mdm_sdk_1.getCommentsCount
993
- .mockResolvedValueOnce([{ objectId: 'uri1', comments: commentsCount }])
994
- .mockResolvedValueOnce([
995
- { objectId: 'uri1', comments: [commentsCount[0], { commentId: 'id2', status: 'open', replies: 2 }] },
996
- { objectId: 'uri2', comments: [] }
997
- ]);
932
+ mdm_sdk_1.getCommentsCount.mockResolvedValueOnce([{ objectId: 'uri1', comments: commentsCount }]);
998
933
  mdm_sdk_1.createReply.mockResolvedValueOnce([{ content: 'reply message' }]);
999
934
  result = setUp().result;
1000
935
  return [4 /*yield*/, (0, react_hooks_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
1001
936
  return __generator(this, function (_a) {
1002
- switch (_a.label) {
1003
- case 0: return [4 /*yield*/, Promise.resolve()];
1004
- case 1:
1005
- _a.sent();
1006
- return [2 /*return*/];
1007
- }
937
+ Promise.resolve();
938
+ return [2 /*return*/];
1008
939
  });
1009
940
  }); })];
1010
941
  case 1:
@@ -1021,9 +952,6 @@ describe('useCollaboration behaviour', function () {
1021
952
  uri: 'uri2'
1022
953
  })];
1023
954
  case 1:
1024
- _a.sent();
1025
- return [4 /*yield*/, Promise.resolve()];
1026
- case 2:
1027
955
  _a.sent();
1028
956
  return [2 /*return*/];
1029
957
  }
@@ -1050,23 +978,14 @@ describe('useCollaboration behaviour', function () {
1050
978
  ];
1051
979
  expectedCommentsCount = [{ commentId: 'id1', status: 'open', replies: 0 }];
1052
980
  expectedComments = [{ commentId: 'id1', content: 'text 1', status: 'open', replies: [] }];
1053
- mdm_sdk_1.getTotalCommentsCount.mockResolvedValueOnce({ total: 2 }).mockResolvedValueOnce({ total: 1 });
1054
- mdm_sdk_1.getCommentsCount
1055
- .mockResolvedValueOnce([{ objectId: 'uri1', comments: commentsCount }])
1056
- .mockResolvedValueOnce([{ objectId: 'uri1', comments: expectedCommentsCount }]);
981
+ mdm_sdk_1.getCommentsCount.mockResolvedValueOnce([{ objectId: 'uri1', comments: commentsCount }]);
1057
982
  mdm_sdk_1.getComments.mockResolvedValue({ items: comments });
1058
983
  mdm_sdk_1.deleteReply.mockResolvedValueOnce('');
1059
984
  result = setUp().result;
1060
985
  return [4 /*yield*/, (0, react_hooks_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
1061
986
  return __generator(this, function (_a) {
1062
- switch (_a.label) {
1063
- case 0:
1064
- result.current.getComments('uri');
1065
- return [4 /*yield*/, Promise.resolve()];
1066
- case 1:
1067
- _a.sent();
1068
- return [2 /*return*/];
1069
- }
987
+ result.current.getComments('uri');
988
+ return [2 /*return*/];
1070
989
  });
1071
990
  }); })];
1072
991
  case 1:
@@ -1074,16 +993,24 @@ describe('useCollaboration behaviour', function () {
1074
993
  expect(result.current.comments).toEqual(comments);
1075
994
  expect(result.current.commentsMap).toEqual({ uri1: commentsCount });
1076
995
  expect(result.current.sending).toBe(false);
996
+ (0, react_hooks_1.act)(function () {
997
+ result.current.deleteReply({
998
+ commentId: 'id1',
999
+ uri: 'uri1',
1000
+ reply: comments[0].replies[0]
1001
+ });
1002
+ });
1003
+ expect(result.current.sending).toBe(true);
1004
+ expect(mdm_sdk_1.deleteReply).toHaveBeenCalledWith({
1005
+ collaborationPath: '123',
1006
+ tenant: 'alenat',
1007
+ commentId: 'id1',
1008
+ replyId: 'replyId1'
1009
+ });
1077
1010
  return [4 /*yield*/, (0, react_hooks_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
1078
1011
  return __generator(this, function (_a) {
1079
1012
  switch (_a.label) {
1080
- case 0:
1081
- result.current.deleteReply({
1082
- commentId: 'id1',
1083
- uri: 'uri1',
1084
- reply: comments[0].replies[0]
1085
- });
1086
- return [4 /*yield*/, Promise.resolve()];
1013
+ case 0: return [4 /*yield*/, Promise.resolve()];
1087
1014
  case 1:
1088
1015
  _a.sent();
1089
1016
  return [2 /*return*/];
@@ -1093,12 +1020,6 @@ describe('useCollaboration behaviour', function () {
1093
1020
  case 2:
1094
1021
  _a.sent();
1095
1022
  expect(result.current.sending).toBe(false);
1096
- expect(mdm_sdk_1.deleteReply).toHaveBeenCalledWith({
1097
- collaborationPath: '123',
1098
- tenant: 'alenat',
1099
- commentId: 'id1',
1100
- replyId: 'replyId1'
1101
- });
1102
1023
  expect(result.current.commentsMap).toEqual({
1103
1024
  uri1: expectedCommentsCount
1104
1025
  });
@@ -1130,7 +1051,6 @@ describe('useCollaboration behaviour', function () {
1130
1051
  mdm_sdk_1.updateReply.mockResolvedValueOnce(editedReply);
1131
1052
  mdm_sdk_1.getComment.mockResolvedValueOnce(initialComment);
1132
1053
  mdm_sdk_1.getComments.mockResolvedValueOnce({ items: initialComments });
1133
- mdm_sdk_1.getTotalCommentsCount.mockResolvedValue({ total: 2 });
1134
1054
  result = setUp().result;
1135
1055
  return [4 /*yield*/, (0, react_hooks_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
1136
1056
  return __generator(this, function (_a) {
@@ -1187,7 +1107,6 @@ describe('useCollaboration behaviour', function () {
1187
1107
  return __generator(this, function (_a) {
1188
1108
  switch (_a.label) {
1189
1109
  case 0:
1190
- mdm_sdk_1.getTotalCommentsCount.mockResolvedValue({ total: 1 });
1191
1110
  result = setUp().result;
1192
1111
  expect(result.current.getCommentState('attrUri', 'commentUri')).toEqual({});
1193
1112
  return [4 /*yield*/, (0, react_hooks_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
@@ -1230,7 +1149,6 @@ describe('useCollaboration behaviour', function () {
1230
1149
  return __generator(this, function (_a) {
1231
1150
  switch (_a.label) {
1232
1151
  case 0:
1233
- mdm_sdk_1.getTotalCommentsCount.mockResolvedValue({ total: 1 });
1234
1152
  result = setUp().result;
1235
1153
  return [4 /*yield*/, (0, react_hooks_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
1236
1154
  return __generator(this, function (_a) {
@@ -1267,7 +1185,6 @@ describe('useCollaboration behaviour', function () {
1267
1185
  return __generator(this, function (_a) {
1268
1186
  switch (_a.label) {
1269
1187
  case 0:
1270
- mdm_sdk_1.getTotalCommentsCount.mockResolvedValue({ total: 1 });
1271
1188
  result = setUp().result;
1272
1189
  return [4 /*yield*/, (0, react_hooks_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
1273
1190
  return __generator(this, function (_a) {
@@ -1331,13 +1248,37 @@ describe('useCollaboration behaviour', function () {
1331
1248
  expect(result.current.totalCommentsCount).toBe(null);
1332
1249
  expect(mdm_sdk_1.getTotalCommentsCount).not.toHaveBeenCalled();
1333
1250
  });
1334
- it('should call getTotalCommentsCount if collaboration is enabled and update totalCommentsCount value', function () { return __awaiter(void 0, void 0, void 0, function () {
1251
+ it('should not call getTotalCommentsCount and update totalCommentsCount value if collaboration is enabled but needsTotalCount is false', function () { return __awaiter(void 0, void 0, void 0, function () {
1252
+ return __generator(this, function (_a) {
1253
+ switch (_a.label) {
1254
+ case 0:
1255
+ mdm_sdk_1.getTotalCommentsCount.mockResolvedValueOnce({ total: 15 });
1256
+ setUp();
1257
+ expect(mdm_sdk_1.getTotalCommentsCount).not.toHaveBeenCalled();
1258
+ return [4 /*yield*/, (0, react_hooks_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
1259
+ return __generator(this, function (_a) {
1260
+ switch (_a.label) {
1261
+ case 0: return [4 /*yield*/, Promise.resolve()];
1262
+ case 1:
1263
+ _a.sent();
1264
+ return [2 /*return*/];
1265
+ }
1266
+ });
1267
+ }); })];
1268
+ case 1:
1269
+ _a.sent();
1270
+ expect(mdm_sdk_1.getTotalCommentsCount).not.toHaveBeenCalled();
1271
+ return [2 /*return*/];
1272
+ }
1273
+ });
1274
+ }); });
1275
+ it('should call getTotalCommentsCount and update totalCommentsCount value if collaboration is enabled and needsTotalCount is true', function () { return __awaiter(void 0, void 0, void 0, function () {
1335
1276
  var result;
1336
1277
  return __generator(this, function (_a) {
1337
1278
  switch (_a.label) {
1338
1279
  case 0:
1339
1280
  mdm_sdk_1.getTotalCommentsCount.mockResolvedValueOnce({ total: 15 });
1340
- result = setUp().result;
1281
+ result = setUp({ props: { needsTotalCount: true } }).result;
1341
1282
  expect(mdm_sdk_1.getTotalCommentsCount).toHaveBeenCalledWith({
1342
1283
  relatedObjectUri: '1',
1343
1284
  collaborationPath: '123',
@@ -1366,7 +1307,7 @@ describe('useCollaboration behaviour', function () {
1366
1307
  switch (_a.label) {
1367
1308
  case 0:
1368
1309
  mdm_sdk_1.getTotalCommentsCount.mockRejectedValueOnce(new Error('Network error'));
1369
- result = setUp().result;
1310
+ result = setUp({ props: { needsTotalCount: true } }).result;
1370
1311
  expect(mdm_sdk_1.getTotalCommentsCount).toHaveBeenCalled();
1371
1312
  return [4 /*yield*/, (0, react_hooks_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
1372
1313
  return __generator(this, function (_a) {
@@ -3,8 +3,9 @@ type Props = {
3
3
  objectIds?: string[];
4
4
  objectTypes?: CollaborationObjectTypes[];
5
5
  enabled?: boolean;
6
+ needsTotalCount?: boolean;
6
7
  };
7
- export declare const useCollaboration: ({ objectIds, objectTypes, enabled }: Props) => {
8
+ export declare const useCollaboration: ({ objectIds, objectTypes, enabled, needsTotalCount }: Props) => {
8
9
  clearCurrentComment: () => void;
9
10
  comments: Comment[];
10
11
  commentsMap: CommentsMap;
@@ -35,19 +35,19 @@ var getUpdatedReplies = function (comment, reply) {
35
35
  var defaultObjectIds = [];
36
36
  var catchErrorInRequest = function (e) { return console.warn('Collaboration error', e); };
37
37
  export var useCollaboration = function (_a) {
38
- var _b = _a.objectIds, objectIds = _b === void 0 ? defaultObjectIds : _b, objectTypes = _a.objectTypes, _c = _a.enabled, enabled = _c === void 0 ? true : _c;
38
+ var _b = _a.objectIds, objectIds = _b === void 0 ? defaultObjectIds : _b, objectTypes = _a.objectTypes, _c = _a.enabled, enabled = _c === void 0 ? true : _c, _d = _a.needsTotalCount, needsTotalCount = _d === void 0 ? false : _d;
39
39
  var entity = useMdmEntity();
40
40
  var tenant = useMdmTenant();
41
41
  var collaborationPath = useMdmCollaborationPath();
42
42
  var isCollaborationEnabled = useMdmIsCollaborationEnabled() && enabled;
43
- var _d = useState(null), pageToken = _d[0], setPageToken = _d[1];
44
- var _e = useState([]), comments = _e[0], setComments = _e[1];
45
- var _f = useState(null), commentsMap = _f[0], setCommentsMap = _f[1];
46
- var _g = useState(null), totalCommentsCount = _g[0], setTotalCommentsCount = _g[1];
47
- var _h = useState(null), currentComment = _h[0], setCurrentComment = _h[1];
48
- var _j = useState(false), sending = _j[0], setSending = _j[1];
49
- var _k = useState(false), loading = _k[0], setLoading = _k[1];
50
- var _l = useState({}), collaborationStateMap = _l[0], setCollaborationStateMap = _l[1];
43
+ var _e = useState(null), pageToken = _e[0], setPageToken = _e[1];
44
+ var _f = useState([]), comments = _f[0], setComments = _f[1];
45
+ var _g = useState(null), commentsMap = _g[0], setCommentsMap = _g[1];
46
+ var _h = useState(null), totalCommentsCount = _h[0], setTotalCommentsCount = _h[1];
47
+ var _j = useState(null), currentComment = _j[0], setCurrentComment = _j[1];
48
+ var _k = useState(false), sending = _k[0], setSending = _k[1];
49
+ var _l = useState(false), loading = _l[0], setLoading = _l[1];
50
+ var _m = useState({}), collaborationStateMap = _m[0], setCollaborationStateMap = _m[1];
51
51
  var addCommentsToCommentsMap = useCallback(function (commentsMap) {
52
52
  setCommentsMap(function (currentCommentsMap) { return (__assign(__assign({}, currentCommentsMap), commentsMap)); });
53
53
  }, []);
@@ -55,18 +55,16 @@ export var useCollaboration = function (_a) {
55
55
  var isCollaborationEnabledForEntity = isCollaborationEnabled && entityUri && !isTempUri(entityUri);
56
56
  var getCommentsCount = useCallback(function (objectIds, shouldResetCommentsMap) {
57
57
  if (shouldResetCommentsMap === void 0) { shouldResetCommentsMap = false; }
58
- if (!isCollaborationEnabledForEntity || totalCommentsCount == null) {
59
- return setCommentsMap(null);
60
- }
61
- if (totalCommentsCount === 0) {
62
- return shouldResetCommentsMap && setCommentsMap({});
58
+ if (!isCollaborationEnabledForEntity) {
59
+ setCommentsMap(null);
60
+ return;
63
61
  }
64
62
  var onError = function (e) {
65
63
  console.warn('Collaboration error', e);
66
64
  setCommentsMap(null);
67
65
  };
68
66
  pipe(getCommentsCountRequest, andThen(map(props(['objectId', 'comments']))), andThen(fromPairs), andThen(shouldResetCommentsMap ? setCommentsMap : addCommentsToCommentsMap), otherwise(onError))({ uris: objectIds, tenant: tenant, collaborationPath: collaborationPath });
69
- }, [addCommentsToCommentsMap, collaborationPath, isCollaborationEnabledForEntity, tenant, totalCommentsCount]);
67
+ }, [addCommentsToCommentsMap, collaborationPath, isCollaborationEnabledForEntity, tenant]);
70
68
  var getTotalCommentsCount = useCallback(function () {
71
69
  if (isCollaborationEnabledForEntity) {
72
70
  var onError = function (e) {
@@ -84,8 +82,10 @@ export var useCollaboration = function (_a) {
84
82
  }
85
83
  }, [isCollaborationEnabledForEntity, collaborationPath, entityUri, tenant]);
86
84
  useEffect(function () {
87
- getTotalCommentsCount();
88
- }, [getTotalCommentsCount]);
85
+ if (needsTotalCount) {
86
+ getTotalCommentsCount();
87
+ }
88
+ }, [getTotalCommentsCount, needsTotalCount]);
89
89
  useEffect(function () {
90
90
  getCommentsCount(objectIds, true);
91
91
  }, [objectIds, getCommentsCount]);
@@ -124,16 +124,22 @@ export var useCollaboration = function (_a) {
124
124
  setComments(map(when(propEq('commentId', comment.commentId), always(comment))));
125
125
  };
126
126
  var deleteCommentFromState = function (commentId, uri) {
127
+ var repliesCountFromComments;
128
+ var repliesCountFromCommentsMap;
127
129
  setCurrentComment(null);
128
130
  setCommentsMap(function (prevCommentsMap) {
129
131
  var _a;
132
+ var _b, _c;
133
+ repliesCountFromCommentsMap = (_c = (_b = prevCommentsMap === null || prevCommentsMap === void 0 ? void 0 : prevCommentsMap[uri]) === null || _b === void 0 ? void 0 : _b.find(function (c) { return c.commentId === commentId; })) === null || _c === void 0 ? void 0 : _c.replies;
130
134
  var comments = prevCommentsMap[uri] || [];
131
135
  return __assign(__assign({}, prevCommentsMap), (_a = {}, _a[uri] = comments.filter(function (c) { return c.commentId !== commentId; }), _a));
132
136
  });
133
137
  setComments(function (prevComments) {
138
+ var _a;
139
+ repliesCountFromComments = (_a = prevComments.find(function (comment) { return comment.commentId === commentId; })) === null || _a === void 0 ? void 0 : _a.replies.length;
134
140
  return prevComments.filter(function (comment) { return comment.commentId !== commentId; });
135
141
  });
136
- setTotalCommentsCount(function (prevCount) { return Math.max((prevCount || 0) - 1, 0); });
142
+ setTotalCommentsCount(function (prevCount) { var _a; return Math.max((prevCount || 0) - (1 + ((_a = repliesCountFromComments !== null && repliesCountFromComments !== void 0 ? repliesCountFromComments : repliesCountFromCommentsMap) !== null && _a !== void 0 ? _a : 0)), 0); });
137
143
  };
138
144
  var createComment = useCallback(function (_a) {
139
145
  var content = _a.content, namedUsers = _a.namedUsers, objectType = _a.objectType, uri = _a.uri, relatedObjectUris = _a.relatedObjectUris;
@@ -92,31 +92,6 @@ describe('useCollaboration behaviour', function () {
92
92
  expect(getCommentsCount).not.toHaveBeenCalled();
93
93
  expect(getTotalCommentsCount).not.toHaveBeenCalled();
94
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
- }); });
120
95
  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 () {
121
96
  var result;
122
97
  return __generator(this, function (_a) {
@@ -147,7 +122,7 @@ describe('useCollaboration behaviour', function () {
147
122
  }
148
123
  });
149
124
  }); });
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 () {
125
+ it('should call getCommentsCount if collaboration is enabled and update commentsMap value', function () { return __awaiter(void 0, void 0, void 0, function () {
151
126
  var comments, result;
152
127
  return __generator(this, function (_a) {
153
128
  switch (_a.label) {
@@ -157,8 +132,12 @@ describe('useCollaboration behaviour', function () {
157
132
  { commentId: 'id2', status: 'open', replies: 2 }
158
133
  ];
159
134
  getCommentsCount.mockResolvedValueOnce([{ objectId: 'uri1', comments: comments }]);
160
- getTotalCommentsCount.mockResolvedValueOnce({ total: 2 });
161
135
  result = setUp({ props: { objectIds: ['uri1'] } }).result;
136
+ expect(getCommentsCount).toHaveBeenCalledWith({
137
+ uris: ['uri1'],
138
+ tenant: 'alenat',
139
+ collaborationPath: defaultMdmValues.collaborationPath
140
+ });
162
141
  return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
163
142
  return __generator(this, function (_a) {
164
143
  switch (_a.label) {
@@ -171,24 +150,19 @@ describe('useCollaboration behaviour', function () {
171
150
  }); })];
172
151
  case 1:
173
152
  _a.sent();
174
- expect(getCommentsCount).toHaveBeenCalledWith({
175
- uris: ['uri1'],
176
- tenant: 'alenat',
177
- collaborationPath: defaultMdmValues.collaborationPath
178
- });
179
153
  expect(result.current.commentsMap).toEqual({ uri1: comments });
180
154
  return [2 /*return*/];
181
155
  }
182
156
  });
183
157
  }); });
184
- it('should set commentsMap value as null in case of unsuccessful getCommentsCount request', function () { return __awaiter(void 0, void 0, void 0, function () {
158
+ it('should set commentsMap value as null in case of unsuccessful request', function () { return __awaiter(void 0, void 0, void 0, function () {
185
159
  var result;
186
160
  return __generator(this, function (_a) {
187
161
  switch (_a.label) {
188
162
  case 0:
189
- getTotalCommentsCount.mockResolvedValueOnce({ total: 1 });
190
- getCommentsCount.mockRejectedValueOnce(new Error('Fail'));
163
+ getCommentsCount.mockRejectedValueOnce(null);
191
164
  result = setUp().result;
165
+ expect(getCommentsCount).toHaveBeenCalled();
192
166
  return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
193
167
  return __generator(this, function (_a) {
194
168
  switch (_a.label) {
@@ -201,7 +175,6 @@ describe('useCollaboration behaviour', function () {
201
175
  }); })];
202
176
  case 1:
203
177
  _a.sent();
204
- expect(getCommentsCount).toHaveBeenCalled();
205
178
  expect(result.current.commentsMap).toBe(null);
206
179
  return [2 /*return*/];
207
180
  }
@@ -223,20 +196,7 @@ describe('useCollaboration behaviour', function () {
223
196
  return Promise.resolve([{ objectId: 'uri2', comments: secondComments }]);
224
197
  }
225
198
  });
226
- getTotalCommentsCount.mockResolvedValueOnce({ total: 3 });
227
199
  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();
240
200
  expect(getCommentsCount).toHaveBeenCalledWith({
241
201
  uris: ['uri1'],
242
202
  tenant: 'alenat',
@@ -248,7 +208,7 @@ describe('useCollaboration behaviour', function () {
248
208
  return [2 /*return*/];
249
209
  });
250
210
  }); })];
251
- case 2:
211
+ case 1:
252
212
  _a.sent();
253
213
  expect(getCommentsCount).toHaveBeenCalledWith({
254
214
  uris: ['uri2'],
@@ -276,20 +236,7 @@ describe('useCollaboration behaviour', function () {
276
236
  return Promise.resolve([{ objectId: 'uri2', comments: secondComments }]);
277
237
  }
278
238
  });
279
- getTotalCommentsCount.mockResolvedValue({ total: 3 });
280
239
  _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();
293
240
  expect(getCommentsCount).toHaveBeenCalledWith({
294
241
  uris: ['uri1'],
295
242
  tenant: 'alenat',
@@ -307,7 +254,7 @@ describe('useCollaboration behaviour', function () {
307
254
  }
308
255
  });
309
256
  }); })];
310
- case 2:
257
+ case 1:
311
258
  _b.sent();
312
259
  expect(getCommentsCount).toHaveBeenCalledWith({
313
260
  uris: ['uri2'],
@@ -444,12 +391,7 @@ describe('useCollaboration behaviour', function () {
444
391
  replies: 2
445
392
  }
446
393
  ];
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
- ]);
394
+ getCommentsCount.mockResolvedValueOnce([{ objectId: 'uri1', comments: comments }]);
453
395
  createComment.mockResolvedValueOnce([{ commentId: 'commentId' }]);
454
396
  result = setUp().result;
455
397
  return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
@@ -467,16 +409,33 @@ describe('useCollaboration behaviour', function () {
467
409
  expect(result.current.commentsMap).toEqual({ uri1: comments });
468
410
  expect(result.current.currentComment).toBe(null);
469
411
  expect(result.current.sending).toBe(false);
412
+ act(function () {
413
+ result.current.createComment({
414
+ content: 'content',
415
+ namedUsers: [],
416
+ objectType: 'entity',
417
+ relatedObjectUris: ['uri1'],
418
+ uri: 'uri1'
419
+ });
420
+ });
421
+ expect(result.current.sending).toBe(true);
422
+ expect(createComment).toHaveBeenCalledWith({
423
+ collaborationPath: '123',
424
+ tenant: 'alenat',
425
+ data: {
426
+ objectId: 'uri1',
427
+ content: 'content',
428
+ relatedObjectUris: ['uri1'],
429
+ objectType: 'entity',
430
+ visibility: 'public',
431
+ namedUsers: [],
432
+ permanentLink: 'https://tst-01.reltio.com/nui/alenat/profile?entityUri=entities%2F2jWtLtNc&commentId=%7BcommentId%7D'
433
+ }
434
+ });
470
435
  return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
471
436
  return __generator(this, function (_a) {
472
437
  switch (_a.label) {
473
- case 0: return [4 /*yield*/, result.current.createComment({
474
- content: 'content',
475
- namedUsers: [],
476
- objectType: 'entity',
477
- relatedObjectUris: ['uri1'],
478
- uri: 'uri1'
479
- })];
438
+ case 0: return [4 /*yield*/, Promise.resolve()];
480
439
  case 1:
481
440
  _a.sent();
482
441
  return [2 /*return*/];
@@ -493,23 +452,15 @@ describe('useCollaboration behaviour', function () {
493
452
  uri1: __spreadArray(__spreadArray([], comments, true), [{ commentId: 'commentId', replies: 0, status: 'open' }], false)
494
453
  });
495
454
  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
- ]);
500
455
  return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
501
456
  return __generator(this, function (_a) {
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
- }
457
+ result.current.createComment({
458
+ content: 'content',
459
+ namedUsers: [],
460
+ objectType: 'entity',
461
+ uri: 'uri2'
462
+ });
463
+ return [2 /*return*/];
513
464
  });
514
465
  }); })];
515
466
  case 3:
@@ -538,14 +489,7 @@ describe('useCollaboration behaviour', function () {
538
489
  { commentId: 'id1', content: 'first comment', status: 'open', replies: [] },
539
490
  { commentId: 'id2', content: 'second comment', status: 'open', replies: [] }
540
491
  ];
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
- ]);
492
+ getCommentsCount.mockResolvedValue([{ objectId: 'uri1', comments: commentsCount }]);
549
493
  getComments.mockResolvedValue({ items: comments });
550
494
  getComment.mockResolvedValueOnce({
551
495
  commentId: 'id2',
@@ -678,11 +622,7 @@ describe('useCollaboration behaviour', function () {
678
622
  { commentId: 'id1', status: 'open', content: 'first comment', replies: [] },
679
623
  { commentId: 'id2', status: 'open', content: 'second comment', replies: [] }
680
624
  ];
681
- getCommentsCount
682
- .mockResolvedValueOnce([{ objectId: 'uri1', comments: commentsCount }])
683
- .mockResolvedValueOnce([
684
- { objectId: 'uri1', comments: [commentsCount[0], { commentId: 'id2', status: 'resolved', replies: 3 }] }
685
- ]);
625
+ getCommentsCount.mockResolvedValueOnce([{ objectId: 'uri1', comments: commentsCount }]);
686
626
  getComment.mockResolvedValueOnce({ commentId: 'id2', replies: [] });
687
627
  getComments.mockResolvedValue({ items: comments });
688
628
  createReply.mockResolvedValueOnce([{ content: '', action: 'resolve' }]);
@@ -755,11 +695,7 @@ describe('useCollaboration behaviour', function () {
755
695
  { commentId: 'id1', status: 'open', content: 'first comment', replies: [] },
756
696
  { commentId: 'id2', status: 'open', content: 'second comment', replies: [] }
757
697
  ];
758
- getCommentsCount
759
- .mockResolvedValueOnce([{ objectId: 'uri1', comments: commentsCount }])
760
- .mockResolvedValueOnce([
761
- { objectId: 'uri1', comments: [commentsCount[0], { commentId: 'id2', status: 'open', replies: 3 }] }
762
- ]);
698
+ getCommentsCount.mockResolvedValueOnce([{ objectId: 'uri1', comments: commentsCount }]);
763
699
  getComment.mockResolvedValueOnce({ commentId: 'id2', replies: [] });
764
700
  getComments.mockResolvedValue({
765
701
  items: comments
@@ -932,12 +868,9 @@ describe('useCollaboration behaviour', function () {
932
868
  { commentId: 'id1', content: 'text 1', status: 'open', replies: [] },
933
869
  { commentId: 'id2', content: 'text2', status: 'open', replies: [] }
934
870
  ];
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 }]);
871
+ expectedCommentsCount = commentsCount.slice(1);
872
+ expectedComments = comments.slice(1);
873
+ getCommentsCount.mockResolvedValueOnce([{ objectId: 'uri1', comments: commentsCount }]);
941
874
  getComments.mockResolvedValueOnce({ items: comments });
942
875
  deleteComment.mockResolvedValueOnce('');
943
876
  result = setUp().result;
@@ -952,20 +885,28 @@ describe('useCollaboration behaviour', function () {
952
885
  expect(result.current.comments).toEqual(comments);
953
886
  expect(result.current.commentsMap).toEqual({ uri1: commentsCount });
954
887
  expect(result.current.sending).toBe(false);
888
+ act(function () {
889
+ result.current.deleteComment({ commentId: 'id1', uri: 'uri1' });
890
+ });
891
+ expect(result.current.sending).toBe(true);
892
+ expect(deleteComment).toHaveBeenCalledWith({
893
+ collaborationPath: '123',
894
+ tenant: 'alenat',
895
+ commentId: 'id1'
896
+ });
955
897
  return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
956
898
  return __generator(this, function (_a) {
957
- result.current.deleteComment({ commentId: 'id1', uri: 'uri1' });
958
- return [2 /*return*/];
899
+ switch (_a.label) {
900
+ case 0: return [4 /*yield*/, Promise.resolve()];
901
+ case 1:
902
+ _a.sent();
903
+ return [2 /*return*/];
904
+ }
959
905
  });
960
906
  }); })];
961
907
  case 2:
962
908
  _a.sent();
963
909
  expect(result.current.sending).toBe(false);
964
- expect(deleteComment).toHaveBeenCalledWith({
965
- collaborationPath: '123',
966
- tenant: 'alenat',
967
- commentId: 'id1'
968
- });
969
910
  expect(result.current.commentsMap).toEqual({
970
911
  uri1: expectedCommentsCount
971
912
  });
@@ -983,23 +924,13 @@ describe('useCollaboration behaviour', function () {
983
924
  { commentId: 'id1', status: 'open', replies: 1 },
984
925
  { commentId: 'id2', status: 'open', replies: 2 }
985
926
  ];
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
- ]);
927
+ getCommentsCount.mockResolvedValueOnce([{ objectId: 'uri1', comments: commentsCount }]);
993
928
  createReply.mockResolvedValueOnce([{ content: 'reply message' }]);
994
929
  result = setUp().result;
995
930
  return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
996
931
  return __generator(this, function (_a) {
997
- switch (_a.label) {
998
- case 0: return [4 /*yield*/, Promise.resolve()];
999
- case 1:
1000
- _a.sent();
1001
- return [2 /*return*/];
1002
- }
932
+ Promise.resolve();
933
+ return [2 /*return*/];
1003
934
  });
1004
935
  }); })];
1005
936
  case 1:
@@ -1016,9 +947,6 @@ describe('useCollaboration behaviour', function () {
1016
947
  uri: 'uri2'
1017
948
  })];
1018
949
  case 1:
1019
- _a.sent();
1020
- return [4 /*yield*/, Promise.resolve()];
1021
- case 2:
1022
950
  _a.sent();
1023
951
  return [2 /*return*/];
1024
952
  }
@@ -1045,23 +973,14 @@ describe('useCollaboration behaviour', function () {
1045
973
  ];
1046
974
  expectedCommentsCount = [{ commentId: 'id1', status: 'open', replies: 0 }];
1047
975
  expectedComments = [{ commentId: 'id1', content: 'text 1', status: 'open', replies: [] }];
1048
- getTotalCommentsCount.mockResolvedValueOnce({ total: 2 }).mockResolvedValueOnce({ total: 1 });
1049
- getCommentsCount
1050
- .mockResolvedValueOnce([{ objectId: 'uri1', comments: commentsCount }])
1051
- .mockResolvedValueOnce([{ objectId: 'uri1', comments: expectedCommentsCount }]);
976
+ getCommentsCount.mockResolvedValueOnce([{ objectId: 'uri1', comments: commentsCount }]);
1052
977
  getComments.mockResolvedValue({ items: comments });
1053
978
  deleteReply.mockResolvedValueOnce('');
1054
979
  result = setUp().result;
1055
980
  return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
1056
981
  return __generator(this, function (_a) {
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
- }
982
+ result.current.getComments('uri');
983
+ return [2 /*return*/];
1065
984
  });
1066
985
  }); })];
1067
986
  case 1:
@@ -1069,16 +988,24 @@ describe('useCollaboration behaviour', function () {
1069
988
  expect(result.current.comments).toEqual(comments);
1070
989
  expect(result.current.commentsMap).toEqual({ uri1: commentsCount });
1071
990
  expect(result.current.sending).toBe(false);
991
+ act(function () {
992
+ result.current.deleteReply({
993
+ commentId: 'id1',
994
+ uri: 'uri1',
995
+ reply: comments[0].replies[0]
996
+ });
997
+ });
998
+ expect(result.current.sending).toBe(true);
999
+ expect(deleteReply).toHaveBeenCalledWith({
1000
+ collaborationPath: '123',
1001
+ tenant: 'alenat',
1002
+ commentId: 'id1',
1003
+ replyId: 'replyId1'
1004
+ });
1072
1005
  return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
1073
1006
  return __generator(this, function (_a) {
1074
1007
  switch (_a.label) {
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()];
1008
+ case 0: return [4 /*yield*/, Promise.resolve()];
1082
1009
  case 1:
1083
1010
  _a.sent();
1084
1011
  return [2 /*return*/];
@@ -1088,12 +1015,6 @@ describe('useCollaboration behaviour', function () {
1088
1015
  case 2:
1089
1016
  _a.sent();
1090
1017
  expect(result.current.sending).toBe(false);
1091
- expect(deleteReply).toHaveBeenCalledWith({
1092
- collaborationPath: '123',
1093
- tenant: 'alenat',
1094
- commentId: 'id1',
1095
- replyId: 'replyId1'
1096
- });
1097
1018
  expect(result.current.commentsMap).toEqual({
1098
1019
  uri1: expectedCommentsCount
1099
1020
  });
@@ -1125,7 +1046,6 @@ describe('useCollaboration behaviour', function () {
1125
1046
  updateReply.mockResolvedValueOnce(editedReply);
1126
1047
  getComment.mockResolvedValueOnce(initialComment);
1127
1048
  getComments.mockResolvedValueOnce({ items: initialComments });
1128
- getTotalCommentsCount.mockResolvedValue({ total: 2 });
1129
1049
  result = setUp().result;
1130
1050
  return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
1131
1051
  return __generator(this, function (_a) {
@@ -1182,7 +1102,6 @@ describe('useCollaboration behaviour', function () {
1182
1102
  return __generator(this, function (_a) {
1183
1103
  switch (_a.label) {
1184
1104
  case 0:
1185
- getTotalCommentsCount.mockResolvedValue({ total: 1 });
1186
1105
  result = setUp().result;
1187
1106
  expect(result.current.getCommentState('attrUri', 'commentUri')).toEqual({});
1188
1107
  return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
@@ -1225,7 +1144,6 @@ describe('useCollaboration behaviour', function () {
1225
1144
  return __generator(this, function (_a) {
1226
1145
  switch (_a.label) {
1227
1146
  case 0:
1228
- getTotalCommentsCount.mockResolvedValue({ total: 1 });
1229
1147
  result = setUp().result;
1230
1148
  return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
1231
1149
  return __generator(this, function (_a) {
@@ -1262,7 +1180,6 @@ describe('useCollaboration behaviour', function () {
1262
1180
  return __generator(this, function (_a) {
1263
1181
  switch (_a.label) {
1264
1182
  case 0:
1265
- getTotalCommentsCount.mockResolvedValue({ total: 1 });
1266
1183
  result = setUp().result;
1267
1184
  return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
1268
1185
  return __generator(this, function (_a) {
@@ -1326,13 +1243,37 @@ describe('useCollaboration behaviour', function () {
1326
1243
  expect(result.current.totalCommentsCount).toBe(null);
1327
1244
  expect(getTotalCommentsCount).not.toHaveBeenCalled();
1328
1245
  });
1329
- it('should call getTotalCommentsCount if collaboration is enabled and update totalCommentsCount value', function () { return __awaiter(void 0, void 0, void 0, function () {
1246
+ it('should not call getTotalCommentsCount and update totalCommentsCount value if collaboration is enabled but needsTotalCount is false', function () { return __awaiter(void 0, void 0, void 0, function () {
1247
+ return __generator(this, function (_a) {
1248
+ switch (_a.label) {
1249
+ case 0:
1250
+ getTotalCommentsCount.mockResolvedValueOnce({ total: 15 });
1251
+ setUp();
1252
+ expect(getTotalCommentsCount).not.toHaveBeenCalled();
1253
+ return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
1254
+ return __generator(this, function (_a) {
1255
+ switch (_a.label) {
1256
+ case 0: return [4 /*yield*/, Promise.resolve()];
1257
+ case 1:
1258
+ _a.sent();
1259
+ return [2 /*return*/];
1260
+ }
1261
+ });
1262
+ }); })];
1263
+ case 1:
1264
+ _a.sent();
1265
+ expect(getTotalCommentsCount).not.toHaveBeenCalled();
1266
+ return [2 /*return*/];
1267
+ }
1268
+ });
1269
+ }); });
1270
+ it('should call getTotalCommentsCount and update totalCommentsCount value if collaboration is enabled and needsTotalCount is true', function () { return __awaiter(void 0, void 0, void 0, function () {
1330
1271
  var result;
1331
1272
  return __generator(this, function (_a) {
1332
1273
  switch (_a.label) {
1333
1274
  case 0:
1334
1275
  getTotalCommentsCount.mockResolvedValueOnce({ total: 15 });
1335
- result = setUp().result;
1276
+ result = setUp({ props: { needsTotalCount: true } }).result;
1336
1277
  expect(getTotalCommentsCount).toHaveBeenCalledWith({
1337
1278
  relatedObjectUri: '1',
1338
1279
  collaborationPath: '123',
@@ -1361,7 +1302,7 @@ describe('useCollaboration behaviour', function () {
1361
1302
  switch (_a.label) {
1362
1303
  case 0:
1363
1304
  getTotalCommentsCount.mockRejectedValueOnce(new Error('Network error'));
1364
- result = setUp().result;
1305
+ result = setUp({ props: { needsTotalCount: true } }).result;
1365
1306
  expect(getTotalCommentsCount).toHaveBeenCalled();
1366
1307
  return [4 /*yield*/, act(function () { return __awaiter(void 0, void 0, void 0, function () {
1367
1308
  return __generator(this, function (_a) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.2155",
3
+ "version": "1.4.2156",
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.1976",
14
+ "@reltio/mdm-sdk": "^1.4.1977",
15
15
  "@vis.gl/react-google-maps": "^1.3.0",
16
16
  "d3-cloud": "^1.2.5",
17
17
  "d3-geo": "^2.0.1",