@reltio/components 1.4.2019 → 1.4.2020

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.
@@ -10,6 +10,9 @@ export var useEntityDetails = function (entityUri) {
10
10
  setIsLoading(true);
11
11
  safePromise(getEntity(entityUri))
12
12
  .then(setEntityDetails)
13
+ .catch(function (error) {
14
+ console.warn('Failed to load entity', error);
15
+ })
13
16
  .finally(function () { return setIsLoading(false); });
14
17
  }, 1000), [entityUri, safePromise]);
15
18
  var hideEntityDetails = useCallback(function () {
@@ -194,4 +194,32 @@ describe('useEntityDetails', function () {
194
194
  }
195
195
  });
196
196
  }); });
197
+ it('should catch and handle error when getEntity returns error', function () { return __awaiter(void 0, void 0, void 0, function () {
198
+ var warnSpy, result;
199
+ return __generator(this, function (_a) {
200
+ switch (_a.label) {
201
+ case 0:
202
+ warnSpy = jest.spyOn(global.console, 'warn');
203
+ getEntity.mockRejectedValue({ errorCode: 403, errorMessage: 'Access is denied' });
204
+ result = renderHook(useEntityDetails, { initialProps: entity.uri }).result;
205
+ act(function () {
206
+ result.current.showEntityDetails();
207
+ jest.runAllTimers();
208
+ });
209
+ expect(getEntity).toHaveBeenCalled();
210
+ return [4 /*yield*/, act(function () {
211
+ return Promise.resolve();
212
+ })];
213
+ case 1:
214
+ _a.sent();
215
+ expect(result.current.isLoading).toBe(false);
216
+ expect(warnSpy).toHaveBeenCalledWith('Failed to load entity', {
217
+ errorCode: 403,
218
+ errorMessage: 'Access is denied'
219
+ });
220
+ warnSpy.mockRestore();
221
+ return [2 /*return*/];
222
+ }
223
+ });
224
+ }); });
197
225
  });
@@ -65,7 +65,11 @@ export var useSearchNavigation = function () {
65
65
  }, [listenToActions, updateNavigationData, searchNavigationListener]);
66
66
  var requestNextPage = useCallback(function (cache, total, index) {
67
67
  setLoading(true);
68
- safeRequestTotalPromise(searchProvider.requestTotal()).then(function (total) { return updateNavigationData({ total: total }); });
68
+ safeRequestTotalPromise(searchProvider.requestTotal())
69
+ .then(function (total) { return updateNavigationData({ total: total }); })
70
+ .catch(function (error) {
71
+ console.warn('Failed to load total count of entities', error);
72
+ });
69
73
  var newIndex = index + 1;
70
74
  return safeRequestEntitiesPromise(searchProvider.requestEntities(REQUEST_PAGE_SIZE, newIndex))
71
75
  .then(function (entities) {
@@ -97,7 +101,11 @@ export var useSearchNavigation = function () {
97
101
  }, [searchProvider, updateNavigationData, openEntity]);
98
102
  var requestPrevPage = useCallback(function (cache, index) {
99
103
  setLoading(true);
100
- safeRequestTotalPromise(searchProvider.requestTotal()).then(function (total) { return updateNavigationData({ total: total }); });
104
+ safeRequestTotalPromise(searchProvider.requestTotal())
105
+ .then(function (total) { return updateNavigationData({ total: total }); })
106
+ .catch(function (error) {
107
+ console.warn('Failed to load total count of entities', error);
108
+ });
101
109
  var newIndex = index - 1;
102
110
  var offset = Math.max(0, index - REQUEST_PAGE_SIZE);
103
111
  var max = REQUEST_PAGE_SIZE + Math.min(0, index - REQUEST_PAGE_SIZE);
@@ -207,7 +215,7 @@ export var useSearchNavigation = function () {
207
215
  if (cache && uri) {
208
216
  var cacheIndex = cache.indexOf(uri) - 1;
209
217
  stepBackWithCheck(cache, cacheIndex, total, index).catch(function (error) {
210
- console.warn("Can't load prev page of search", error);
218
+ console.warn("Can't load previous page of search", error);
211
219
  });
212
220
  }
213
221
  }, [stepBackWithCheck, cache, uri, total, index]);
@@ -534,6 +534,94 @@ describe('useSearchNavigation behavior', function () {
534
534
  }
535
535
  });
536
536
  }); });
