@webex/contact-center 3.9.0-next.6 → 3.9.0-next.7
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/dist/cc.js +14 -0
- package/dist/cc.js.map +1 -1
- package/dist/metrics/MetricsManager.js +1 -1
- package/dist/metrics/MetricsManager.js.map +1 -1
- package/dist/metrics/constants.js +2 -0
- package/dist/metrics/constants.js.map +1 -1
- package/dist/services/core/GlobalTypes.js.map +1 -1
- package/dist/services/core/Utils.js +47 -2
- package/dist/services/core/Utils.js.map +1 -1
- package/dist/services/core/aqm-reqs.js +0 -4
- package/dist/services/core/aqm-reqs.js.map +1 -1
- package/dist/services/core/websocket/WebSocketManager.js +0 -4
- package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
- package/dist/services/task/index.js +122 -52
- package/dist/services/task/index.js.map +1 -1
- package/dist/types/metrics/constants.d.ts +1 -0
- package/dist/types/services/core/GlobalTypes.d.ts +25 -0
- package/dist/types/services/core/Utils.d.ts +16 -1
- package/dist/webex.js +1 -1
- package/package.json +1 -1
- package/src/cc.ts +15 -0
- package/src/metrics/MetricsManager.ts +1 -1
- package/src/metrics/constants.ts +3 -0
- package/src/services/core/GlobalTypes.ts +27 -0
- package/src/services/core/Utils.ts +57 -1
- package/src/services/core/aqm-reqs.ts +0 -5
- package/src/services/core/websocket/WebSocketManager.ts +0 -4
- package/src/services/task/index.ts +124 -28
- package/test/unit/spec/metrics/MetricsManager.ts +0 -1
- package/test/unit/spec/services/core/aqm-reqs.ts +1 -3
- package/test/unit/spec/services/core/websocket/WebSocketManager.ts +0 -4
- package/test/unit/spec/services/task/index.ts +153 -111
- package/umd/contact-center.min.js +2 -2
- package/umd/contact-center.min.js.map +1 -1
|
@@ -33,7 +33,7 @@ describe('Task', () => {
|
|
|
33
33
|
let mockMetricsManager;
|
|
34
34
|
let taskDataMock;
|
|
35
35
|
let webCallingService;
|
|
36
|
-
let
|
|
36
|
+
let generateTaskErrorObjectSpy;
|
|
37
37
|
let mockWebexRequest;
|
|
38
38
|
let webex: WebexSDK;
|
|
39
39
|
let loggerInfoSpy;
|
|
@@ -164,7 +164,37 @@ describe('Task', () => {
|
|
|
164
164
|
return mockStream;
|
|
165
165
|
});
|
|
166
166
|
|
|
167
|
-
|
|
167
|
+
generateTaskErrorObjectSpy = jest.spyOn(Utils, 'generateTaskErrorObject');
|
|
168
|
+
generateTaskErrorObjectSpy.mockImplementation((error: any, methodName: string) => {
|
|
169
|
+
const trackingId = error?.details?.trackingId;
|
|
170
|
+
const msg = error?.details?.msg;
|
|
171
|
+
const legacyReason = error?.details?.data?.reason;
|
|
172
|
+
const errorMessage = msg?.errorMessage || legacyReason || `Error while performing ${methodName}`;
|
|
173
|
+
const errorType = msg?.errorType || '';
|
|
174
|
+
const errorData = msg?.errorData || '';
|
|
175
|
+
const reasonCode = msg?.reasonCode || 0;
|
|
176
|
+
const reason = legacyReason || (errorType ? `${errorType}: ${errorMessage}` : errorMessage);
|
|
177
|
+
const err: any = new Error(reason);
|
|
178
|
+
err.data = {
|
|
179
|
+
trackingId,
|
|
180
|
+
message: errorMessage,
|
|
181
|
+
errorType,
|
|
182
|
+
errorData,
|
|
183
|
+
reasonCode,
|
|
184
|
+
};
|
|
185
|
+
return err;
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
(global as any).makeFailure = (reason: string, trackingId = '1234', orgId = 'org1') => ({
|
|
189
|
+
type: 'failure_event',
|
|
190
|
+
orgId,
|
|
191
|
+
trackingId,
|
|
192
|
+
data: {
|
|
193
|
+
agentId: 'agent1',
|
|
194
|
+
reason,
|
|
195
|
+
reasonCode: 0,
|
|
196
|
+
},
|
|
197
|
+
});
|
|
168
198
|
});
|
|
169
199
|
|
|
170
200
|
afterEach(() => {
|
|
@@ -420,27 +450,28 @@ describe('Task', () => {
|
|
|
420
450
|
});
|
|
421
451
|
|
|
422
452
|
it('should handle errors in accept method', async () => {
|
|
423
|
-
const error = {
|
|
424
|
-
details: {
|
|
425
|
-
trackingId: '1234',
|
|
426
|
-
data: {
|
|
427
|
-
reason: 'Accept Failed',
|
|
428
|
-
},
|
|
429
|
-
},
|
|
430
|
-
};
|
|
453
|
+
const error = {details: (global as any).makeFailure('Accept Failed')};
|
|
431
454
|
|
|
432
455
|
jest.spyOn(webCallingService, 'answerCall').mockImplementation(() => {
|
|
433
456
|
throw error;
|
|
434
457
|
});
|
|
435
458
|
|
|
436
459
|
await expect(task.accept()).rejects.toThrow(new Error(error.details.data.reason));
|
|
437
|
-
expect(
|
|
460
|
+
expect(generateTaskErrorObjectSpy).toHaveBeenCalledWith(error, 'accept', TASK_FILE);
|
|
461
|
+
const expectedTaskErrorFields = {
|
|
462
|
+
trackingId: error.details.trackingId,
|
|
463
|
+
errorMessage: error.details.data.reason,
|
|
464
|
+
errorType: '',
|
|
465
|
+
errorData: '',
|
|
466
|
+
reasonCode: 0,
|
|
467
|
+
};
|
|
438
468
|
expect(mockMetricsManager.trackEvent).toHaveBeenNthCalledWith(
|
|
439
469
|
1,
|
|
440
470
|
METRIC_EVENT_NAMES.TASK_ACCEPT_FAILED,
|
|
441
471
|
{
|
|
442
472
|
taskId: taskDataMock.interactionId,
|
|
443
473
|
error: error.toString(),
|
|
474
|
+
...expectedTaskErrorFields,
|
|
444
475
|
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details),
|
|
445
476
|
},
|
|
446
477
|
['operational', 'behavioral', 'business']
|
|
@@ -476,26 +507,27 @@ describe('Task', () => {
|
|
|
476
507
|
});
|
|
477
508
|
|
|
478
509
|
it('should handle errors in decline method', async () => {
|
|
479
|
-
const error = {
|
|
480
|
-
details: {
|
|
481
|
-
trackingId: '1234',
|
|
482
|
-
data: {
|
|
483
|
-
reason: 'Decline Failed',
|
|
484
|
-
},
|
|
485
|
-
},
|
|
486
|
-
};
|
|
510
|
+
const error = {details: (global as any).makeFailure('Decline Failed')};
|
|
487
511
|
|
|
488
512
|
jest.spyOn(webCallingService, 'declineCall').mockImplementation(() => {
|
|
489
513
|
throw error;
|
|
490
514
|
});
|
|
491
515
|
await expect(task.decline()).rejects.toThrow(new Error(error.details.data.reason));
|
|
492
|
-
expect(
|
|
516
|
+
expect(generateTaskErrorObjectSpy).toHaveBeenCalledWith(error, 'decline', TASK_FILE);
|
|
517
|
+
const expectedTaskErrorFieldsDecline = {
|
|
518
|
+
trackingId: error.details.trackingId,
|
|
519
|
+
errorMessage: error.details.data.reason,
|
|
520
|
+
errorType: '',
|
|
521
|
+
errorData: '',
|
|
522
|
+
reasonCode: 0,
|
|
523
|
+
};
|
|
493
524
|
expect(mockMetricsManager.trackEvent).toHaveBeenNthCalledWith(
|
|
494
525
|
1,
|
|
495
526
|
METRIC_EVENT_NAMES.TASK_DECLINE_FAILED,
|
|
496
527
|
{
|
|
497
528
|
taskId: taskDataMock.interactionId,
|
|
498
529
|
error: error.toString(),
|
|
530
|
+
...expectedTaskErrorFieldsDecline,
|
|
499
531
|
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details),
|
|
500
532
|
},
|
|
501
533
|
['operational', 'behavioral']
|
|
@@ -536,20 +568,20 @@ describe('Task', () => {
|
|
|
536
568
|
});
|
|
537
569
|
|
|
538
570
|
it('should handle errors in hold method', async () => {
|
|
539
|
-
const error = {
|
|
540
|
-
details: {
|
|
541
|
-
trackingId: '1234',
|
|
542
|
-
data: {
|
|
543
|
-
reason: 'Hold Failed',
|
|
544
|
-
},
|
|
545
|
-
},
|
|
546
|
-
};
|
|
571
|
+
const error = {details: (global as any).makeFailure('Hold Failed')};
|
|
547
572
|
contactMock.hold.mockImplementation(() => {
|
|
548
573
|
throw error;
|
|
549
574
|
});
|
|
550
575
|
|
|
551
576
|
await expect(task.hold()).rejects.toThrow(error.details.data.reason);
|
|
552
|
-
expect(
|
|
577
|
+
expect(generateTaskErrorObjectSpy).toHaveBeenCalledWith(error, 'hold', TASK_FILE);
|
|
578
|
+
const expectedTaskErrorFieldsHold = {
|
|
579
|
+
trackingId: error.details.trackingId,
|
|
580
|
+
errorMessage: error.details.data.reason,
|
|
581
|
+
errorType: '',
|
|
582
|
+
errorData: '',
|
|
583
|
+
reasonCode: 0,
|
|
584
|
+
};
|
|
553
585
|
expect(mockMetricsManager.trackEvent).toHaveBeenNthCalledWith(
|
|
554
586
|
1,
|
|
555
587
|
METRIC_EVENT_NAMES.TASK_HOLD_FAILED,
|
|
@@ -557,6 +589,7 @@ describe('Task', () => {
|
|
|
557
589
|
taskId: taskDataMock.interactionId,
|
|
558
590
|
mediaResourceId: taskDataMock.mediaResourceId,
|
|
559
591
|
error: error.toString(),
|
|
592
|
+
...expectedTaskErrorFieldsHold,
|
|
560
593
|
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details),
|
|
561
594
|
},
|
|
562
595
|
['operational', 'behavioral']
|
|
@@ -588,20 +621,20 @@ describe('Task', () => {
|
|
|
588
621
|
});
|
|
589
622
|
|
|
590
623
|
it('should handle errors in resume method', async () => {
|
|
591
|
-
const error = {
|
|
592
|
-
details: {
|
|
593
|
-
trackingId: '1234',
|
|
594
|
-
data: {
|
|
595
|
-
reason: 'Resume Failed',
|
|
596
|
-
},
|
|
597
|
-
},
|
|
598
|
-
};
|
|
624
|
+
const error = {details: (global as any).makeFailure('Resume Failed')};
|
|
599
625
|
contactMock.unHold.mockImplementation(() => {
|
|
600
626
|
throw error;
|
|
601
627
|
});
|
|
602
628
|
|
|
603
629
|
await expect(task.resume()).rejects.toThrow(error.details.data.reason);
|
|
604
|
-
expect(
|
|
630
|
+
expect(generateTaskErrorObjectSpy).toHaveBeenCalledWith(error, 'resume', TASK_FILE);
|
|
631
|
+
const expectedTaskErrorFieldsResume = {
|
|
632
|
+
trackingId: error.details.trackingId,
|
|
633
|
+
errorMessage: error.details.data.reason,
|
|
634
|
+
errorType: '',
|
|
635
|
+
errorData: '',
|
|
636
|
+
reasonCode: 0,
|
|
637
|
+
};
|
|
605
638
|
expect(mockMetricsManager.trackEvent).toHaveBeenNthCalledWith(
|
|
606
639
|
1,
|
|
607
640
|
METRIC_EVENT_NAMES.TASK_RESUME_FAILED,
|
|
@@ -611,6 +644,7 @@ describe('Task', () => {
|
|
|
611
644
|
mediaResourceId:
|
|
612
645
|
taskDataMock.interaction.media[taskDataMock.interaction.mainInteractionId]
|
|
613
646
|
.mediaResourceId,
|
|
647
|
+
...expectedTaskErrorFieldsResume,
|
|
614
648
|
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details),
|
|
615
649
|
},
|
|
616
650
|
['operational', 'behavioral']
|
|
@@ -653,14 +687,7 @@ describe('Task', () => {
|
|
|
653
687
|
});
|
|
654
688
|
|
|
655
689
|
it('should handle errors in consult method', async () => {
|
|
656
|
-
const error = {
|
|
657
|
-
details: {
|
|
658
|
-
trackingId: '1234',
|
|
659
|
-
data: {
|
|
660
|
-
reason: 'Consult Failed',
|
|
661
|
-
},
|
|
662
|
-
},
|
|
663
|
-
};
|
|
690
|
+
const error = {details: (global as any).makeFailure('Consult Failed')};
|
|
664
691
|
contactMock.consult.mockImplementation(() => {
|
|
665
692
|
throw error;
|
|
666
693
|
});
|
|
@@ -671,12 +698,19 @@ describe('Task', () => {
|
|
|
671
698
|
};
|
|
672
699
|
|
|
673
700
|
await expect(task.consult(consultPayload)).rejects.toThrow(error.details.data.reason);
|
|
674
|
-
expect(
|
|
701
|
+
expect(generateTaskErrorObjectSpy).toHaveBeenCalledWith(error, 'consult', TASK_FILE);
|
|
675
702
|
expect(loggerInfoSpy).toHaveBeenCalledWith(`Starting consult`, {
|
|
676
703
|
module: TASK_FILE,
|
|
677
704
|
method: 'consult',
|
|
678
705
|
interactionId: task.data.interactionId,
|
|
679
706
|
});
|
|
707
|
+
const expectedTaskErrorFieldsConsult = {
|
|
708
|
+
trackingId: error.details.trackingId,
|
|
709
|
+
errorMessage: error.details.data.reason,
|
|
710
|
+
errorType: '',
|
|
711
|
+
errorData: '',
|
|
712
|
+
reasonCode: 0,
|
|
713
|
+
};
|
|
680
714
|
expect(mockMetricsManager.trackEvent).toHaveBeenCalledWith(
|
|
681
715
|
METRIC_EVENT_NAMES.TASK_CONSULT_START_FAILED,
|
|
682
716
|
{
|
|
@@ -684,6 +718,7 @@ describe('Task', () => {
|
|
|
684
718
|
destination: consultPayload.to,
|
|
685
719
|
destinationType: consultPayload.destinationType,
|
|
686
720
|
error: error.toString(),
|
|
721
|
+
...expectedTaskErrorFieldsConsult,
|
|
687
722
|
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details),
|
|
688
723
|
},
|
|
689
724
|
['operational', 'behavioral', 'business']
|
|
@@ -717,14 +752,7 @@ describe('Task', () => {
|
|
|
717
752
|
});
|
|
718
753
|
|
|
719
754
|
it('should handle errors in endConsult method', async () => {
|
|
720
|
-
const error = {
|
|
721
|
-
details: {
|
|
722
|
-
trackingId: '1234',
|
|
723
|
-
data: {
|
|
724
|
-
reason: 'End Consult Failed',
|
|
725
|
-
},
|
|
726
|
-
},
|
|
727
|
-
};
|
|
755
|
+
const error = {details: (global as any).makeFailure('End Consult Failed')};
|
|
728
756
|
contactMock.consultEnd.mockImplementation(() => {
|
|
729
757
|
throw error;
|
|
730
758
|
});
|
|
@@ -735,13 +763,21 @@ describe('Task', () => {
|
|
|
735
763
|
};
|
|
736
764
|
|
|
737
765
|
await expect(task.endConsult(consultEndPayload)).rejects.toThrow(error.details.data.reason);
|
|
738
|
-
expect(
|
|
766
|
+
expect(generateTaskErrorObjectSpy).toHaveBeenCalledWith(error, 'endConsult', TASK_FILE);
|
|
767
|
+
const expectedTaskErrorFieldsEndConsult = {
|
|
768
|
+
trackingId: error.details.trackingId,
|
|
769
|
+
errorMessage: error.details.data.reason,
|
|
770
|
+
errorType: '',
|
|
771
|
+
errorData: '',
|
|
772
|
+
reasonCode: 0,
|
|
773
|
+
};
|
|
739
774
|
expect(mockMetricsManager.trackEvent).toHaveBeenNthCalledWith(
|
|
740
775
|
1,
|
|
741
776
|
METRIC_EVENT_NAMES.TASK_CONSULT_END_FAILED,
|
|
742
777
|
{
|
|
743
778
|
taskId: taskDataMock.interactionId,
|
|
744
779
|
error: error.toString(),
|
|
780
|
+
...expectedTaskErrorFieldsEndConsult,
|
|
745
781
|
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details),
|
|
746
782
|
},
|
|
747
783
|
['operational', 'behavioral', 'business']
|
|
@@ -891,14 +927,7 @@ describe('Task', () => {
|
|
|
891
927
|
expect(contactMock.consult).toHaveBeenCalledWith({interactionId: taskId, data: consultPayload});
|
|
892
928
|
expect(response).toEqual(expectedResponse);
|
|
893
929
|
|
|
894
|
-
const error = {
|
|
895
|
-
details: {
|
|
896
|
-
trackingId: '1234',
|
|
897
|
-
data: {
|
|
898
|
-
reason: 'Consult Transfer Failed',
|
|
899
|
-
},
|
|
900
|
-
},
|
|
901
|
-
};
|
|
930
|
+
const error = {details: (global as any).makeFailure('Consult Transfer Failed')};
|
|
902
931
|
contactMock.consultTransfer.mockImplementation(() => {
|
|
903
932
|
throw error;
|
|
904
933
|
});
|
|
@@ -911,7 +940,14 @@ describe('Task', () => {
|
|
|
911
940
|
await expect(task.consultTransfer(consultTransferPayload)).rejects.toThrow(
|
|
912
941
|
error.details.data.reason
|
|
913
942
|
);
|
|
914
|
-
expect(
|
|
943
|
+
expect(generateTaskErrorObjectSpy).toHaveBeenCalledWith(error, 'consultTransfer', TASK_FILE);
|
|
944
|
+
const expectedTaskErrorFieldsConsultTransfer = {
|
|
945
|
+
trackingId: error.details.trackingId,
|
|
946
|
+
errorMessage: error.details.data.reason,
|
|
947
|
+
errorType: '',
|
|
948
|
+
errorData: '',
|
|
949
|
+
reasonCode: 0,
|
|
950
|
+
};
|
|
915
951
|
expect(mockMetricsManager.trackEvent).toHaveBeenNthCalledWith(
|
|
916
952
|
2,
|
|
917
953
|
METRIC_EVENT_NAMES.TASK_TRANSFER_FAILED,
|
|
@@ -921,6 +957,7 @@ describe('Task', () => {
|
|
|
921
957
|
destinationType: CONSULT_TRANSFER_DESTINATION_TYPE.AGENT,
|
|
922
958
|
isConsultTransfer: true,
|
|
923
959
|
error: error.toString(),
|
|
960
|
+
...expectedTaskErrorFieldsConsultTransfer,
|
|
924
961
|
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details),
|
|
925
962
|
},
|
|
926
963
|
['operational', 'behavioral', 'business']
|
|
@@ -988,14 +1025,7 @@ describe('Task', () => {
|
|
|
988
1025
|
});
|
|
989
1026
|
|
|
990
1027
|
it('should handle errors in transfer method', async () => {
|
|
991
|
-
const error = {
|
|
992
|
-
details: {
|
|
993
|
-
trackingId: '1234',
|
|
994
|
-
data: {
|
|
995
|
-
reason: 'Consult Transfer Failed',
|
|
996
|
-
},
|
|
997
|
-
},
|
|
998
|
-
};
|
|
1028
|
+
const error = {details: (global as any).makeFailure('Consult Transfer Failed')};
|
|
999
1029
|
contactMock.blindTransfer.mockImplementation(() => {
|
|
1000
1030
|
throw error;
|
|
1001
1031
|
});
|
|
@@ -1006,7 +1036,14 @@ describe('Task', () => {
|
|
|
1006
1036
|
};
|
|
1007
1037
|
|
|
1008
1038
|
await expect(task.transfer(blindTransferPayload)).rejects.toThrow(error.details.data.reason);
|
|
1009
|
-
expect(
|
|
1039
|
+
expect(generateTaskErrorObjectSpy).toHaveBeenCalledWith(error, 'transfer', TASK_FILE);
|
|
1040
|
+
const expectedTaskErrorFieldsTransfer = {
|
|
1041
|
+
trackingId: error.details.trackingId,
|
|
1042
|
+
errorMessage: error.details.data.reason,
|
|
1043
|
+
errorType: '',
|
|
1044
|
+
errorData: '',
|
|
1045
|
+
reasonCode: 0,
|
|
1046
|
+
};
|
|
1010
1047
|
expect(mockMetricsManager.trackEvent).toHaveBeenNthCalledWith(
|
|
1011
1048
|
1,
|
|
1012
1049
|
METRIC_EVENT_NAMES.TASK_TRANSFER_FAILED,
|
|
@@ -1016,6 +1053,7 @@ describe('Task', () => {
|
|
|
1016
1053
|
destinationType: blindTransferPayload.destinationType,
|
|
1017
1054
|
isConsultTransfer: false,
|
|
1018
1055
|
error: error.toString(),
|
|
1056
|
+
...expectedTaskErrorFieldsTransfer,
|
|
1019
1057
|
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details),
|
|
1020
1058
|
},
|
|
1021
1059
|
['operational', 'behavioral', 'business']
|
|
@@ -1052,25 +1090,26 @@ describe('Task', () => {
|
|
|
1052
1090
|
});
|
|
1053
1091
|
|
|
1054
1092
|
it('should handle errors in end method', async () => {
|
|
1055
|
-
const error = {
|
|
1056
|
-
details: {
|
|
1057
|
-
trackingId: '1234',
|
|
1058
|
-
data: {
|
|
1059
|
-
reason: 'End Failed',
|
|
1060
|
-
},
|
|
1061
|
-
},
|
|
1062
|
-
};
|
|
1093
|
+
const error = {details: (global as any).makeFailure('End Failed')};
|
|
1063
1094
|
contactMock.end.mockImplementation(() => {
|
|
1064
1095
|
throw error;
|
|
1065
1096
|
});
|
|
1066
1097
|
|
|
1067
1098
|
await expect(task.end()).rejects.toThrow(error.details.data.reason);
|
|
1068
|
-
expect(
|
|
1099
|
+
expect(generateTaskErrorObjectSpy).toHaveBeenCalledWith(error, 'end', TASK_FILE);
|
|
1100
|
+
const expectedTaskErrorFieldsEnd = {
|
|
1101
|
+
trackingId: error.details.trackingId,
|
|
1102
|
+
errorMessage: error.details.data.reason,
|
|
1103
|
+
errorType: '',
|
|
1104
|
+
errorData: '',
|
|
1105
|
+
reasonCode: 0,
|
|
1106
|
+
};
|
|
1069
1107
|
expect(mockMetricsManager.trackEvent).toHaveBeenNthCalledWith(
|
|
1070
1108
|
1,
|
|
1071
1109
|
METRIC_EVENT_NAMES.TASK_END_FAILED,
|
|
1072
1110
|
{
|
|
1073
1111
|
taskId: taskDataMock.interactionId,
|
|
1112
|
+
...expectedTaskErrorFieldsEnd,
|
|
1074
1113
|
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details),
|
|
1075
1114
|
},
|
|
1076
1115
|
['operational', 'behavioral', 'business']
|
|
@@ -1103,14 +1142,7 @@ describe('Task', () => {
|
|
|
1103
1142
|
});
|
|
1104
1143
|
|
|
1105
1144
|
it('should handle errors in wrapup method', async () => {
|
|
1106
|
-
const error = {
|
|
1107
|
-
details: {
|
|
1108
|
-
trackingId: '1234',
|
|
1109
|
-
data: {
|
|
1110
|
-
reason: 'Wrapup Failed',
|
|
1111
|
-
},
|
|
1112
|
-
},
|
|
1113
|
-
};
|
|
1145
|
+
const error = {details: (global as any).makeFailure('Wrapup Failed')};
|
|
1114
1146
|
contactMock.wrapup.mockImplementation(() => {
|
|
1115
1147
|
throw error;
|
|
1116
1148
|
});
|
|
@@ -1121,7 +1153,14 @@ describe('Task', () => {
|
|
|
1121
1153
|
};
|
|
1122
1154
|
|
|
1123
1155
|
await expect(task.wrapup(wrapupPayload)).rejects.toThrow(error.details.data.reason);
|
|
1124
|
-
expect(
|
|
1156
|
+
expect(generateTaskErrorObjectSpy).toHaveBeenCalledWith(error, 'wrapup', TASK_FILE);
|
|
1157
|
+
const expectedTaskErrorFieldsWrapup = {
|
|
1158
|
+
trackingId: error.details.trackingId,
|
|
1159
|
+
errorMessage: error.details.data.reason,
|
|
1160
|
+
errorType: '',
|
|
1161
|
+
errorData: '',
|
|
1162
|
+
reasonCode: 0,
|
|
1163
|
+
};
|
|
1125
1164
|
expect(mockMetricsManager.trackEvent).toHaveBeenNthCalledWith(
|
|
1126
1165
|
1,
|
|
1127
1166
|
METRIC_EVENT_NAMES.TASK_WRAPUP_FAILED,
|
|
@@ -1129,6 +1168,7 @@ describe('Task', () => {
|
|
|
1129
1168
|
taskId: taskDataMock.interactionId,
|
|
1130
1169
|
wrapUpCode: wrapupPayload.auxCodeId,
|
|
1131
1170
|
wrapUpReason: wrapupPayload.wrapUpReason,
|
|
1171
|
+
...expectedTaskErrorFieldsWrapup,
|
|
1132
1172
|
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details),
|
|
1133
1173
|
},
|
|
1134
1174
|
['operational', 'behavioral', 'business']
|
|
@@ -1186,26 +1226,27 @@ describe('Task', () => {
|
|
|
1186
1226
|
});
|
|
1187
1227
|
|
|
1188
1228
|
it('should handle errors in pauseRecording method', async () => {
|
|
1189
|
-
const error = {
|
|
1190
|
-
details: {
|
|
1191
|
-
trackingId: '1234',
|
|
1192
|
-
data: {
|
|
1193
|
-
reason: 'Pause Recording Failed',
|
|
1194
|
-
},
|
|
1195
|
-
},
|
|
1196
|
-
};
|
|
1229
|
+
const error = {details: (global as any).makeFailure('Pause Recording Failed')};
|
|
1197
1230
|
contactMock.pauseRecording.mockImplementation(() => {
|
|
1198
1231
|
throw error;
|
|
1199
1232
|
});
|
|
1200
1233
|
|
|
1201
1234
|
await expect(task.pauseRecording()).rejects.toThrow(error.details.data.reason);
|
|
1202
|
-
expect(
|
|
1235
|
+
expect(generateTaskErrorObjectSpy).toHaveBeenCalledWith(error, 'pauseRecording', TASK_FILE);
|
|
1236
|
+
const expectedTaskErrorFieldsPause = {
|
|
1237
|
+
trackingId: error.details.trackingId,
|
|
1238
|
+
errorMessage: error.details.data.reason,
|
|
1239
|
+
errorType: '',
|
|
1240
|
+
errorData: '',
|
|
1241
|
+
reasonCode: 0,
|
|
1242
|
+
};
|
|
1203
1243
|
expect(mockMetricsManager.trackEvent).toHaveBeenNthCalledWith(
|
|
1204
1244
|
1,
|
|
1205
1245
|
METRIC_EVENT_NAMES.TASK_PAUSE_RECORDING_FAILED,
|
|
1206
1246
|
{
|
|
1207
1247
|
taskId: taskDataMock.interactionId,
|
|
1208
1248
|
error: error.toString(),
|
|
1249
|
+
...expectedTaskErrorFieldsPause,
|
|
1209
1250
|
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details),
|
|
1210
1251
|
},
|
|
1211
1252
|
['operational', 'behavioral', 'business']
|
|
@@ -1266,14 +1307,7 @@ describe('Task', () => {
|
|
|
1266
1307
|
});
|
|
1267
1308
|
|
|
1268
1309
|
it('should handle errors in resumeRecording method', async () => {
|
|
1269
|
-
const error = {
|
|
1270
|
-
details: {
|
|
1271
|
-
trackingId: '1234',
|
|
1272
|
-
data: {
|
|
1273
|
-
reason: 'Resume Recording Failed',
|
|
1274
|
-
},
|
|
1275
|
-
},
|
|
1276
|
-
};
|
|
1310
|
+
const error = {details: (global as any).makeFailure('Resume Recording Failed')};
|
|
1277
1311
|
contactMock.resumeRecording.mockImplementation(() => {
|
|
1278
1312
|
throw error;
|
|
1279
1313
|
});
|
|
@@ -1283,13 +1317,21 @@ describe('Task', () => {
|
|
|
1283
1317
|
};
|
|
1284
1318
|
|
|
1285
1319
|
await expect(task.resumeRecording(resumePayload)).rejects.toThrow(error.details.data.reason);
|
|
1286
|
-
expect(
|
|
1320
|
+
expect(generateTaskErrorObjectSpy).toHaveBeenCalledWith(error, 'resumeRecording', TASK_FILE);
|
|
1321
|
+
const expectedTaskErrorFieldsResumeRec = {
|
|
1322
|
+
trackingId: error.details.trackingId,
|
|
1323
|
+
errorMessage: error.details.data.reason,
|
|
1324
|
+
errorType: '',
|
|
1325
|
+
errorData: '',
|
|
1326
|
+
reasonCode: 0,
|
|
1327
|
+
};
|
|
1287
1328
|
expect(mockMetricsManager.trackEvent).toHaveBeenNthCalledWith(
|
|
1288
1329
|
1,
|
|
1289
1330
|
METRIC_EVENT_NAMES.TASK_RESUME_RECORDING_FAILED,
|
|
1290
1331
|
{
|
|
1291
1332
|
taskId: taskDataMock.interactionId,
|
|
1292
1333
|
error: error.toString(),
|
|
1334
|
+
...expectedTaskErrorFieldsResumeRec,
|
|
1293
1335
|
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details),
|
|
1294
1336
|
},
|
|
1295
1337
|
['operational', 'behavioral', 'business']
|
|
@@ -1329,7 +1371,7 @@ describe('Task', () => {
|
|
|
1329
1371
|
throw error;
|
|
1330
1372
|
});
|
|
1331
1373
|
await expect(task.toggleMute()).rejects.toThrow(new Error(error.details.data.reason));
|
|
1332
|
-
expect(
|
|
1374
|
+
expect(generateTaskErrorObjectSpy).toHaveBeenCalledWith(error, 'toggleMute', TASK_FILE);
|
|
1333
1375
|
expect(loggerInfoSpy).toHaveBeenCalledWith(`Toggling mute state`, {
|
|
1334
1376
|
module: TASK_FILE,
|
|
1335
1377
|
method: 'toggleMute',
|