@webex/contact-center 3.12.0 → 3.13.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/.repo-context.json +704 -0
- package/.sdd/manifest.json +1613 -0
- package/AGENTS.md +969 -0
- package/dist/cc.js +1102 -47
- package/dist/cc.js.map +1 -1
- package/dist/config.js +13 -0
- package/dist/config.js.map +1 -1
- package/dist/constants.js +46 -3
- package/dist/constants.js.map +1 -1
- package/dist/index.js +86 -17
- package/dist/index.js.map +1 -1
- package/dist/metrics/MetricsManager.js +16 -0
- package/dist/metrics/MetricsManager.js.map +1 -1
- package/dist/metrics/behavioral-events.js +211 -0
- package/dist/metrics/behavioral-events.js.map +1 -1
- package/dist/metrics/constants.js +58 -4
- package/dist/metrics/constants.js.map +1 -1
- package/dist/services/AddressBook.js +18 -15
- package/dist/services/AddressBook.js.map +1 -1
- package/dist/services/AnswerCallOnWebexService.js +202 -0
- package/dist/services/AnswerCallOnWebexService.js.map +1 -0
- package/dist/services/ApiAiAssistant.js +369 -14
- package/dist/services/ApiAiAssistant.js.map +1 -1
- package/dist/services/EntryPoint.js +46 -68
- package/dist/services/EntryPoint.js.map +1 -1
- package/dist/services/Queue.js +27 -22
- package/dist/services/Queue.js.map +1 -1
- package/dist/services/UserPreference.js +427 -0
- package/dist/services/UserPreference.js.map +1 -0
- package/dist/services/WebCallingService.js +287 -37
- package/dist/services/WebCallingService.js.map +1 -1
- package/dist/services/WebexCrossClientService.js +225 -0
- package/dist/services/WebexCrossClientService.js.map +1 -0
- package/dist/services/WxAppTelephonyMercurySync.js +111 -0
- package/dist/services/WxAppTelephonyMercurySync.js.map +1 -0
- package/dist/services/config/Util.js +48 -48
- package/dist/services/config/Util.js.map +1 -1
- package/dist/services/config/constants.js +57 -79
- package/dist/services/config/constants.js.map +1 -1
- package/dist/services/config/index.js +100 -226
- package/dist/services/config/index.js.map +1 -1
- package/dist/services/config/types.js +100 -40
- package/dist/services/config/types.js.map +1 -1
- package/dist/services/constants.js +19 -1
- package/dist/services/constants.js.map +1 -1
- package/dist/services/core/Err.js.map +1 -1
- package/dist/services/core/Utils.js +131 -32
- package/dist/services/core/Utils.js.map +1 -1
- package/dist/services/core/WebexRequest.js +6 -2
- package/dist/services/core/WebexRequest.js.map +1 -1
- package/dist/services/core/aqm-reqs.js +17 -11
- package/dist/services/core/aqm-reqs.js.map +1 -1
- package/dist/services/core/constants.js +9 -1
- package/dist/services/core/constants.js.map +1 -1
- package/dist/services/core/types.js.map +1 -1
- package/dist/services/core/websocket/WebSocketManager.js +26 -6
- package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
- package/dist/services/core/websocket/connection-service.js +3 -1
- package/dist/services/core/websocket/connection-service.js.map +1 -1
- package/dist/services/core/websocket/types.js.map +1 -1
- package/dist/services/index.js +6 -0
- package/dist/services/index.js.map +1 -1
- package/dist/services/task/Task.js +955 -0
- package/dist/services/task/Task.js.map +1 -0
- package/dist/services/task/TaskFactory.js +50 -0
- package/dist/services/task/TaskFactory.js.map +1 -0
- package/dist/services/task/TaskManager.js +1275 -504
- package/dist/services/task/TaskManager.js.map +1 -1
- package/dist/services/task/TaskUtils.js +221 -27
- package/dist/services/task/TaskUtils.js.map +1 -1
- package/dist/services/task/WebexCallingUtils.js +70 -0
- package/dist/services/task/WebexCallingUtils.js.map +1 -0
- package/dist/services/task/constants.js +22 -2
- package/dist/services/task/constants.js.map +1 -1
- package/dist/services/task/contact.js +29 -0
- package/dist/services/task/contact.js.map +1 -1
- package/dist/services/task/dialer.js +78 -0
- package/dist/services/task/dialer.js.map +1 -1
- package/dist/services/task/digital/Digital.js +78 -0
- package/dist/services/task/digital/Digital.js.map +1 -0
- package/dist/services/task/state-machine/TaskStateMachine.js +982 -0
- package/dist/services/task/state-machine/TaskStateMachine.js.map +1 -0
- package/dist/services/task/state-machine/actions.js +572 -0
- package/dist/services/task/state-machine/actions.js.map +1 -0
- package/dist/services/task/state-machine/constants.js +161 -0
- package/dist/services/task/state-machine/constants.js.map +1 -0
- package/dist/services/task/state-machine/guards.js +379 -0
- package/dist/services/task/state-machine/guards.js.map +1 -0
- package/dist/services/task/state-machine/index.js +53 -0
- package/dist/services/task/state-machine/index.js.map +1 -0
- package/dist/services/task/state-machine/types.js +54 -0
- package/dist/services/task/state-machine/types.js.map +1 -0
- package/dist/services/task/state-machine/uiControlsComputer.js +703 -0
- package/dist/services/task/state-machine/uiControlsComputer.js.map +1 -0
- package/dist/services/task/taskDataNormalizer.js +99 -0
- package/dist/services/task/taskDataNormalizer.js.map +1 -0
- package/dist/services/task/types.js +259 -5
- package/dist/services/task/types.js.map +1 -1
- package/dist/services/task/voice/Voice.js +1504 -0
- package/dist/services/task/voice/Voice.js.map +1 -0
- package/dist/services/task/voice/WebRTC.js +152 -0
- package/dist/services/task/voice/WebRTC.js.map +1 -0
- package/dist/services/task/voice/wxAppOfferObservability.js +145 -0
- package/dist/services/task/voice/wxAppOfferObservability.js.map +1 -0
- package/dist/services/task/voice/wxAppVoiceMethods.js +395 -0
- package/dist/services/task/voice/wxAppVoiceMethods.js.map +1 -0
- package/dist/services/wxAppDiagnosticLogging.js +159 -0
- package/dist/services/wxAppDiagnosticLogging.js.map +1 -0
- package/dist/services/wxAppTelephonyUtils.js +19 -0
- package/dist/services/wxAppTelephonyUtils.js.map +1 -0
- package/dist/types/cc.d.ts +222 -10
- package/dist/types/config.d.ts +13 -0
- package/dist/types/constants.d.ts +40 -1
- package/dist/types/index.d.ts +58 -22
- package/dist/types/metrics/MetricsManager.d.ts +6 -0
- package/dist/types/metrics/constants.d.ts +52 -1
- package/dist/types/services/AddressBook.d.ts +2 -1
- package/dist/types/services/AnswerCallOnWebexService.d.ts +38 -0
- package/dist/types/services/ApiAiAssistant.d.ts +67 -5
- package/dist/types/services/EntryPoint.d.ts +7 -5
- package/dist/types/services/Queue.d.ts +5 -3
- package/dist/types/services/UserPreference.d.ts +118 -0
- package/dist/types/services/WebexCrossClientService.d.ts +32 -0
- package/dist/types/services/WxAppTelephonyMercurySync.d.ts +28 -0
- package/dist/types/services/config/Util.d.ts +4 -8
- package/dist/types/services/config/constants.d.ts +49 -76
- package/dist/types/services/config/index.d.ts +16 -64
- package/dist/types/services/config/types.d.ts +252 -114
- package/dist/types/services/constants.d.ts +16 -0
- package/dist/types/services/core/Err.d.ts +6 -0
- package/dist/types/services/core/Utils.d.ts +43 -13
- package/dist/types/services/core/WebexRequest.d.ts +1 -0
- package/dist/types/services/core/constants.d.ts +7 -0
- package/dist/types/services/core/types.d.ts +2 -0
- package/dist/types/services/core/websocket/WebSocketManager.d.ts +2 -0
- package/dist/types/services/core/websocket/types.d.ts +1 -1
- package/dist/types/services/index.d.ts +2 -0
- package/dist/types/services/task/Task.d.ts +186 -0
- package/dist/types/services/task/TaskFactory.d.ts +14 -0
- package/dist/types/services/task/TaskUtils.d.ts +54 -2
- package/dist/types/services/task/WebexCallingUtils.d.ts +11 -0
- package/dist/types/services/task/constants.d.ts +20 -0
- package/dist/types/services/task/contact.d.ts +4 -0
- package/dist/types/services/task/dialer.d.ts +30 -0
- package/dist/types/services/task/digital/Digital.d.ts +23 -0
- package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +1442 -0
- package/dist/types/services/task/state-machine/actions.d.ts +10 -0
- package/dist/types/services/task/state-machine/constants.d.ts +107 -0
- package/dist/types/services/task/state-machine/guards.d.ts +103 -0
- package/dist/types/services/task/state-machine/index.d.ts +13 -0
- package/dist/types/services/task/state-machine/types.d.ts +277 -0
- package/dist/types/services/task/state-machine/uiControlsComputer.d.ts +9 -0
- package/dist/types/services/task/taskDataNormalizer.d.ts +10 -0
- package/dist/types/services/task/types.d.ts +790 -66
- package/dist/types/services/task/voice/Voice.d.ts +241 -0
- package/dist/types/services/task/voice/WebRTC.d.ts +54 -0
- package/dist/types/services/task/voice/wxAppOfferObservability.d.ts +39 -0
- package/dist/types/services/task/voice/wxAppVoiceMethods.d.ts +68 -0
- package/dist/types/services/wxAppDiagnosticLogging.d.ts +63 -0
- package/dist/types/services/wxAppTelephonyUtils.d.ts +5 -0
- package/dist/types/types.d.ts +258 -11
- package/dist/types/utils/PageCache.d.ts +20 -3
- package/dist/types/webex.d.ts +1 -0
- package/dist/types.js +204 -6
- package/dist/types.js.map +1 -1
- package/dist/utils/PageCache.js +19 -5
- package/dist/utils/PageCache.js.map +1 -1
- package/dist/webex.js +22 -2
- package/dist/webex.js.map +1 -1
- package/docs/adr/0001-spec-source-policy.md +97 -0
- package/docs/adr/0002-consult-transfer-list-policy.md +345 -0
- package/docs/adr/0003-repo-standards-migration.md +104 -0
- package/docs/adr/index.md +35 -0
- package/docs/architecture.md +460 -0
- package/docs/getting-started.md +142 -0
- package/docs/index.md +53 -0
- package/docs/specs/README.md +98 -0
- package/package.json +17 -12
- package/schemas/repo-context.schema.json +796 -0
- package/src/cc.ts +1439 -105
- package/src/config.ts +13 -0
- package/src/constants.ts +53 -1
- package/src/docs/README.md +727 -0
- package/src/index.ts +72 -16
- package/src/metrics/MetricsManager.ts +16 -0
- package/src/metrics/behavioral-events.ts +218 -0
- package/src/metrics/constants.ts +63 -4
- package/src/metrics/docs/README.md +710 -0
- package/src/services/AddressBook.ts +17 -6
- package/src/services/AnswerCallOnWebexService.ts +239 -0
- package/src/services/ApiAiAssistant.ts +494 -15
- package/src/services/EntryPoint.ts +59 -60
- package/src/services/Queue.ts +29 -12
- package/src/services/UserPreference.ts +509 -0
- package/src/services/WebCallingService.ts +362 -40
- package/src/services/WebexCrossClientService.ts +298 -0
- package/src/services/WxAppTelephonyMercurySync.ts +142 -0
- package/src/services/agent/docs/README.md +673 -0
- package/src/services/config/Util.ts +54 -84
- package/src/services/config/constants.ts +64 -86
- package/src/services/config/docs/README.md +530 -0
- package/src/services/config/index.ts +116 -277
- package/src/services/config/types.ts +238 -125
- package/src/services/constants.ts +18 -0
- package/src/services/core/Err.ts +3 -0
- package/src/services/core/Utils.ts +151 -37
- package/src/services/core/WebexRequest.ts +3 -1
- package/src/services/core/aqm-reqs.ts +18 -12
- package/src/services/core/constants.ts +8 -0
- package/src/services/core/docs/README.md +993 -0
- package/src/services/core/types.ts +33 -1
- package/src/services/core/websocket/WebSocketManager.ts +37 -8
- package/src/services/core/websocket/connection-service.ts +5 -1
- package/src/services/core/websocket/types.ts +1 -1
- package/src/services/docs/README.md +765 -0
- package/src/services/index.ts +4 -0
- package/src/services/task/Task.ts +1211 -0
- package/src/services/task/TaskFactory.ts +82 -0
- package/src/services/task/TaskManager.ts +1551 -584
- package/src/services/task/TaskUtils.ts +316 -25
- package/src/services/task/WebexCallingUtils.ts +136 -0
- package/src/services/task/constants.ts +21 -0
- package/src/services/task/contact.ts +30 -0
- package/src/services/task/dialer.ts +80 -0
- package/src/services/task/digital/Digital.ts +102 -0
- package/src/services/task/docs/README.md +1569 -0
- package/src/services/task/state-machine/TaskStateMachine.ts +1320 -0
- package/src/services/task/state-machine/actions.ts +741 -0
- package/src/services/task/state-machine/constants.ts +172 -0
- package/src/services/task/state-machine/docs/README.md +1388 -0
- package/src/services/task/state-machine/guards.ts +442 -0
- package/src/services/task/state-machine/index.ts +28 -0
- package/src/services/task/state-machine/types.ts +258 -0
- package/src/services/task/state-machine/uiControlsComputer.ts +1135 -0
- package/src/services/task/taskDataNormalizer.ts +137 -0
- package/src/services/task/types.ts +974 -70
- package/src/services/task/voice/Voice.ts +1878 -0
- package/src/services/task/voice/WebRTC.ts +194 -0
- package/src/services/task/voice/wxAppOfferObservability.ts +204 -0
- package/src/services/task/voice/wxAppVoiceMethods.ts +575 -0
- package/src/services/wxAppDiagnosticLogging.ts +286 -0
- package/src/services/wxAppTelephonyUtils.ts +14 -0
- package/src/types.ts +323 -13
- package/src/utils/AGENTS.md +291 -0
- package/src/utils/PageCache.ts +38 -5
- package/src/utils/docs/README.md +413 -0
- package/src/webex.js +10 -0
- package/test/unit/fixtures/aiSummaryTestUtils.ts +40 -0
- package/test/unit/spec/cc.ts +4046 -181
- package/test/unit/spec/index.ts +891 -0
- package/test/unit/spec/logger-proxy.ts +70 -0
- package/test/unit/spec/metrics/MetricsManager.ts +25 -0
- package/test/unit/spec/metrics/behavioral-events.ts +60 -0
- package/test/unit/spec/services/AddressBook.ts +37 -6
- package/test/unit/spec/services/AnswerCallOnWebexService.ts +264 -0
- package/test/unit/spec/services/ApiAiAssistant.ts +442 -23
- package/test/unit/spec/services/EntryPoint.ts +87 -40
- package/test/unit/spec/services/Queue.ts +123 -12
- package/test/unit/spec/services/UserPreference.ts +401 -0
- package/test/unit/spec/services/WebCallingService.ts +484 -49
- package/test/unit/spec/services/WebexCrossClientService.ts +509 -0
- package/test/unit/spec/services/WxAppTelephonyMercurySync.ts +136 -0
- package/test/unit/spec/services/config/Util.ts +501 -0
- package/test/unit/spec/services/config/index.ts +318 -548
- package/test/unit/spec/services/core/Utils.ts +447 -8
- package/test/unit/spec/services/core/WebexRequest.ts +8 -7
- package/test/unit/spec/services/core/aqm-reqs.ts +142 -1
- package/test/unit/spec/services/core/websocket/WebSocketManager.ts +132 -56
- package/test/unit/spec/services/core/websocket/connection-service.ts +3 -1
- package/test/unit/spec/services/task/AutoWrapup.ts +63 -0
- package/test/unit/spec/services/task/Task.ts +2723 -0
- package/test/unit/spec/services/task/TaskFactory.ts +116 -0
- package/test/unit/spec/services/task/TaskManager.ts +4800 -1586
- package/test/unit/spec/services/task/TaskUtils.ts +307 -0
- package/test/unit/spec/services/task/WebexCallingUtils.ts +153 -0
- package/test/unit/spec/services/task/contact.ts +33 -0
- package/test/unit/spec/services/task/dialer.ts +190 -0
- package/test/unit/spec/services/task/digital/Digital.ts +105 -0
- package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +4060 -0
- package/test/unit/spec/services/task/state-machine/guards.ts +839 -0
- package/test/unit/spec/services/task/state-machine/types.ts +18 -0
- package/test/unit/spec/services/task/state-machine/uiControlsComputer.ts +3101 -0
- package/test/unit/spec/services/task/taskTestUtils.ts +87 -0
- package/test/unit/spec/services/task/voice/Voice.ts +2355 -0
- package/test/unit/spec/services/task/voice/WebRTC.ts +235 -0
- package/test/unit/spec/services/task/voice/wxAppOfferObservability.ts +361 -0
- package/test/unit/spec/services/task/voice/wxAppVoiceMethods.ts +719 -0
- package/test/unit/spec/services/wxAppDiagnosticLogging.ts +179 -0
- package/test/unit/spec/wellnessSampleUtils.ts +288 -0
- package/typedoc.md +1 -1
- package/umd/contact-center.min.js +2 -2
- package/umd/contact-center.min.js.map +1 -1
- package/dist/services/task/index.js +0 -1525
- package/dist/services/task/index.js.map +0 -1
- package/dist/types/services/task/index.d.ts +0 -650
- package/src/services/task/index.ts +0 -1801
- package/test/unit/spec/services/task/index.ts +0 -2184
|
@@ -8,9 +8,20 @@ import {
|
|
|
8
8
|
isDigitalOutbound,
|
|
9
9
|
hasAgentInitiatedOutdial,
|
|
10
10
|
shouldAutoAnswerTask,
|
|
11
|
+
getIsCustomerInCall,
|
|
12
|
+
getConferenceParticipantsCount,
|
|
13
|
+
isSecondaryAgent,
|
|
14
|
+
isSecondaryEpDnAgent,
|
|
15
|
+
getConsultMediaResourceId,
|
|
16
|
+
getIsConsultInProgressForConferenceControls,
|
|
17
|
+
getIsConsultedAgentForControls,
|
|
18
|
+
getServerHoldStateForControls,
|
|
19
|
+
isCampaignPreviewTask,
|
|
20
|
+
isCampaignPreviewReservation,
|
|
11
21
|
} from '../../../../../src/services/task/TaskUtils';
|
|
12
22
|
import {ITask, Interaction, TaskData} from '../../../../../src/services/task/types';
|
|
13
23
|
import {LoginOption} from '../../../../../src/types';
|
|
24
|
+
import {CC_EVENTS} from '../../../../../src/services/config/types';
|
|
14
25
|
|
|
15
26
|
describe('TaskUtils', () => {
|
|
16
27
|
let mockTask: ITask;
|
|
@@ -41,6 +52,73 @@ describe('TaskUtils', () => {
|
|
|
41
52
|
} as any;
|
|
42
53
|
});
|
|
43
54
|
|
|
55
|
+
describe('state-control helper branches', () => {
|
|
56
|
+
it('should derive consulted-agent and hold states from task context', () => {
|
|
57
|
+
expect(
|
|
58
|
+
getIsConsultedAgentForControls({isConsulted: true} as TaskData, {} as any, false)
|
|
59
|
+
).toBe(true);
|
|
60
|
+
expect(
|
|
61
|
+
getIsConsultedAgentForControls(
|
|
62
|
+
{} as TaskData,
|
|
63
|
+
{consultInitiator: false} as any,
|
|
64
|
+
true
|
|
65
|
+
)
|
|
66
|
+
).toBe(true);
|
|
67
|
+
expect(
|
|
68
|
+
getIsConsultedAgentForControls(
|
|
69
|
+
{} as TaskData,
|
|
70
|
+
{consultInitiator: true} as any,
|
|
71
|
+
true
|
|
72
|
+
)
|
|
73
|
+
).toBe(false);
|
|
74
|
+
|
|
75
|
+
const taskData = {
|
|
76
|
+
interaction: {
|
|
77
|
+
media: {
|
|
78
|
+
main: {isHold: true},
|
|
79
|
+
fallback: {isHold: false},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
mediaResourceId: 'fallback',
|
|
83
|
+
} as TaskData;
|
|
84
|
+
|
|
85
|
+
expect(getServerHoldStateForControls({taskData} as any, 'main')).toBe(true);
|
|
86
|
+
expect(getServerHoldStateForControls({taskData} as any)).toBe(false);
|
|
87
|
+
expect(getServerHoldStateForControls({} as any)).toBeUndefined();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('should detect campaign preview tasks and reservations', () => {
|
|
91
|
+
expect(
|
|
92
|
+
isCampaignPreviewTask({
|
|
93
|
+
interaction: {
|
|
94
|
+
outboundType: 'STANDARD_PREVIEW_CAMPAIGN',
|
|
95
|
+
callProcessingDetails: {},
|
|
96
|
+
},
|
|
97
|
+
} as TaskData)
|
|
98
|
+
).toBe(true);
|
|
99
|
+
expect(
|
|
100
|
+
isCampaignPreviewTask({
|
|
101
|
+
interaction: {
|
|
102
|
+
outboundType: 'OUTDIAL',
|
|
103
|
+
callProcessingDetails: {campaignType: 'preview_standard'},
|
|
104
|
+
},
|
|
105
|
+
} as unknown as TaskData)
|
|
106
|
+
).toBe(true);
|
|
107
|
+
expect(isCampaignPreviewTask({interaction: {callProcessingDetails: {}}} as TaskData)).toBe(
|
|
108
|
+
false
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
expect(
|
|
112
|
+
isCampaignPreviewReservation({
|
|
113
|
+
data: {type: CC_EVENTS.AGENT_OFFER_CAMPAIGN_RESERVATION},
|
|
114
|
+
} as ITask)
|
|
115
|
+
).toBe(true);
|
|
116
|
+
expect(isCampaignPreviewReservation({data: {type: CC_EVENTS.AGENT_CONTACT}} as ITask)).toBe(
|
|
117
|
+
false
|
|
118
|
+
);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
44
122
|
describe('isPrimary', () => {
|
|
45
123
|
it('should return true when agent is the owner', () => {
|
|
46
124
|
expect(isPrimary(mockTask, mockAgentId)).toBe(true);
|
|
@@ -430,4 +508,233 @@ describe('TaskUtils', () => {
|
|
|
430
508
|
});
|
|
431
509
|
});
|
|
432
510
|
});
|
|
511
|
+
|
|
512
|
+
// Additional coverage for conference/consult utility functions
|
|
513
|
+
describe('Conference Utility Functions', () => {
|
|
514
|
+
const interactionId = 'interaction-123';
|
|
515
|
+
const createInteraction = (media: any = {}, participants: any = {}) =>
|
|
516
|
+
({interactionId, mainInteractionId: interactionId, media, participants}) as any;
|
|
517
|
+
|
|
518
|
+
it('getIsCustomerInCall returns true when customer active', () => {
|
|
519
|
+
const interaction = createInteraction(
|
|
520
|
+
{[interactionId]: {mType: 'mainCall', participants: ['c1']}},
|
|
521
|
+
{'c1': {pType: 'Customer', hasLeft: false}}
|
|
522
|
+
);
|
|
523
|
+
expect(getIsCustomerInCall(interaction, interactionId)).toBe(true);
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
it('getIsCustomerInCall returns false when participants map is missing', () => {
|
|
527
|
+
const interaction = createInteraction(
|
|
528
|
+
{[interactionId]: {mType: 'mainCall', participants: ['c1']}},
|
|
529
|
+
undefined
|
|
530
|
+
);
|
|
531
|
+
expect(getIsCustomerInCall(interaction, interactionId)).toBe(false);
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
it('getConferenceParticipantsCount counts active agents only', () => {
|
|
535
|
+
const interaction = createInteraction(
|
|
536
|
+
{[interactionId]: {mType: 'mainCall', participants: ['a1', 'a2', 'c1']}},
|
|
537
|
+
{'a1': {pType: 'Agent', hasLeft: false}, 'a2': {pType: 'Agent', hasLeft: false}, 'c1': {pType: 'Customer', hasLeft: false}}
|
|
538
|
+
);
|
|
539
|
+
expect(getConferenceParticipantsCount(interaction, interactionId)).toBe(2);
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
it('getConferenceParticipantsCount returns 0 when participants map is missing', () => {
|
|
543
|
+
const interaction = createInteraction(
|
|
544
|
+
{[interactionId]: {mType: 'mainCall', participants: ['a1', 'a2', 'c1']}},
|
|
545
|
+
undefined
|
|
546
|
+
);
|
|
547
|
+
expect(getConferenceParticipantsCount(interaction, interactionId)).toBe(0);
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
it('isSecondaryAgent returns true for consult with parentInteractionId', () => {
|
|
551
|
+
const interaction = createInteraction();
|
|
552
|
+
interaction.callProcessingDetails = {relationshipType: 'consult', parentInteractionId: 'parent-456'};
|
|
553
|
+
expect(isSecondaryAgent(interaction)).toBe(true);
|
|
554
|
+
});
|
|
555
|
+
|
|
556
|
+
it('isSecondaryEpDnAgent returns true for telephony secondary agent', () => {
|
|
557
|
+
const interaction = createInteraction();
|
|
558
|
+
interaction.mediaType = 'telephony';
|
|
559
|
+
interaction.callProcessingDetails = {relationshipType: 'consult', parentInteractionId: 'parent-456'};
|
|
560
|
+
expect(isSecondaryEpDnAgent(interaction)).toBe(true);
|
|
561
|
+
});
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
describe('getConsultMediaResourceId', () => {
|
|
565
|
+
it('returns consultMediaResourceId directly when provided', () => {
|
|
566
|
+
const result = getConsultMediaResourceId(undefined, 'consult-media-1', 'agent1');
|
|
567
|
+
expect(result).toBe('consult-media-1');
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
it('returns undefined when no interaction and no consultMediaResourceId', () => {
|
|
571
|
+
const result = getConsultMediaResourceId(undefined, undefined, 'agent1');
|
|
572
|
+
expect(result).toBeUndefined();
|
|
573
|
+
});
|
|
574
|
+
|
|
575
|
+
it('returns undefined when no agentId and no consultMediaResourceId', () => {
|
|
576
|
+
const interaction = {media: {}} as any;
|
|
577
|
+
const result = getConsultMediaResourceId(interaction, undefined, undefined);
|
|
578
|
+
expect(result).toBeUndefined();
|
|
579
|
+
});
|
|
580
|
+
|
|
581
|
+
it('finds consult media leg by mType and agent participation', () => {
|
|
582
|
+
const interaction = {
|
|
583
|
+
media: {
|
|
584
|
+
'main-media': {
|
|
585
|
+
mediaResourceId: 'main-media',
|
|
586
|
+
mType: 'mainCall',
|
|
587
|
+
participants: ['agent1', 'customer1'],
|
|
588
|
+
},
|
|
589
|
+
'consult-media': {
|
|
590
|
+
mediaResourceId: 'consult-media',
|
|
591
|
+
mType: 'consult',
|
|
592
|
+
participants: ['agent1', 'agent2'],
|
|
593
|
+
},
|
|
594
|
+
},
|
|
595
|
+
} as any;
|
|
596
|
+
const result = getConsultMediaResourceId(interaction, undefined, 'agent1');
|
|
597
|
+
expect(result).toBe('consult-media');
|
|
598
|
+
});
|
|
599
|
+
|
|
600
|
+
it('returns undefined when no consult media leg matches the agent', () => {
|
|
601
|
+
const interaction = {
|
|
602
|
+
media: {
|
|
603
|
+
'main-media': {
|
|
604
|
+
mediaResourceId: 'main-media',
|
|
605
|
+
mType: 'mainCall',
|
|
606
|
+
participants: ['agent1', 'customer1'],
|
|
607
|
+
},
|
|
608
|
+
'consult-media': {
|
|
609
|
+
mediaResourceId: 'consult-media',
|
|
610
|
+
mType: 'consult',
|
|
611
|
+
participants: ['agent2', 'agent3'],
|
|
612
|
+
},
|
|
613
|
+
},
|
|
614
|
+
} as any;
|
|
615
|
+
const result = getConsultMediaResourceId(interaction, undefined, 'agent1');
|
|
616
|
+
expect(result).toBeUndefined();
|
|
617
|
+
});
|
|
618
|
+
|
|
619
|
+
it('returns undefined when media has no consult type entries', () => {
|
|
620
|
+
const interaction = {
|
|
621
|
+
media: {
|
|
622
|
+
'main-media': {
|
|
623
|
+
mediaResourceId: 'main-media',
|
|
624
|
+
mType: 'mainCall',
|
|
625
|
+
participants: ['agent1', 'customer1'],
|
|
626
|
+
},
|
|
627
|
+
},
|
|
628
|
+
} as any;
|
|
629
|
+
const result = getConsultMediaResourceId(interaction, undefined, 'agent1');
|
|
630
|
+
expect(result).toBeUndefined();
|
|
631
|
+
});
|
|
632
|
+
|
|
633
|
+
it('prioritizes direct consultMediaResourceId over interaction search', () => {
|
|
634
|
+
const interaction = {
|
|
635
|
+
media: {
|
|
636
|
+
'consult-media': {
|
|
637
|
+
mediaResourceId: 'consult-media',
|
|
638
|
+
mType: 'consult',
|
|
639
|
+
participants: ['agent1', 'agent2'],
|
|
640
|
+
},
|
|
641
|
+
},
|
|
642
|
+
} as any;
|
|
643
|
+
const result = getConsultMediaResourceId(interaction, 'direct-id', 'agent1');
|
|
644
|
+
expect(result).toBe('direct-id');
|
|
645
|
+
});
|
|
646
|
+
});
|
|
647
|
+
|
|
648
|
+
describe('getIsConsultInProgressForConferenceControls', () => {
|
|
649
|
+
it('returns false when consultee is reserved but has not joined (RONA)', () => {
|
|
650
|
+
const interaction = {
|
|
651
|
+
participants: {
|
|
652
|
+
'agent-1': {id: 'agent-1', pType: 'Agent', hasLeft: false, isConsulted: false},
|
|
653
|
+
'agent-2': {
|
|
654
|
+
id: 'agent-2',
|
|
655
|
+
pType: 'Agent',
|
|
656
|
+
hasLeft: false,
|
|
657
|
+
hasJoined: false,
|
|
658
|
+
isConsulted: true,
|
|
659
|
+
consultState: 'consultReserved',
|
|
660
|
+
},
|
|
661
|
+
'customer-1': {id: 'customer-1', pType: 'Customer', hasLeft: false},
|
|
662
|
+
},
|
|
663
|
+
media: {
|
|
664
|
+
'interaction-1': {
|
|
665
|
+
mType: 'mainCall',
|
|
666
|
+
participants: ['customer-1', 'agent-1'],
|
|
667
|
+
},
|
|
668
|
+
'consult-media': {
|
|
669
|
+
mType: 'consult',
|
|
670
|
+
participants: ['agent-2', 'agent-1'],
|
|
671
|
+
},
|
|
672
|
+
},
|
|
673
|
+
} as any;
|
|
674
|
+
|
|
675
|
+
expect(
|
|
676
|
+
getIsConsultInProgressForConferenceControls(interaction, 'interaction-1', 'agent-1')
|
|
677
|
+
).toBe(false);
|
|
678
|
+
});
|
|
679
|
+
|
|
680
|
+
it('returns true when consultee is actively consulting', () => {
|
|
681
|
+
const interaction = {
|
|
682
|
+
participants: {
|
|
683
|
+
'agent-1': {id: 'agent-1', pType: 'Agent', hasLeft: false, isConsulted: false},
|
|
684
|
+
'agent-2': {
|
|
685
|
+
id: 'agent-2',
|
|
686
|
+
pType: 'Agent',
|
|
687
|
+
hasLeft: false,
|
|
688
|
+
hasJoined: true,
|
|
689
|
+
isConsulted: true,
|
|
690
|
+
consultState: 'consulting',
|
|
691
|
+
},
|
|
692
|
+
'customer-1': {id: 'customer-1', pType: 'Customer', hasLeft: false},
|
|
693
|
+
},
|
|
694
|
+
media: {
|
|
695
|
+
'interaction-1': {
|
|
696
|
+
mType: 'mainCall',
|
|
697
|
+
participants: ['customer-1', 'agent-1'],
|
|
698
|
+
},
|
|
699
|
+
'consult-media': {
|
|
700
|
+
mType: 'consult',
|
|
701
|
+
participants: ['agent-2', 'agent-1'],
|
|
702
|
+
},
|
|
703
|
+
},
|
|
704
|
+
} as any;
|
|
705
|
+
|
|
706
|
+
expect(
|
|
707
|
+
getIsConsultInProgressForConferenceControls(interaction, 'interaction-1', 'agent-1')
|
|
708
|
+
).toBe(true);
|
|
709
|
+
});
|
|
710
|
+
|
|
711
|
+
it('returns true when EP-DN participant is on consult leg but not main call (CAI-8329)', () => {
|
|
712
|
+
const interaction = {
|
|
713
|
+
participants: {
|
|
714
|
+
'agent-1': {id: 'agent-1', pType: 'Agent', hasLeft: false, consultState: 'conferencing'},
|
|
715
|
+
'+13159998087': {
|
|
716
|
+
id: '+13159998087',
|
|
717
|
+
pType: 'EP-DN',
|
|
718
|
+
type: 'EpDn',
|
|
719
|
+
hasLeft: false,
|
|
720
|
+
},
|
|
721
|
+
'customer-1': {id: 'customer-1', pType: 'Customer', hasLeft: false, hasJoined: true},
|
|
722
|
+
},
|
|
723
|
+
media: {
|
|
724
|
+
'interaction-1': {
|
|
725
|
+
mType: 'mainCall',
|
|
726
|
+
participants: ['customer-1', 'agent-1'],
|
|
727
|
+
},
|
|
728
|
+
'consult-media-1': {
|
|
729
|
+
mType: 'consult',
|
|
730
|
+
participants: ['+13159998087', 'agent-1'],
|
|
731
|
+
},
|
|
732
|
+
},
|
|
733
|
+
} as any;
|
|
734
|
+
|
|
735
|
+
expect(
|
|
736
|
+
getIsConsultInProgressForConferenceControls(interaction, 'interaction-1', 'agent-1')
|
|
737
|
+
).toBe(true);
|
|
738
|
+
});
|
|
739
|
+
});
|
|
433
740
|
});
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import {expect} from '@jest/globals';
|
|
2
|
+
import {
|
|
3
|
+
getWebexCallingDeviceDetailsForAgent,
|
|
4
|
+
isWebexCallingCallForAgent,
|
|
5
|
+
isWxAppEngagedForControls,
|
|
6
|
+
decodedLineOwnerId,
|
|
7
|
+
} from '../../../../../src/services/task/WebexCallingUtils';
|
|
8
|
+
import {TaskState} from '../../../../../src/services/task/state-machine/constants';
|
|
9
|
+
|
|
10
|
+
const WX_APP_PARTICIPANT = {
|
|
11
|
+
id: 'agent-1',
|
|
12
|
+
deviceType: 'wxApp',
|
|
13
|
+
deviceId: 'device-id-1',
|
|
14
|
+
deviceCallId: 'call-id-1',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const participantsById = {
|
|
18
|
+
'agent-1': WX_APP_PARTICIPANT,
|
|
19
|
+
'customer-1': {id: 'customer-1', pType: 'Customer'},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
describe('getWebexCallingDeviceDetailsForAgent', () => {
|
|
23
|
+
it('returns device details when agent participant has wxApp deviceType', () => {
|
|
24
|
+
const result = getWebexCallingDeviceDetailsForAgent('agent-1', participantsById);
|
|
25
|
+
|
|
26
|
+
expect(result).toEqual({
|
|
27
|
+
deviceType: 'wxApp',
|
|
28
|
+
deviceId: 'device-id-1',
|
|
29
|
+
deviceCallId: 'call-id-1',
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('returns undefined when agentId is undefined', () => {
|
|
34
|
+
expect(getWebexCallingDeviceDetailsForAgent(undefined, participantsById)).toBeUndefined();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('returns undefined when agentId is empty string', () => {
|
|
38
|
+
expect(getWebexCallingDeviceDetailsForAgent('', participantsById)).toBeUndefined();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('returns undefined when participants is null', () => {
|
|
42
|
+
expect(getWebexCallingDeviceDetailsForAgent('agent-1', null)).toBeUndefined();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('returns undefined when participants is an array (not object-by-id)', () => {
|
|
46
|
+
expect(getWebexCallingDeviceDetailsForAgent('agent-1', [WX_APP_PARTICIPANT])).toBeUndefined();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('returns undefined when agent participant lacks deviceCallId', () => {
|
|
50
|
+
const participants = {
|
|
51
|
+
'agent-1': {id: 'agent-1', deviceType: 'wxApp', deviceId: 'device-id-1'},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
expect(getWebexCallingDeviceDetailsForAgent('agent-1', participants)).toBeUndefined();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('returns undefined when agent participant lacks deviceId', () => {
|
|
58
|
+
const participants = {
|
|
59
|
+
'agent-1': {id: 'agent-1', deviceType: 'wxApp', deviceCallId: 'call-id-1'},
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
expect(getWebexCallingDeviceDetailsForAgent('agent-1', participants)).toBeUndefined();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('finds participant by id field when keyed differently', () => {
|
|
66
|
+
const participants = {
|
|
67
|
+
'some-other-key': WX_APP_PARTICIPANT,
|
|
68
|
+
};
|
|
69
|
+
const result = getWebexCallingDeviceDetailsForAgent('agent-1', participants);
|
|
70
|
+
|
|
71
|
+
expect(result?.deviceCallId).toBe('call-id-1');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('defaults deviceType to empty string when missing', () => {
|
|
75
|
+
const participants = {
|
|
76
|
+
'agent-1': {id: 'agent-1', deviceId: 'device-id-1', deviceCallId: 'call-id-1'},
|
|
77
|
+
};
|
|
78
|
+
const result = getWebexCallingDeviceDetailsForAgent('agent-1', participants);
|
|
79
|
+
|
|
80
|
+
expect(result?.deviceType).toBe('');
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe('isWebexCallingCallForAgent', () => {
|
|
85
|
+
it('returns true when device details are found', () => {
|
|
86
|
+
expect(isWebexCallingCallForAgent('agent-1', participantsById)).toBe(true);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('returns false when no device details are found', () => {
|
|
90
|
+
expect(isWebexCallingCallForAgent('unknown-agent', participantsById)).toBe(false);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('returns false when agentId is undefined', () => {
|
|
94
|
+
expect(isWebexCallingCallForAgent(undefined, participantsById)).toBe(false);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe('isWxAppEngagedForControls', () => {
|
|
99
|
+
it('returns true when flag is on, wxApp participant exists, and state is CONNECTED', () => {
|
|
100
|
+
expect(
|
|
101
|
+
isWxAppEngagedForControls(true, 'agent-1', participantsById, TaskState.CONNECTED)
|
|
102
|
+
).toBe(true);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('returns false in OFFERED state', () => {
|
|
106
|
+
expect(isWxAppEngagedForControls(true, 'agent-1', participantsById, TaskState.OFFERED)).toBe(
|
|
107
|
+
false
|
|
108
|
+
);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('returns false when enableWxBetterTogether is false', () => {
|
|
112
|
+
expect(
|
|
113
|
+
isWxAppEngagedForControls(false, 'agent-1', participantsById, TaskState.CONNECTED)
|
|
114
|
+
).toBe(false);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('returns false in TERMINATED state', () => {
|
|
118
|
+
expect(
|
|
119
|
+
isWxAppEngagedForControls(true, 'agent-1', participantsById, TaskState.TERMINATED)
|
|
120
|
+
).toBe(false);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('returns false in COMPLETED state', () => {
|
|
124
|
+
expect(
|
|
125
|
+
isWxAppEngagedForControls(true, 'agent-1', participantsById, TaskState.COMPLETED)
|
|
126
|
+
).toBe(false);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('returns false in WRAPPING_UP state', () => {
|
|
130
|
+
expect(
|
|
131
|
+
isWxAppEngagedForControls(true, 'agent-1', participantsById, TaskState.WRAPPING_UP)
|
|
132
|
+
).toBe(false);
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
describe('decodedLineOwnerId', () => {
|
|
137
|
+
it('returns undefined when lineOwnerId is not provided', () => {
|
|
138
|
+
expect(decodedLineOwnerId(undefined)).toBeUndefined();
|
|
139
|
+
expect(decodedLineOwnerId('')).toBeUndefined();
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('decodes base64 encoded ID and returns last path segment', () => {
|
|
143
|
+
const orgId = 'ciscospark://us/ORGANIZATION/org-abc';
|
|
144
|
+
const encoded = btoa(orgId);
|
|
145
|
+
const result = decodedLineOwnerId(encoded);
|
|
146
|
+
|
|
147
|
+
expect(result).toBe('org-abc');
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('returns undefined when base64 decoding fails', () => {
|
|
151
|
+
expect(decodedLineOwnerId('not-valid-base64!!')).toBeUndefined();
|
|
152
|
+
});
|
|
153
|
+
});
|
|
@@ -215,6 +215,39 @@ describe("Routing contacts", () => {
|
|
|
215
215
|
expect(req).toBeDefined();
|
|
216
216
|
});
|
|
217
217
|
|
|
218
|
+
it('dropConferenceParticipant', () => {
|
|
219
|
+
fakeAqm.pendingRequests = {};
|
|
220
|
+
const req = contact.dropConferenceParticipant({
|
|
221
|
+
interactionId: 'test-interaction-drop-123',
|
|
222
|
+
participantId: '+1/participant 42',
|
|
223
|
+
}) as any;
|
|
224
|
+
|
|
225
|
+
expect(req).toEqual({
|
|
226
|
+
url: '/v1/tasks/test-interaction-drop-123/conference/participants/%2B1%2Fparticipant%2042/drop',
|
|
227
|
+
data: {},
|
|
228
|
+
host: 'wcc-api-gateway',
|
|
229
|
+
err: expect.any(Function),
|
|
230
|
+
redactSensitiveLogs: true,
|
|
231
|
+
notifSuccess: {
|
|
232
|
+
bind: {
|
|
233
|
+
type: 'RoutingMessage',
|
|
234
|
+
data: {
|
|
235
|
+
type: 'ParticipantLeftConference',
|
|
236
|
+
interactionId: 'test-interaction-drop-123',
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
msg: {},
|
|
240
|
+
},
|
|
241
|
+
notifFail: {
|
|
242
|
+
bind: {
|
|
243
|
+
type: 'RoutingMessage',
|
|
244
|
+
data: {type: 'ParticipantDropConferenceFailed'},
|
|
245
|
+
},
|
|
246
|
+
errId: 'Service.aqm.task.dropConferenceParticipant',
|
|
247
|
+
},
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
|
|
218
251
|
it("exitConference", () => {
|
|
219
252
|
fakeAqm.pendingRequests = {};
|
|
220
253
|
const req = contact.exitConference({
|