537
+ it('should catch and handle checkEntity error when checking previous entity', function () { return __awaiter(void 0, void 0, void 0, function () {
538
+ var warnSpy, _a, result, waitFor;
539
+ return __generator(this, function (_b) {
540
+ switch (_b.label) {
541
+ case 0:
542
+ warnSpy = jest.spyOn(global.console, 'warn');
543
+ searchProvider.checkEntity.mockRejectedValue({ errorCode: 403, errorMessage: 'Access is denied' });
544
+ _a = setUp(), result = _a.result, waitFor = _a.waitFor;
545
+ act(function () {
546
+ result.current.onPrev();
547
+ });
548
+ return [4 /*yield*/, waitFor(function () { return expect(result.current.isPrevDisabled).toBe(false); })];
549
+ case 1:
550
+ _b.sent();
551
+ expect(warnSpy).toHaveBeenCalledWith("Can't load previous page of search", {
552
+ errorCode: 403,
553
+ errorMessage: 'Access is denied'
554
+ });
555
+ warnSpy.mockRestore();
556
+ return [2 /*return*/];
557
+ }
558
+ });
559
+ }); });
560
+ it('should catch and handle requestTotal error when requesting previous entities page', function () { return __awaiter(void 0, void 0, void 0, function () {
561
+ var warnSpy, searchNavigationData, entity, mdmValues, _a, result, waitFor;
562
+ return __generator(this, function (_b) {
563
+ switch (_b.label) {
564
+ case 0:
565
+ warnSpy = jest.spyOn(global.console, 'warn');
566
+ searchProvider.requestTotal.mockRejectedValue({ errorCode: 403, errorMessage: 'Access is denied' });
567
+ searchNavigationData = {
568
+ uri: 'uri3',
569
+ cache: ['uri3', 'uri4', 'uri5'],
570
+ index: 3,
571
+ total: 10,
572
+ tenant: 't1'
573
+ };
574
+ entity = { uri: 'uri3' };
575
+ mdmValues = __assign(__assign({}, defaultMdmValues), { searchNavigationData: searchNavigationData, entity: entity });
576
+ _a = setUp({ mdmValues: mdmValues }), result = _a.result, waitFor = _a.waitFor;
577
+ act(function () {
578
+ result.current.onPrev();
579
+ });
580
+ return [4 /*yield*/, waitFor(function () { return expect(result.current.isPrevDisabled).toBe(false); })];
581
+ case 1:
582
+ _b.sent();
583
+ expect(warnSpy).toHaveBeenCalledWith('Failed to load total count of entities', {
584
+ errorCode: 403,
585
+ errorMessage: 'Access is denied'
586
+ });
587
+ warnSpy.mockRestore();
588
+ return [2 /*return*/];
589
+ }
590
+ });
591
+ }); });
592
+ it('should catch and handle requestEntities error when requesting previous entities page', function () { return __awaiter(void 0, void 0, void 0, function () {
593
+ var warnSpy, searchNavigationData, entity, mdmValues, _a, result, waitFor;
594
+ return __generator(this, function (_b) {
595
+ switch (_b.label) {
596
+ case 0:
597
+ warnSpy = jest.spyOn(global.console, 'warn');
598
+ searchProvider.requestTotal.mockResolvedValue(11);
599
+ searchProvider.requestEntities.mockRejectedValue({ errorCode: 403, errorMessage: 'Access is denied' });
600
+ searchNavigationData = {
601
+ uri: 'uri3',
602
+ cache: ['uri3', 'uri4', 'uri5'],
603
+ index: 5,
604
+ total: 10,
605
+ tenant: 't1'
606
+ };
607
+ entity = { uri: 'uri3' };
608
+ mdmValues = __assign(__assign({}, defaultMdmValues), { searchNavigationData: searchNavigationData, entity: entity });
609
+ _a = setUp({ mdmValues: mdmValues }), result = _a.result, waitFor = _a.waitFor;
610
+ act(function () {
611
+ result.current.onPrev();
612
+ });
613
+ return [4 /*yield*/, waitFor(function () { return expect(result.current.isPrevDisabled).toBe(false); })];
614
+ case 1:
615
+ _b.sent();
616
+ expect(warnSpy).toHaveBeenCalledWith("Can't load previous page of search", {
617
+ errorCode: 403,
618
+ errorMessage: 'Access is denied'
619
+ });
620
+ warnSpy.mockRestore();
621
+ return [2 /*return*/];
622
+ }
623
+ });
624
+ }); });
537
625
  });
