@webex/contact-center 3.8.1 → 3.9.0-next.10
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 +105 -63
- package/dist/cc.js.map +1 -1
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/logger-proxy.js +24 -1
- package/dist/logger-proxy.js.map +1 -1
- package/dist/metrics/MetricsManager.js +1 -1
- package/dist/metrics/MetricsManager.js.map +1 -1
- package/dist/metrics/behavioral-events.js +51 -0
- package/dist/metrics/behavioral-events.js.map +1 -1
- package/dist/metrics/constants.js +12 -1
- package/dist/metrics/constants.js.map +1 -1
- package/dist/services/AddressBook.js +271 -0
- package/dist/services/AddressBook.js.map +1 -0
- package/dist/services/EntryPoint.js +227 -0
- package/dist/services/EntryPoint.js.map +1 -0
- package/dist/services/Queue.js +261 -0
- package/dist/services/Queue.js.map +1 -0
- package/dist/services/config/constants.js +24 -2
- package/dist/services/config/constants.js.map +1 -1
- package/dist/services/config/index.js +1 -43
- package/dist/services/config/index.js.map +1 -1
- package/dist/services/config/types.js +0 -5
- package/dist/services/config/types.js.map +1 -1
- package/dist/services/core/GlobalTypes.js.map +1 -1
- package/dist/services/core/Utils.js +121 -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/TaskManager.js +1 -0
- package/dist/services/task/TaskManager.js.map +1 -1
- package/dist/services/task/index.js +145 -71
- package/dist/services/task/index.js.map +1 -1
- package/dist/types/cc.d.ts +77 -43
- package/dist/types/index.d.ts +8 -3
- package/dist/types/metrics/constants.d.ts +7 -0
- package/dist/types/services/AddressBook.d.ts +74 -0
- package/dist/types/services/EntryPoint.d.ts +67 -0
- package/dist/types/services/Queue.d.ts +76 -0
- package/dist/types/services/config/constants.d.ts +23 -1
- package/dist/types/services/config/index.d.ts +1 -14
- package/dist/types/services/config/types.d.ts +0 -64
- package/dist/types/services/core/GlobalTypes.d.ts +25 -0
- package/dist/types/services/core/Utils.d.ts +27 -1
- package/dist/types/services/task/index.d.ts +1 -1
- package/dist/types/types.d.ts +162 -0
- package/dist/types/utils/PageCache.d.ts +173 -0
- package/dist/types.js +17 -0
- package/dist/types.js.map +1 -1
- package/dist/utils/PageCache.js +192 -0
- package/dist/utils/PageCache.js.map +1 -0
- package/dist/webex.js +1 -1
- package/package.json +10 -10
- package/src/cc.ts +121 -81
- package/src/index.ts +19 -3
- package/src/logger-proxy.ts +24 -1
- package/src/metrics/MetricsManager.ts +1 -1
- package/src/metrics/behavioral-events.ts +54 -0
- package/src/metrics/constants.ts +15 -0
- package/src/services/AddressBook.ts +291 -0
- package/src/services/EntryPoint.ts +241 -0
- package/src/services/Queue.ts +277 -0
- package/src/services/config/constants.ts +26 -2
- package/src/services/config/index.ts +1 -55
- package/src/services/config/types.ts +0 -65
- package/src/services/core/GlobalTypes.ts +27 -0
- package/src/services/core/Utils.ts +155 -1
- package/src/services/core/aqm-reqs.ts +0 -5
- package/src/services/core/websocket/WebSocketManager.ts +0 -4
- package/src/services/task/TaskManager.ts +1 -0
- package/src/services/task/index.ts +172 -56
- package/src/types.ts +180 -0
- package/src/utils/PageCache.ts +252 -0
- package/test/unit/spec/cc.ts +30 -82
- package/test/unit/spec/metrics/MetricsManager.ts +0 -1
- package/test/unit/spec/metrics/behavioral-events.ts +14 -0
- package/test/unit/spec/services/AddressBook.ts +332 -0
- package/test/unit/spec/services/EntryPoint.ts +259 -0
- package/test/unit/spec/services/Queue.ts +323 -0
- package/test/unit/spec/services/config/index.ts +0 -71
- package/test/unit/spec/services/core/Utils.ts +50 -0
- 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/TaskManager.ts +8 -1
- package/test/unit/spec/services/task/index.ts +226 -122
- package/umd/contact-center.min.js +2 -2
- package/umd/contact-center.min.js.map +1 -1
|
@@ -33,12 +33,13 @@ 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;
|
|
40
40
|
let loggerLogSpy;
|
|
41
41
|
let loggerErrorSpy;
|
|
42
|
+
let getDestinationAgentIdSpy;
|
|
42
43
|
|
|
43
44
|
const taskId = '0ae913a4-c857-4705-8d49-76dd3dde75e4';
|
|
44
45
|
const mockTrack = {} as MediaStreamTrack;
|
|
@@ -141,6 +142,11 @@ describe('Task', () => {
|
|
|
141
142
|
},
|
|
142
143
|
};
|
|
143
144
|
|
|
145
|
+
// Mock destination agent id resolution from participants
|
|
146
|
+
getDestinationAgentIdSpy = jest
|
|
147
|
+
.spyOn(Utils, 'getDestinationAgentId')
|
|
148
|
+
.mockReturnValue(taskDataMock.destAgentId);
|
|
149
|
+
|
|
144
150
|
// Create an instance of Task
|
|
145
151
|
task = new Task(contactMock, webCallingService, taskDataMock);
|
|
146
152
|
|
|
@@ -158,11 +164,42 @@ describe('Task', () => {
|
|
|
158
164
|
return mockStream;
|
|
159
165
|
});
|
|
160
166
|
|
|
161
|
-
|
|
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
|
+
});
|
|
162
198
|
});
|
|
163
199
|
|
|
164
200
|
afterEach(() => {
|
|
165
201
|
jest.clearAllMocks();
|
|
202
|
+
jest.restoreAllMocks();
|
|
166
203
|
});
|
|
167
204
|
|
|
168
205
|
it('test the on spy', async () => {
|
|
@@ -413,27 +450,28 @@ describe('Task', () => {
|
|
|
413
450
|
});
|
|
414
451
|
|
|
415
452
|
it('should handle errors in accept method', async () => {
|
|
416
|
-
const error = {
|
|
417
|
-
details: {
|
|
418
|
-
trackingId: '1234',
|
|
419
|
-
data: {
|
|
420
|
-
reason: 'Accept Failed',
|
|
421
|
-
},
|
|
422
|
-
},
|
|
423
|
-
};
|
|
453
|
+
const error = {details: (global as any).makeFailure('Accept Failed')};
|
|
424
454
|
|
|
425
455
|
jest.spyOn(webCallingService, 'answerCall').mockImplementation(() => {
|
|
426
456
|
throw error;
|
|
427
457
|
});
|
|
428
458
|
|
|
429
459
|
await expect(task.accept()).rejects.toThrow(new Error(error.details.data.reason));
|
|
430
|
-
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
|
+
};
|
|
431
468
|
expect(mockMetricsManager.trackEvent).toHaveBeenNthCalledWith(
|
|
432
469
|
1,
|
|
433
470
|
METRIC_EVENT_NAMES.TASK_ACCEPT_FAILED,
|
|
434
471
|
{
|
|
435
472
|
taskId: taskDataMock.interactionId,
|
|
436
473
|
error: error.toString(),
|
|
474
|
+
...expectedTaskErrorFields,
|
|
437
475
|
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details),
|
|
438
476
|
},
|
|
439
477
|
['operational', 'behavioral', 'business']
|
|
@@ -469,26 +507,27 @@ describe('Task', () => {
|
|
|
469
507
|
});
|
|
470
508
|
|
|
471
509
|
it('should handle errors in decline method', async () => {
|
|
472
|
-
const error = {
|
|
473
|
-
details: {
|
|
474
|
-
trackingId: '1234',
|
|
475
|
-
data: {
|
|
476
|
-
reason: 'Decline Failed',
|
|
477
|
-
},
|
|
478
|
-
},
|
|
479
|
-
};
|
|
510
|
+
const error = {details: (global as any).makeFailure('Decline Failed')};
|
|
480
511
|
|
|
481
512
|
jest.spyOn(webCallingService, 'declineCall').mockImplementation(() => {
|
|
482
513
|
throw error;
|
|
483
514
|
});
|
|
484
515
|
await expect(task.decline()).rejects.toThrow(new Error(error.details.data.reason));
|
|
485
|
-
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
|
+
};
|
|
486
524
|
expect(mockMetricsManager.trackEvent).toHaveBeenNthCalledWith(
|
|
487
525
|
1,
|
|
488
526
|
METRIC_EVENT_NAMES.TASK_DECLINE_FAILED,
|
|
489
527
|
{
|
|
490
528
|
taskId: taskDataMock.interactionId,
|
|
491
529
|
error: error.toString(),
|
|
530
|
+
...expectedTaskErrorFieldsDecline,
|
|
492
531
|
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details),
|
|
493
532
|
},
|
|
494
533
|
['operational', 'behavioral']
|
|
@@ -529,20 +568,20 @@ describe('Task', () => {
|
|
|
529
568
|
});
|
|
530
569
|
|
|
531
570
|
it('should handle errors in hold method', async () => {
|
|
532
|
-
const error = {
|
|
533
|
-
details: {
|
|
534
|
-
trackingId: '1234',
|
|
535
|
-
data: {
|
|
536
|
-
reason: 'Hold Failed',
|
|
537
|
-
},
|
|
538
|
-
},
|
|
539
|
-
};
|
|
571
|
+
const error = {details: (global as any).makeFailure('Hold Failed')};
|
|
540
572
|
contactMock.hold.mockImplementation(() => {
|
|
541
573
|
throw error;
|
|
542
574
|
});
|
|
543
575
|
|
|
544
576
|
await expect(task.hold()).rejects.toThrow(error.details.data.reason);
|
|
545
|
-
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
|
+
};
|
|
546
585
|
expect(mockMetricsManager.trackEvent).toHaveBeenNthCalledWith(
|
|
547
586
|
1,
|
|
548
587
|
METRIC_EVENT_NAMES.TASK_HOLD_FAILED,
|
|
@@ -550,6 +589,7 @@ describe('Task', () => {
|
|
|
550
589
|
taskId: taskDataMock.interactionId,
|
|
551
590
|
mediaResourceId: taskDataMock.mediaResourceId,
|
|
552
591
|
error: error.toString(),
|
|
592
|
+
...expectedTaskErrorFieldsHold,
|
|
553
593
|
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details),
|
|
554
594
|
},
|
|
555
595
|
['operational', 'behavioral']
|
|
@@ -581,20 +621,20 @@ describe('Task', () => {
|
|
|
581
621
|
});
|
|
582
622
|
|
|
583
623
|
it('should handle errors in resume method', async () => {
|
|
584
|
-
const error = {
|
|
585
|
-
details: {
|
|
586
|
-
trackingId: '1234',
|
|
587
|
-
data: {
|
|
588
|
-
reason: 'Resume Failed',
|
|
589
|
-
},
|
|
590
|
-
},
|
|
591
|
-
};
|
|
624
|
+
const error = {details: (global as any).makeFailure('Resume Failed')};
|
|
592
625
|
contactMock.unHold.mockImplementation(() => {
|
|
593
626
|
throw error;
|
|
594
627
|
});
|
|
595
628
|
|
|
596
629
|
await expect(task.resume()).rejects.toThrow(error.details.data.reason);
|
|
597
|
-
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
|
+
};
|
|
598
638
|
expect(mockMetricsManager.trackEvent).toHaveBeenNthCalledWith(
|
|
599
639
|
1,
|
|
600
640
|
METRIC_EVENT_NAMES.TASK_RESUME_FAILED,
|
|
@@ -604,6 +644,7 @@ describe('Task', () => {
|
|
|
604
644
|
mediaResourceId:
|
|
605
645
|
taskDataMock.interaction.media[taskDataMock.interaction.mainInteractionId]
|
|
606
646
|
.mediaResourceId,
|
|
647
|
+
...expectedTaskErrorFieldsResume,
|
|
607
648
|
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details),
|
|
608
649
|
},
|
|
609
650
|
['operational', 'behavioral']
|
|
@@ -646,14 +687,7 @@ describe('Task', () => {
|
|
|
646
687
|
});
|
|
647
688
|
|
|
648
689
|
it('should handle errors in consult method', async () => {
|
|
649
|
-
const error = {
|
|
650
|
-
details: {
|
|
651
|
-
trackingId: '1234',
|
|
652
|
-
data: {
|
|
653
|
-
reason: 'Consult Failed',
|
|
654
|
-
},
|
|
655
|
-
},
|
|
656
|
-
};
|
|
690
|
+
const error = {details: (global as any).makeFailure('Consult Failed')};
|
|
657
691
|
contactMock.consult.mockImplementation(() => {
|
|
658
692
|
throw error;
|
|
659
693
|
});
|
|
@@ -664,12 +698,19 @@ describe('Task', () => {
|
|
|
664
698
|
};
|
|
665
699
|
|
|
666
700
|
await expect(task.consult(consultPayload)).rejects.toThrow(error.details.data.reason);
|
|
667
|
-
expect(
|
|
701
|
+
expect(generateTaskErrorObjectSpy).toHaveBeenCalledWith(error, 'consult', TASK_FILE);
|
|
668
702
|
expect(loggerInfoSpy).toHaveBeenCalledWith(`Starting consult`, {
|
|
669
703
|
module: TASK_FILE,
|
|
670
704
|
method: 'consult',
|
|
671
705
|
interactionId: task.data.interactionId,
|
|
672
706
|
});
|
|
707
|
+
const expectedTaskErrorFieldsConsult = {
|
|
708
|
+
trackingId: error.details.trackingId,
|
|
709
|
+
errorMessage: error.details.data.reason,
|
|
710
|
+
errorType: '',
|
|
711
|
+
errorData: '',
|
|
712
|
+
reasonCode: 0,
|
|
713
|
+
};
|
|
673
714
|
expect(mockMetricsManager.trackEvent).toHaveBeenCalledWith(
|
|
674
715
|
METRIC_EVENT_NAMES.TASK_CONSULT_START_FAILED,
|
|
675
716
|
{
|
|
@@ -677,6 +718,7 @@ describe('Task', () => {
|
|
|
677
718
|
destination: consultPayload.to,
|
|
678
719
|
destinationType: consultPayload.destinationType,
|
|
679
720
|
error: error.toString(),
|
|
721
|
+
...expectedTaskErrorFieldsConsult,
|
|
680
722
|
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details),
|
|
681
723
|
},
|
|
682
724
|
['operational', 'behavioral', 'business']
|
|
@@ -710,14 +752,7 @@ describe('Task', () => {
|
|
|
710
752
|
});
|
|
711
753
|
|
|
712
754
|
it('should handle errors in endConsult method', async () => {
|
|
713
|
-
const error = {
|
|
714
|
-
details: {
|
|
715
|
-
trackingId: '1234',
|
|
716
|
-
data: {
|
|
717
|
-
reason: 'End Consult Failed',
|
|
718
|
-
},
|
|
719
|
-
},
|
|
720
|
-
};
|
|
755
|
+
const error = {details: (global as any).makeFailure('End Consult Failed')};
|
|
721
756
|
contactMock.consultEnd.mockImplementation(() => {
|
|
722
757
|
throw error;
|
|
723
758
|
});
|
|
@@ -728,13 +763,21 @@ describe('Task', () => {
|
|
|
728
763
|
};
|
|
729
764
|
|
|
730
765
|
await expect(task.endConsult(consultEndPayload)).rejects.toThrow(error.details.data.reason);
|
|
731
|
-
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
|
+
};
|
|
732
774
|
expect(mockMetricsManager.trackEvent).toHaveBeenNthCalledWith(
|
|
733
775
|
1,
|
|
734
776
|
METRIC_EVENT_NAMES.TASK_CONSULT_END_FAILED,
|
|
735
777
|
{
|
|
736
778
|
taskId: taskDataMock.interactionId,
|
|
737
779
|
error: error.toString(),
|
|
780
|
+
...expectedTaskErrorFieldsEndConsult,
|
|
738
781
|
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details),
|
|
739
782
|
},
|
|
740
783
|
['operational', 'behavioral', 'business']
|
|
@@ -754,29 +797,81 @@ describe('Task', () => {
|
|
|
754
797
|
expect(contactMock.consult).toHaveBeenCalledWith({interactionId: taskId, data: consultPayload});
|
|
755
798
|
expect(response).toEqual(expectedResponse);
|
|
756
799
|
|
|
757
|
-
const
|
|
758
|
-
to: '1234',
|
|
759
|
-
destinationType: CONSULT_TRANSFER_DESTINATION_TYPE.AGENT,
|
|
760
|
-
};
|
|
761
|
-
|
|
762
|
-
const consultTransferResponse = await task.consultTransfer(consultTransferPayload);
|
|
800
|
+
const consultTransferResponse = await task.consultTransfer();
|
|
763
801
|
expect(contactMock.consultTransfer).toHaveBeenCalledWith({
|
|
764
802
|
interactionId: taskId,
|
|
765
|
-
data:
|
|
803
|
+
data: {
|
|
804
|
+
to: taskDataMock.destAgentId,
|
|
805
|
+
destinationType: CONSULT_TRANSFER_DESTINATION_TYPE.AGENT,
|
|
806
|
+
},
|
|
766
807
|
});
|
|
767
808
|
expect(mockMetricsManager.trackEvent).toHaveBeenNthCalledWith(
|
|
768
809
|
2,
|
|
769
810
|
METRIC_EVENT_NAMES.TASK_TRANSFER_SUCCESS,
|
|
770
811
|
{
|
|
771
812
|
taskId: taskDataMock.interactionId,
|
|
772
|
-
destination:
|
|
773
|
-
destinationType:
|
|
813
|
+
destination: taskDataMock.destAgentId,
|
|
814
|
+
destinationType: CONSULT_TRANSFER_DESTINATION_TYPE.AGENT,
|
|
774
815
|
isConsultTransfer: true,
|
|
775
816
|
},
|
|
776
817
|
['operational', 'behavioral', 'business']
|
|
777
818
|
);
|
|
778
819
|
});
|
|
779
820
|
|
|
821
|
+
it('should send DIALNUMBER when task destinationType is DN during consultTransfer', async () => {
|
|
822
|
+
const expectedResponse: TaskResponse = {data: {interactionId: taskId}} as AgentContact;
|
|
823
|
+
contactMock.consultTransfer.mockResolvedValue(expectedResponse);
|
|
824
|
+
|
|
825
|
+
// Ensure task data indicates DN scenario
|
|
826
|
+
task.data.destinationType = 'DN' as unknown as string;
|
|
827
|
+
|
|
828
|
+
await task.consultTransfer();
|
|
829
|
+
|
|
830
|
+
expect(contactMock.consultTransfer).toHaveBeenCalledWith({
|
|
831
|
+
interactionId: taskId,
|
|
832
|
+
data: {
|
|
833
|
+
to: taskDataMock.destAgentId,
|
|
834
|
+
destinationType: CONSULT_TRANSFER_DESTINATION_TYPE.DIALNUMBER,
|
|
835
|
+
},
|
|
836
|
+
});
|
|
837
|
+
});
|
|
838
|
+
|
|
839
|
+
it('should send ENTRYPOINT when task destinationType is EPDN during consultTransfer', async () => {
|
|
840
|
+
const expectedResponse: TaskResponse = {data: {interactionId: taskId}} as AgentContact;
|
|
841
|
+
contactMock.consultTransfer.mockResolvedValue(expectedResponse);
|
|
842
|
+
|
|
843
|
+
// Ensure task data indicates EP/EPDN scenario
|
|
844
|
+
task.data.destinationType = 'EPDN' as unknown as string;
|
|
845
|
+
|
|
846
|
+
await task.consultTransfer();
|
|
847
|
+
|
|
848
|
+
expect(contactMock.consultTransfer).toHaveBeenCalledWith({
|
|
849
|
+
interactionId: taskId,
|
|
850
|
+
data: {
|
|
851
|
+
to: taskDataMock.destAgentId,
|
|
852
|
+
destinationType: CONSULT_TRANSFER_DESTINATION_TYPE.ENTRYPOINT,
|
|
853
|
+
},
|
|
854
|
+
});
|
|
855
|
+
});
|
|
856
|
+
|
|
857
|
+
it('should keep AGENT when task destinationType is neither DN nor EPDN/ENTRYPOINT', async () => {
|
|
858
|
+
const expectedResponse: TaskResponse = {data: {interactionId: taskId}} as AgentContact;
|
|
859
|
+
contactMock.consultTransfer.mockResolvedValue(expectedResponse);
|
|
860
|
+
|
|
861
|
+
// Ensure task data indicates non-DN and non-EP/EPDN scenario
|
|
862
|
+
task.data.destinationType = 'SOMETHING_ELSE' as unknown as string;
|
|
863
|
+
|
|
864
|
+
await task.consultTransfer();
|
|
865
|
+
|
|
866
|
+
expect(contactMock.consultTransfer).toHaveBeenCalledWith({
|
|
867
|
+
interactionId: taskId,
|
|
868
|
+
data: {
|
|
869
|
+
to: taskDataMock.destAgentId,
|
|
870
|
+
destinationType: CONSULT_TRANSFER_DESTINATION_TYPE.AGENT,
|
|
871
|
+
},
|
|
872
|
+
});
|
|
873
|
+
});
|
|
874
|
+
|
|
780
875
|
it('should do consult transfer to a queue by using the destAgentId from task data', async () => {
|
|
781
876
|
const expectedResponse: TaskResponse = {data: {interactionId: taskId}} as AgentContact;
|
|
782
877
|
contactMock.consultTransfer.mockResolvedValue(expectedResponse);
|
|
@@ -811,6 +906,9 @@ describe('Task', () => {
|
|
|
811
906
|
destinationType: CONSULT_TRANSFER_DESTINATION_TYPE.QUEUE,
|
|
812
907
|
};
|
|
813
908
|
|
|
909
|
+
// For this negative case, ensure computed destination is empty
|
|
910
|
+
getDestinationAgentIdSpy.mockReturnValueOnce('');
|
|
911
|
+
|
|
814
912
|
await expect(
|
|
815
913
|
taskWithoutDestAgentId.consultTransfer(queueConsultTransferPayload)
|
|
816
914
|
).rejects.toThrow('Error while performing consultTransfer');
|
|
@@ -829,14 +927,7 @@ describe('Task', () => {
|
|
|
829
927
|
expect(contactMock.consult).toHaveBeenCalledWith({interactionId: taskId, data: consultPayload});
|
|
830
928
|
expect(response).toEqual(expectedResponse);
|
|
831
929
|
|
|
832
|
-
const error = {
|
|
833
|
-
details: {
|
|
834
|
-
trackingId: '1234',
|
|
835
|
-
data: {
|
|
836
|
-
reason: 'Consult Transfer Failed',
|
|
837
|
-
},
|
|
838
|
-
},
|
|
839
|
-
};
|
|
930
|
+
const error = {details: (global as any).makeFailure('Consult Transfer Failed')};
|
|
840
931
|
contactMock.consultTransfer.mockImplementation(() => {
|
|
841
932
|
throw error;
|
|
842
933
|
});
|
|
@@ -849,16 +940,24 @@ describe('Task', () => {
|
|
|
849
940
|
await expect(task.consultTransfer(consultTransferPayload)).rejects.toThrow(
|
|
850
941
|
error.details.data.reason
|
|
851
942
|
);
|
|
852
|
-
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
|
+
};
|
|
853
951
|
expect(mockMetricsManager.trackEvent).toHaveBeenNthCalledWith(
|
|
854
952
|
2,
|
|
855
953
|
METRIC_EVENT_NAMES.TASK_TRANSFER_FAILED,
|
|
856
954
|
{
|
|
857
955
|
taskId: taskDataMock.interactionId,
|
|
858
|
-
destination:
|
|
859
|
-
destinationType:
|
|
956
|
+
destination: taskDataMock.destAgentId,
|
|
957
|
+
destinationType: CONSULT_TRANSFER_DESTINATION_TYPE.AGENT,
|
|
860
958
|
isConsultTransfer: true,
|
|
861
959
|
error: error.toString(),
|
|
960
|
+
...expectedTaskErrorFieldsConsultTransfer,
|
|
862
961
|
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details),
|
|
863
962
|
},
|
|
864
963
|
['operational', 'behavioral', 'business']
|
|
@@ -926,14 +1025,7 @@ describe('Task', () => {
|
|
|
926
1025
|
});
|
|
927
1026
|
|
|
928
1027
|
it('should handle errors in transfer method', async () => {
|
|
929
|
-
const error = {
|
|
930
|
-
details: {
|
|
931
|
-
trackingId: '1234',
|
|
932
|
-
data: {
|
|
933
|
-
reason: 'Consult Transfer Failed',
|
|
934
|
-
},
|
|
935
|
-
},
|
|
936
|
-
};
|
|
1028
|
+
const error = {details: (global as any).makeFailure('Consult Transfer Failed')};
|
|
937
1029
|
contactMock.blindTransfer.mockImplementation(() => {
|
|
938
1030
|
throw error;
|
|
939
1031
|
});
|
|
@@ -944,7 +1036,14 @@ describe('Task', () => {
|
|
|
944
1036
|
};
|
|
945
1037
|
|
|
946
1038
|
await expect(task.transfer(blindTransferPayload)).rejects.toThrow(error.details.data.reason);
|
|
947
|
-
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
|
+
};
|
|
948
1047
|
expect(mockMetricsManager.trackEvent).toHaveBeenNthCalledWith(
|
|
949
1048
|
1,
|
|
950
1049
|
METRIC_EVENT_NAMES.TASK_TRANSFER_FAILED,
|
|
@@ -954,6 +1053,7 @@ describe('Task', () => {
|
|
|
954
1053
|
destinationType: blindTransferPayload.destinationType,
|
|
955
1054
|
isConsultTransfer: false,
|
|
956
1055
|
error: error.toString(),
|
|
1056
|
+
...expectedTaskErrorFieldsTransfer,
|
|
957
1057
|
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details),
|
|
958
1058
|
},
|
|
959
1059
|
['operational', 'behavioral', 'business']
|
|
@@ -990,25 +1090,26 @@ describe('Task', () => {
|
|
|
990
1090
|
});
|
|
991
1091
|
|
|
992
1092
|
it('should handle errors in end method', async () => {
|
|
993
|
-
const error = {
|
|
994
|
-
details: {
|
|
995
|
-
trackingId: '1234',
|
|
996
|
-
data: {
|
|
997
|
-
reason: 'End Failed',
|
|
998
|
-
},
|
|
999
|
-
},
|
|
1000
|
-
};
|
|
1093
|
+
const error = {details: (global as any).makeFailure('End Failed')};
|
|
1001
1094
|
contactMock.end.mockImplementation(() => {
|
|
1002
1095
|
throw error;
|
|
1003
1096
|
});
|
|
1004
1097
|
|
|
1005
1098
|
await expect(task.end()).rejects.toThrow(error.details.data.reason);
|
|
1006
|
-
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
|
+
};
|
|
1007
1107
|
expect(mockMetricsManager.trackEvent).toHaveBeenNthCalledWith(
|
|
1008
1108
|
1,
|
|
1009
1109
|
METRIC_EVENT_NAMES.TASK_END_FAILED,
|
|
1010
1110
|
{
|
|
1011
1111
|
taskId: taskDataMock.interactionId,
|
|
1112
|
+
...expectedTaskErrorFieldsEnd,
|
|
1012
1113
|
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details),
|
|
1013
1114
|
},
|
|
1014
1115
|
['operational', 'behavioral', 'business']
|
|
@@ -1041,14 +1142,7 @@ describe('Task', () => {
|
|
|
1041
1142
|
});
|
|
1042
1143
|
|
|
1043
1144
|
it('should handle errors in wrapup method', async () => {
|
|
1044
|
-
const error = {
|
|
1045
|
-
details: {
|
|
1046
|
-
trackingId: '1234',
|
|
1047
|
-
data: {
|
|
1048
|
-
reason: 'Wrapup Failed',
|
|
1049
|
-
},
|
|
1050
|
-
},
|
|
1051
|
-
};
|
|
1145
|
+
const error = {details: (global as any).makeFailure('Wrapup Failed')};
|
|
1052
1146
|
contactMock.wrapup.mockImplementation(() => {
|
|
1053
1147
|
throw error;
|
|
1054
1148
|
});
|
|
@@ -1059,7 +1153,14 @@ describe('Task', () => {
|
|
|
1059
1153
|
};
|
|
1060
1154
|
|
|
1061
1155
|
await expect(task.wrapup(wrapupPayload)).rejects.toThrow(error.details.data.reason);
|
|
1062
|
-
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
|
+
};
|
|
1063
1164
|
expect(mockMetricsManager.trackEvent).toHaveBeenNthCalledWith(
|
|
1064
1165
|
1,
|
|
1065
1166
|
METRIC_EVENT_NAMES.TASK_WRAPUP_FAILED,
|
|
@@ -1067,6 +1168,7 @@ describe('Task', () => {
|
|
|
1067
1168
|
taskId: taskDataMock.interactionId,
|
|
1068
1169
|
wrapUpCode: wrapupPayload.auxCodeId,
|
|
1069
1170
|
wrapUpReason: wrapupPayload.wrapUpReason,
|
|
1171
|
+
...expectedTaskErrorFieldsWrapup,
|
|
1070
1172
|
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details),
|
|
1071
1173
|
},
|
|
1072
1174
|
['operational', 'behavioral', 'business']
|
|
@@ -1124,26 +1226,27 @@ describe('Task', () => {
|
|
|
1124
1226
|
});
|
|
1125
1227
|
|
|
1126
1228
|
it('should handle errors in pauseRecording method', async () => {
|
|
1127
|
-
const error = {
|
|
1128
|
-
details: {
|
|
1129
|
-
trackingId: '1234',
|
|
1130
|
-
data: {
|
|
1131
|
-
reason: 'Pause Recording Failed',
|
|
1132
|
-
},
|
|
1133
|
-
},
|
|
1134
|
-
};
|
|
1229
|
+
const error = {details: (global as any).makeFailure('Pause Recording Failed')};
|
|
1135
1230
|
contactMock.pauseRecording.mockImplementation(() => {
|
|
1136
1231
|
throw error;
|
|
1137
1232
|
});
|
|
1138
1233
|
|
|
1139
1234
|
await expect(task.pauseRecording()).rejects.toThrow(error.details.data.reason);
|
|
1140
|
-
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
|
+
};
|
|
1141
1243
|
expect(mockMetricsManager.trackEvent).toHaveBeenNthCalledWith(
|
|
1142
1244
|
1,
|
|
1143
1245
|
METRIC_EVENT_NAMES.TASK_PAUSE_RECORDING_FAILED,
|
|
1144
1246
|
{
|
|
1145
1247
|
taskId: taskDataMock.interactionId,
|
|
1146
1248
|
error: error.toString(),
|
|
1249
|
+
...expectedTaskErrorFieldsPause,
|
|
1147
1250
|
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details),
|
|
1148
1251
|
},
|
|
1149
1252
|
['operational', 'behavioral', 'business']
|
|
@@ -1204,14 +1307,7 @@ describe('Task', () => {
|
|
|
1204
1307
|
});
|
|
1205
1308
|
|
|
1206
1309
|
it('should handle errors in resumeRecording method', async () => {
|
|
1207
|
-
const error = {
|
|
1208
|
-
details: {
|
|
1209
|
-
trackingId: '1234',
|
|
1210
|
-
data: {
|
|
1211
|
-
reason: 'Resume Recording Failed',
|
|
1212
|
-
},
|
|
1213
|
-
},
|
|
1214
|
-
};
|
|
1310
|
+
const error = {details: (global as any).makeFailure('Resume Recording Failed')};
|
|
1215
1311
|
contactMock.resumeRecording.mockImplementation(() => {
|
|
1216
1312
|
throw error;
|
|
1217
1313
|
});
|
|
@@ -1221,13 +1317,21 @@ describe('Task', () => {
|
|
|
1221
1317
|
};
|
|
1222
1318
|
|
|
1223
1319
|
await expect(task.resumeRecording(resumePayload)).rejects.toThrow(error.details.data.reason);
|
|
1224
|
-
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
|
+
};
|
|
1225
1328
|
expect(mockMetricsManager.trackEvent).toHaveBeenNthCalledWith(
|
|
1226
1329
|
1,
|
|
1227
1330
|
METRIC_EVENT_NAMES.TASK_RESUME_RECORDING_FAILED,
|
|
1228
1331
|
{
|
|
1229
1332
|
taskId: taskDataMock.interactionId,
|
|
1230
1333
|
error: error.toString(),
|
|
1334
|
+
...expectedTaskErrorFieldsResumeRec,
|
|
1231
1335
|
...MetricsManager.getCommonTrackingFieldForAQMResponseFailed(error.details),
|
|
1232
1336
|
},
|
|
1233
1337
|
['operational', 'behavioral', 'business']
|
|
@@ -1267,7 +1371,7 @@ describe('Task', () => {
|
|
|
1267
1371
|
throw error;
|
|
1268
1372
|
});
|
|
1269
1373
|
await expect(task.toggleMute()).rejects.toThrow(new Error(error.details.data.reason));
|
|
1270
|
-
expect(
|
|
1374
|
+
expect(generateTaskErrorObjectSpy).toHaveBeenCalledWith(error, 'toggleMute', TASK_FILE);
|
|
1271
1375
|
expect(loggerInfoSpy).toHaveBeenCalledWith(`Toggling mute state`, {
|
|
1272
1376
|
module: TASK_FILE,
|
|
1273
1377
|
method: 'toggleMute',
|