@webex/contact-center 3.10.0-next.16 → 3.10.0-next.17
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/services/task/TaskManager.js +17 -8
- package/dist/services/task/TaskManager.js.map +1 -1
- package/dist/services/task/types.js +1 -0
- package/dist/services/task/types.js.map +1 -1
- package/dist/types/services/task/types.d.ts +11 -0
- package/dist/webex.js +1 -1
- package/package.json +1 -1
- package/src/services/task/TaskManager.ts +21 -8
- package/src/services/task/types.ts +12 -0
- package/test/unit/spec/services/task/TaskManager.ts +89 -3
- package/umd/contact-center.min.js +2 -2
- package/umd/contact-center.min.js.map +1 -1
|
@@ -347,6 +347,18 @@ export enum TASK_EVENTS {
|
|
|
347
347
|
*/
|
|
348
348
|
TASK_REJECT = 'task:rejected',
|
|
349
349
|
|
|
350
|
+
/**
|
|
351
|
+
* Triggered when an outdial call fails
|
|
352
|
+
* @example
|
|
353
|
+
* ```typescript
|
|
354
|
+
* task.on(TASK_EVENTS.TASK_OUTDIAL_FAILED, (reason: string) => {
|
|
355
|
+
* console.log('Outdial failed:', reason);
|
|
356
|
+
* // Handle outdial failure
|
|
357
|
+
* });
|
|
358
|
+
* ```
|
|
359
|
+
*/
|
|
360
|
+
TASK_OUTDIAL_FAILED = 'task:outdialFailed',
|
|
361
|
+
|
|
350
362
|
/**
|
|
351
363
|
* Triggered when a task is populated with data
|
|
352
364
|
* @example
|
|
@@ -673,14 +673,36 @@ describe('TaskManager', () => {
|
|
|
673
673
|
expect(taskUpdateTaskDataSpy).toHaveBeenCalledWith(payload.data);
|
|
674
674
|
});
|
|
675
675
|
|
|
676
|
-
it('should remove
|
|
676
|
+
it('should NOT remove OUTDIAL task from taskCollection on AGENT_OUTBOUND_FAILED when terminated (wrap-up flow)', () => {
|
|
677
|
+
const task = taskManager.getTask(taskId);
|
|
678
|
+
task.updateTaskData = jest.fn().mockImplementation((newData) => {
|
|
679
|
+
task.data = {
|
|
680
|
+
...task.data,
|
|
681
|
+
...newData,
|
|
682
|
+
interaction: {
|
|
683
|
+
...task.data.interaction,
|
|
684
|
+
...newData.interaction,
|
|
685
|
+
outboundType: 'OUTDIAL',
|
|
686
|
+
state: 'new',
|
|
687
|
+
isTerminated: true,
|
|
688
|
+
},
|
|
689
|
+
};
|
|
690
|
+
return task;
|
|
691
|
+
});
|
|
692
|
+
task.unregisterWebCallListeners = jest.fn();
|
|
693
|
+
const removeTaskSpy = jest.spyOn(taskManager, 'removeTaskFromCollection');
|
|
694
|
+
|
|
677
695
|
const payload = {
|
|
678
696
|
data: {
|
|
679
697
|
type: CC_EVENTS.AGENT_OUTBOUND_FAILED,
|
|
680
698
|
agentId: '723a8ffb-a26e-496d-b14a-ff44fb83b64f',
|
|
681
699
|
eventTime: 1733211616959,
|
|
682
700
|
eventType: 'RoutingMessage',
|
|
683
|
-
interaction: {
|
|
701
|
+
interaction: {
|
|
702
|
+
outboundType: 'OUTDIAL',
|
|
703
|
+
state: 'new',
|
|
704
|
+
isTerminated: true,
|
|
705
|
+
},
|
|
684
706
|
interactionId: taskId,
|
|
685
707
|
orgId: '6ecef209-9a34-4ed1-a07a-7ddd1dbe925a',
|
|
686
708
|
trackingId: '575c0ec2-618c-42af-a61c-53aeb0a221ee',
|
|
@@ -688,14 +710,78 @@ describe('TaskManager', () => {
|
|
|
688
710
|
destAgentId: 'ebeb893b-ba67-4f36-8418-95c7492b28c2',
|
|
689
711
|
owner: '723a8ffb-a26e-496d-b14a-ff44fb83b64f',
|
|
690
712
|
queueMgr: 'aqm',
|
|
713
|
+
reason: 'CUSTOMER_BUSY',
|
|
714
|
+
reasonCode: 1022,
|
|
691
715
|
},
|
|
692
716
|
};
|
|
693
717
|
|
|
694
|
-
|
|
718
|
+
webSocketManagerMock.emit('message', JSON.stringify(payload));
|
|
719
|
+
|
|
720
|
+
expect(taskManager.getTask(taskId)).toBeDefined();
|
|
721
|
+
expect(removeTaskSpy).not.toHaveBeenCalled();
|
|
722
|
+
});
|
|
723
|
+
|
|
724
|
+
it('should emit TASK_OUTDIAL_FAILED event on AGENT_OUTBOUND_FAILED', () => {
|
|
725
|
+
const task = taskManager.getTask(taskId);
|
|
726
|
+
task.updateTaskData = jest.fn().mockReturnValue(task);
|
|
727
|
+
const taskEmitSpy = jest.spyOn(task, 'emit');
|
|
728
|
+
const payload = {
|
|
729
|
+
data: {
|
|
730
|
+
type: CC_EVENTS.AGENT_OUTBOUND_FAILED,
|
|
731
|
+
interactionId: taskId,
|
|
732
|
+
reason: 'CUSTOMER_BUSY',
|
|
733
|
+
},
|
|
734
|
+
};
|
|
735
|
+
webSocketManagerMock.emit('message', JSON.stringify(payload));
|
|
736
|
+
expect(taskEmitSpy).toHaveBeenCalledWith(TASK_EVENTS.TASK_OUTDIAL_FAILED, 'CUSTOMER_BUSY');
|
|
737
|
+
});
|
|
738
|
+
|
|
739
|
+
it('should remove OUTDIAL task from taskCollection on AGENT_CONTACT_ASSIGN_FAILED when NOT terminated (user-declined)', () => {
|
|
740
|
+
const task = taskManager.getTask(taskId);
|
|
741
|
+
task.updateTaskData = jest.fn().mockImplementation((newData) => {
|
|
742
|
+
task.data = {
|
|
743
|
+
...task.data,
|
|
744
|
+
...newData,
|
|
745
|
+
interaction: {
|
|
746
|
+
...task.data.interaction,
|
|
747
|
+
...newData.interaction,
|
|
748
|
+
outboundType: 'OUTDIAL',
|
|
749
|
+
state: 'new',
|
|
750
|
+
isTerminated: false,
|
|
751
|
+
},
|
|
752
|
+
};
|
|
753
|
+
return task;
|
|
754
|
+
});
|
|
755
|
+
task.unregisterWebCallListeners = jest.fn();
|
|
756
|
+
const removeTaskSpy = jest.spyOn(taskManager, 'removeTaskFromCollection');
|
|
757
|
+
|
|
758
|
+
const payload = {
|
|
759
|
+
data: {
|
|
760
|
+
type: CC_EVENTS.AGENT_CONTACT_ASSIGN_FAILED,
|
|
761
|
+
agentId: '723a8ffb-a26e-496d-b14a-ff44fb83b64f',
|
|
762
|
+
eventTime: 1733211616959,
|
|
763
|
+
eventType: 'RoutingMessage',
|
|
764
|
+
interaction: {
|
|
765
|
+
outboundType: 'OUTDIAL',
|
|
766
|
+
state: 'new',
|
|
767
|
+
isTerminated: false,
|
|
768
|
+
},
|
|
769
|
+
interactionId: taskId,
|
|
770
|
+
orgId: '6ecef209-9a34-4ed1-a07a-7ddd1dbe925a',
|
|
771
|
+
trackingId: '575c0ec2-618c-42af-a61c-53aeb0a221ee',
|
|
772
|
+
mediaResourceId: '0ae913a4-c857-4705-8d49-76dd3dde75e4',
|
|
773
|
+
destAgentId: 'ebeb893b-ba67-4f36-8418-95c7492b28c2',
|
|
774
|
+
owner: '723a8ffb-a26e-496d-b14a-ff44fb83b64f',
|
|
775
|
+
queueMgr: 'aqm',
|
|
776
|
+
reason: 'USER_DECLINED',
|
|
777
|
+
reasonCode: 156,
|
|
778
|
+
},
|
|
779
|
+
};
|
|
695
780
|
|
|
696
781
|
webSocketManagerMock.emit('message', JSON.stringify(payload));
|
|
697
782
|
|
|
698
783
|
expect(taskManager.getTask(taskId)).toBeUndefined();
|
|
784
|
+
expect(removeTaskSpy).toHaveBeenCalled();
|
|
699
785
|
});
|
|
700
786
|
|
|
701
787
|
it('handle AGENT_OFFER_CONSULT event', () => {
|