538
626
  describe('onNext behavior', function () {
539
627
  it('should do nothing if cache or uri in searchNavigationData are not specified', function () {
@@ -901,5 +989,93 @@ describe('useSearchNavigation behavior', function () {
901
989
  }
902
990
  });
903
991
  }); });
992
+ it('should catch and handle checkEntity error when checking next entity', function () { return __awaiter(void 0, void 0, void 0, function () {
993
+ var warnSpy, _a, result, waitFor;
994
+ return __generator(this, function (_b) {
995
+ switch (_b.label) {
996
+ case 0:
997
+ warnSpy = jest.spyOn(global.console, 'warn');
998
+ searchProvider.checkEntity.mockRejectedValue({ errorCode: 403, errorMessage: 'Access is denied' });
999
+ _a = setUp(), result = _a.result, waitFor = _a.waitFor;
1000
+ act(function () {
1001
+ result.current.onNext();
1002
+ });
1003
+ return [4 /*yield*/, waitFor(function () { return expect(result.current.isNextDisabled).toBe(false); })];
1004
+ case 1:
1005
+ _b.sent();
1006
+ expect(warnSpy).toHaveBeenCalledWith("Can't load next page of search", {
1007
+ errorCode: 403,
1008
+ errorMessage: 'Access is denied'
1009
+ });
1010
+ warnSpy.mockRestore();
1011
+ return [2 /*return*/];
1012
+ }
1013
+ });
1014
+ }); });
1015
+ it('should catch and handle requestTotal error when requesting next entities page', function () { return __awaiter(void 0, void 0, void 0, function () {
1016
+ var warnSpy, searchNavigationData, entity, mdmValues, _a, result, waitFor;
1017
+ return __generator(this, function (_b) {
1018
+ switch (_b.label) {
1019
+ case 0:
1020
+ warnSpy = jest.spyOn(global.console, 'warn');
1021
+ searchProvider.requestTotal.mockRejectedValue({ errorCode: 403, errorMessage: 'Access is denied' });
1022
+ searchNavigationData = {
1023
+ uri: 'uri5',
1024
+ cache: ['uri3', 'uri4', 'uri5'],
1025
+ index: 5,
1026
+ total: 10,
1027
+ tenant: 't1'
1028
+ };
1029
+ entity = { uri: 'uri5' };
1030
+ mdmValues = __assign(__assign({}, defaultMdmValues), { searchNavigationData: searchNavigationData, entity: entity });
1031
+ _a = setUp({ mdmValues: mdmValues }), result = _a.result, waitFor = _a.waitFor;
1032
+ act(function () {
1033
+ result.current.onNext();
1034
+ });
1035
+ return [4 /*yield*/, waitFor(function () { return expect(result.current.isNextDisabled).toBe(false); })];
1036
+ case 1:
1037
+ _b.sent();
1038
+ expect(warnSpy).toHaveBeenCalledWith('Failed to load total count of entities', {
1039
+ errorCode: 403,
1040
+ errorMessage: 'Access is denied'
1041
+ });
1042
+ warnSpy.mockRestore();
1043
+ return [2 /*return*/];
1044
+ }
1045
+ });
1046
+ }); });
1047
+ it('should catch and handle requestEntities error when requesting next entities page', function () { return __awaiter(void 0, void 0, void 0, function () {
1048
+ var warnSpy, searchNavigationData, entity, mdmValues, _a, result, waitFor;
1049
+ return __generator(this, function (_b) {
1050
+ switch (_b.label) {
1051
+ case 0:
1052
+ warnSpy = jest.spyOn(global.console, 'warn');
1053
+ searchProvider.requestTotal.mockResolvedValue(11);
1054
+ searchProvider.requestEntities.mockRejectedValue({ errorCode: 403, errorMessage: 'Access is denied' });
1055
+ searchNavigationData = {
1056
+ uri: 'uri5',
1057
+ cache: ['uri3', 'uri4', 'uri5'],
1058
+ index: 5,
1059
+ total: 10,
1060
+ tenant: 't1'
1061
+ };
1062
+ entity = { uri: 'uri5' };
1063
+ mdmValues = __assign(__assign({}, defaultMdmValues), { searchNavigationData: searchNavigationData, entity: entity });
1064
+ _a = setUp({ mdmValues: mdmValues }), result = _a.result, waitFor = _a.waitFor;
1065
+ act(function () {
1066
+ result.current.onNext();
1067
+ });
1068
+ return [4 /*yield*/, waitFor(function () { return expect(result.current.isNextDisabled).toBe(false); })];
1069
+ case 1:
1070
+ _b.sent();
1071
+ expect(warnSpy).toHaveBeenCalledWith("Can't load next page of search", {
1072
+ errorCode: 403,
1073
+ errorMessage: 'Access is denied'
1074
+ });
1075
+ warnSpy.mockRestore();
1076
+ return [2 /*return*/];
1077
+ }
1078
+ });
1079
+ }); });
904
1080
  });
905
1081
  });
@@ -13,6 +13,9 @@ var useEntityDetails = function (entityUri) {
13
13
  setIsLoading(true);
14
14
  safePromise((0, mdm_sdk_1.getEntity)(entityUri))
15
15
  .then(setEntityDetails)
16
+ .catch(function (error) {
17
+ console.warn('Failed to load entity', error);
18
+ })
16
19
  .finally(function () { return setIsLoading(false); });
17
20
  }, 1000), [entityUri, safePromise]);
18
21
  var hideEntityDetails = (0, react_1.useCallback)(function () {
@@ -196,4 +196,32 @@ describe('useEntityDetails', function () {
196
196
  }
197
197
  });
198
198
  }); });
199
+ it('should catch and handle error when getEntity returns error', function () { return __awaiter(void 0, void 0, void 0, function () {
200
+ var warnSpy, result;
201
+ return __generator(this, function (_a) {
202
+ switch (_a.label) {
203
+ case 0:
204
+ warnSpy = jest.spyOn(global.console, 'warn');
205
+ mdm_sdk_1.getEntity.mockRejectedValue({ errorCode: 403, errorMessage: 'Access is denied' });
206
+ result = (0, react_hooks_1.renderHook)(useEntityDetails_1.useEntityDetails, { initialProps: entity.uri }).result;
207
+ (0, react_hooks_1.act)(function () {
208
+ result.current.showEntityDetails();
209
+ jest.runAllTimers();
210
+ });
211
+ expect(mdm_sdk_1.getEntity).toHaveBeenCalled();
212
+ return [4 /*yield*/, (0, react_hooks_1.act)(function () {
213
+ return Promise.resolve();
214
+ })];
215
+ case 1:
216
+ _a.sent();
217
+ expect(result.current.isLoading).toBe(false);
218
+ expect(warnSpy).toHaveBeenCalledWith('Failed to load entity', {
219
+ errorCode: 403,
220
+ errorMessage: 'Access is denied'
221
+ });
222
+ warnSpy.mockRestore();
223
+ return [2 /*return*/];
224
+ }
225
+ });
226
+ }); });
199
227
  });
@@ -68,7 +68,11 @@ var useSearchNavigation = function () {
68
68
  }, [listenToActions, updateNavigationData, searchNavigationListener]);
69
69
  var requestNextPage = (0, react_1.useCallback)(function (cache, total, index) {
70
70
  setLoading(true);
71
- safeRequestTotalPromise(searchProvider.requestTotal()).then(function (total) { return updateNavigationData({ total: total }); });
71
+ safeRequestTotalPromise(searchProvider.requestTotal())
72
+ .then(function (total) { return updateNavigationData({ total: total }); })
73
+ .catch(function (error) {
74
+ console.warn('Failed to load total count of entities', error);
75
+ });
72
76
  var newIndex = index + 1;
73
77
  return safeRequestEntitiesPromise(searchProvider.requestEntities(constants_1.REQUEST_PAGE_SIZE, newIndex))
74
78
  .then(function (entities) {
@@ -100,7 +104,11 @@ var useSearchNavigation = function () {
100
104
  }, [searchProvider, updateNavigationData, openEntity]);
101
105
  var requestPrevPage = (0, react_1.useCallback)(function (cache, index) {
102
106
  setLoading(true);
103
- safeRequestTotalPromise(searchProvider.requestTotal()).then(function (total) { return updateNavigationData({ total: total }); });
107
+ safeRequestTotalPromise(searchProvider.requestTotal())
108
+ .then(function (total) { return updateNavigationData({ total: total }); })
109
+ .catch(function (error) {
110
+ console.warn('Failed to load total count of entities', error);
111
+ });
104
112
  var newIndex = index - 1;
105
113
  var offset = Math.max(0, index - constants_1.REQUEST_PAGE_SIZE);
106
114
  var max = constants_1.REQUEST_PAGE_SIZE + Math.min(0, index - constants_1.REQUEST_PAGE_SIZE);
@@ -210,7 +218,7 @@ var useSearchNavigation = function () {
210
218
  if (cache && uri) {
211
219
  var cacheIndex = cache.indexOf(uri) - 1;
212
220
  stepBackWithCheck(cache, cacheIndex, total, index).catch(function (error) {
213
- console.warn("Can't load prev page of search", error);
221
+ console.warn("Can't load previous page of search", error);
214
222
  });
215
223
  }
216
224
  }, [stepBackWithCheck, cache, uri, total, index]);
@@ -562,6 +562,94 @@ describe('useSearchNavigation behavior', function () {
562
562
  }
563
563
  });
564
564
  }); });
565
+ it('should catch and handle checkEntity error when checking previous entity', function () { return __awaiter(void 0, void 0, void 0, function () {
566
+ var warnSpy, _a, result, waitFor;
567
+ return __generator(this, function (_b) {
568
+ switch (_b.label) {
569
+ case 0:
570
+ warnSpy = jest.spyOn(global.console, 'warn');
571
+ searchProvider.checkEntity.mockRejectedValue({ errorCode: 403, errorMessage: 'Access is denied' });
572
+ _a = setUp(), result = _a.result, waitFor = _a.waitFor;
573
+ (0, react_hooks_1.act)(function () {
574
+ result.current.onPrev();
575
+ });
576
+ return [4 /*yield*/, waitFor(function () { return expect(result.current.isPrevDisabled).toBe(false); })];
577
+ case 1:
578
+ _b.sent();
579
+ expect(warnSpy).toHaveBeenCalledWith("Can't load previous page of search", {
580
+ errorCode: 403,
581
+ errorMessage: 'Access is denied'
582
+ });
583
+ warnSpy.mockRestore();
584
+ return [2 /*return*/];
585
+ }
586
+ });
587
+ }); });
588
+ it('should catch and handle requestTotal error when requesting previous entities page', function () { return __awaiter(void 0, void 0, void 0, function () {
589
+ var warnSpy, searchNavigationData, entity, mdmValues, _a, result, waitFor;
590
+ return __generator(this, function (_b) {
591
+ switch (_b.label) {
592
+ case 0:
593
+ warnSpy = jest.spyOn(global.console, 'warn');
594
+ searchProvider.requestTotal.mockRejectedValue({ errorCode: 403, errorMessage: 'Access is denied' });
595
+ searchNavigationData = {
596
+ uri: 'uri3',
597
+ cache: ['uri3', 'uri4', 'uri5'],
598
+ index: 3,
599
+ total: 10,
600
+ tenant: 't1'
601
+ };
602
+ entity = { uri: 'uri3' };
603
+ mdmValues = __assign(__assign({}, defaultMdmValues), { searchNavigationData: searchNavigationData, entity: entity });
604
+ _a = setUp({ mdmValues: mdmValues }), result = _a.result, waitFor = _a.waitFor;
605
+ (0, react_hooks_1.act)(function () {
606
+ result.current.onPrev();
607
+ });
608
+ return [4 /*yield*/, waitFor(function () { return expect(result.current.isPrevDisabled).toBe(false); })];
609
+ case 1:
610
+ _b.sent();
611
+ expect(warnSpy).toHaveBeenCalledWith('Failed to load total count of entities', {
612
+ errorCode: 403,
613
+ errorMessage: 'Access is denied'
614
+ });
615
+ warnSpy.mockRestore();
616
+ return [2 /*return*/];
617
+ }
618
+ });
619
+ }); });
620
+ it('should catch and handle requestEntities error when requesting previous entities page', function () { return __awaiter(void 0, void 0, void 0, function () {
621
+ var warnSpy, searchNavigationData, entity, mdmValues, _a, result, waitFor;
622
+ return __generator(this, function (_b) {
623
+ switch (_b.label) {
624
+ case 0:
625
+ warnSpy = jest.spyOn(global.console, 'warn');
626
+ searchProvider.requestTotal.mockResolvedValue(11);
627
+ searchProvider.requestEntities.mockRejectedValue({ errorCode: 403, errorMessage: 'Access is denied' });
628
+ searchNavigationData = {
629
+ uri: 'uri3',
630
+ cache: ['uri3', 'uri4', 'uri5'],
631
+ index: 5,
632
+ total: 10,
633
+ tenant: 't1'
634
+ };
635
+ entity = { uri: 'uri3' };
636
+ mdmValues = __assign(__assign({}, defaultMdmValues), { searchNavigationData: searchNavigationData, entity: entity });
637
+ _a = setUp({ mdmValues: mdmValues }), result = _a.result, waitFor = _a.waitFor;
638
+ (0, react_hooks_1.act)(function () {
639
+ result.current.onPrev();
640
+ });
641
+ return [4 /*yield*/, waitFor(function () { return expect(result.current.isPrevDisabled).toBe(false); })];
642
+ case 1:
643
+ _b.sent();
644
+ expect(warnSpy).toHaveBeenCalledWith("Can't load previous page of search", {
645
+ errorCode: 403,
646
+ errorMessage: 'Access is denied'
647
+ });
648
+ warnSpy.mockRestore();
649
+ return [2 /*return*/];
650
+ }
651
+ });
652
+ }); });
565
653
  });
566
654
  describe('onNext behavior', function () {
567
655
  it('should do nothing if cache or uri in searchNavigationData are not specified', function () {
@@ -929,5 +1017,93 @@ describe('useSearchNavigation behavior', function () {
929
1017
  }
930
1018
  });
931
1019
  }); });
1020
+ it('should catch and handle checkEntity error when checking next entity', function () { return __awaiter(void 0, void 0, void 0, function () {
1021
+ var warnSpy, _a, result, waitFor;
1022
+ return __generator(this, function (_b) {
1023
+ switch (_b.label) {
1024
+ case 0:
1025
+ warnSpy = jest.spyOn(global.console, 'warn');
1026
+ searchProvider.checkEntity.mockRejectedValue({ errorCode: 403, errorMessage: 'Access is denied' });
1027
+ _a = setUp(), result = _a.result, waitFor = _a.waitFor;
1028
+ (0, react_hooks_1.act)(function () {
1029
+ result.current.onNext();
1030
+ });
1031
+ return [4 /*yield*/, waitFor(function () { return expect(result.current.isNextDisabled).toBe(false); })];
1032
+ case 1:
1033
+ _b.sent();
1034
+ expect(warnSpy).toHaveBeenCalledWith("Can't load next page of search", {
1035
+ errorCode: 403,
1036
+ errorMessage: 'Access is denied'
1037
+ });
1038
+ warnSpy.mockRestore();
1039
+ return [2 /*return*/];
1040
+ }
1041
+ });
1042
+ }); });
1043
+ it('should catch and handle requestTotal error when requesting next entities page', function () { return __awaiter(void 0, void 0, void 0, function () {
1044
+ var warnSpy, searchNavigationData, entity, mdmValues, _a, result, waitFor;
1045
+ return __generator(this, function (_b) {
1046
+ switch (_b.label) {
1047
+ case 0:
1048
+ warnSpy = jest.spyOn(global.console, 'warn');
1049
+ searchProvider.requestTotal.mockRejectedValue({ errorCode: 403, errorMessage: 'Access is denied' });
1050
+ searchNavigationData = {
1051
+ uri: 'uri5',
1052
+ cache: ['uri3', 'uri4', 'uri5'],
1053
+ index: 5,
1054
+ total: 10,
1055
+ tenant: 't1'
1056
+ };
1057
+ entity = { uri: 'uri5' };
1058
+ mdmValues = __assign(__assign({}, defaultMdmValues), { searchNavigationData: searchNavigationData, entity: entity });
1059
+ _a = setUp({ mdmValues: mdmValues }), result = _a.result, waitFor = _a.waitFor;
1060
+ (0, react_hooks_1.act)(function () {
1061
+ result.current.onNext();
1062
+ });
1063
+ return [4 /*yield*/, waitFor(function () { return expect(result.current.isNextDisabled).toBe(false); })];
1064
+ case 1:
1065
+ _b.sent();
1066
+ expect(warnSpy).toHaveBeenCalledWith('Failed to load total count of entities', {
1067
+ errorCode: 403,
1068
+ errorMessage: 'Access is denied'
1069
+ });
1070
+ warnSpy.mockRestore();
1071
+ return [2 /*return*/];
1072
+ }
1073
+ });
1074
+ }); });
1075
+ it('should catch and handle requestEntities error when requesting next entities page', function () { return __awaiter(void 0, void 0, void 0, function () {
1076
+ var warnSpy, searchNavigationData, entity, mdmValues, _a, result, waitFor;
1077
+ return __generator(this, function (_b) {
1078
+ switch (_b.label) {
1079
+ case 0:
1080
+ warnSpy = jest.spyOn(global.console, 'warn');
1081
+ searchProvider.requestTotal.mockResolvedValue(11);
1082
+ searchProvider.requestEntities.mockRejectedValue({ errorCode: 403, errorMessage: 'Access is denied' });
1083
+ searchNavigationData = {
1084
+ uri: 'uri5',
1085
+ cache: ['uri3', 'uri4', 'uri5'],
1086
+ index: 5,
1087
+ total: 10,
1088
+ tenant: 't1'
1089
+ };
1090
+ entity = { uri: 'uri5' };
1091
+ mdmValues = __assign(__assign({}, defaultMdmValues), { searchNavigationData: searchNavigationData, entity: entity });
1092
+ _a = setUp({ mdmValues: mdmValues }), result = _a.result, waitFor = _a.waitFor;
1093
+ (0, react_hooks_1.act)(function () {
1094
+ result.current.onNext();
1095
+ });
1096
+ return [4 /*yield*/, waitFor(function () { return expect(result.current.isNextDisabled).toBe(false); })];
1097
+ case 1:
1098
+ _b.sent();
1099
+ expect(warnSpy).toHaveBeenCalledWith("Can't load next page of search", {
1100
+ errorCode: 403,
1101
+ errorMessage: 'Access is denied'
1102
+ });
1103
+ warnSpy.mockRestore();
1104
+ return [2 /*return*/];
1105
+ }
1106
+ });
1107
+ }); });
932
1108
  });
933
1109
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.2019",
3
+ "version": "1.4.2020",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./index.js",