@webex/contact-center 3.12.0-next.13 → 3.12.0-next.130
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/.sdd/manifest.json +884 -0
- package/AGENTS.md +94 -0
- package/ai-docs/ARCHITECTURE.md +168 -0
- package/ai-docs/CONTRACTS.md +53 -0
- package/ai-docs/GETTING_STARTED.md +168 -0
- package/ai-docs/GLOSSARY.md +43 -0
- package/ai-docs/README.md +138 -0
- package/ai-docs/REVIEW_CHECKLIST.md +41 -0
- package/ai-docs/RULES.md +444 -0
- package/ai-docs/SECURITY.md +52 -0
- package/ai-docs/SERVICE_STATE.md +52 -0
- package/ai-docs/SPEC_INDEX.md +65 -0
- package/ai-docs/adr/0001-spec-source-policy.md +55 -0
- package/ai-docs/adr/README.md +8 -0
- package/ai-docs/adr/_adr-template.md +31 -0
- package/ai-docs/contact-center-spec.md +382 -0
- package/ai-docs/features/consult-transfer-list-policy/spec/feature-spec.md +362 -0
- package/ai-docs/features/contact-owner-change-refactor.md +78 -0
- package/ai-docs/features/generated-spec-conformance-fidelity-remediation/spec/feature-spec.md +117 -0
- package/ai-docs/features/residual-warning-coverage-completion/spec/feature-spec.md +203 -0
- package/ai-docs/features/validator-code-fidelity-drift-fix/spec/feature-spec.md +315 -0
- package/ai-docs/patterns/event-driven-patterns.md +485 -0
- package/ai-docs/patterns/testing-patterns.md +480 -0
- package/ai-docs/patterns/typescript-patterns.md +365 -0
- package/ai-docs/templates/README.md +102 -0
- package/ai-docs/templates/documentation/create-agents-md.md +240 -0
- package/ai-docs/templates/documentation/create-architecture-md.md +295 -0
- package/ai-docs/templates/existing-service/bug-fix.md +254 -0
- package/ai-docs/templates/existing-service/feature-enhancement.md +450 -0
- package/ai-docs/templates/new-method/00-master.md +80 -0
- package/ai-docs/templates/new-method/01-requirements.md +232 -0
- package/ai-docs/templates/new-method/02-implementation.md +295 -0
- package/ai-docs/templates/new-method/03-tests.md +201 -0
- package/ai-docs/templates/new-method/04-validation.md +141 -0
- package/ai-docs/templates/new-service/00-master.md +109 -0
- package/ai-docs/templates/new-service/01-pre-questions.md +159 -0
- package/ai-docs/templates/new-service/02-code-generation.md +346 -0
- package/ai-docs/templates/new-service/03-integration.md +178 -0
- package/ai-docs/templates/new-service/04-test-generation.md +205 -0
- package/ai-docs/templates/new-service/05-validation.md +145 -0
- package/dist/cc.js +971 -42
- package/dist/cc.js.map +1 -1
- package/dist/config.js +13 -0
- package/dist/config.js.map +1 -1
- package/dist/constants.js +31 -3
- package/dist/constants.js.map +1 -1
- package/dist/index.js +45 -15
- 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 +205 -0
- package/dist/metrics/behavioral-events.js.map +1 -1
- package/dist/metrics/constants.js +48 -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 +269 -9
- 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/WebexCrossClientService.js +222 -0
- package/dist/services/WebexCrossClientService.js.map +1 -0
- package/dist/services/WxAppTelephonyMercurySync.js +108 -0
- package/dist/services/WxAppTelephonyMercurySync.js.map +1 -0
- package/dist/services/config/Util.js +11 -4
- package/dist/services/config/Util.js.map +1 -1
- package/dist/services/config/constants.js +41 -7
- package/dist/services/config/constants.js.map +1 -1
- package/dist/services/config/index.js +51 -0
- package/dist/services/config/index.js.map +1 -1
- package/dist/services/config/types.js +57 -12
- package/dist/services/config/types.js.map +1 -1
- package/dist/services/core/Err.js.map +1 -1
- package/dist/services/core/Utils.js +111 -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 +28 -14
- package/dist/services/core/aqm-reqs.js.map +1 -1
- package/dist/services/core/types.js.map +1 -1
- package/dist/services/core/websocket/WebSocketManager.js +2 -1
- package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
- package/dist/services/core/websocket/types.js.map +1 -1
- package/dist/services/index.js +1 -1
- package/dist/services/index.js.map +1 -1
- package/dist/services/task/Task.js +754 -0
- package/dist/services/task/Task.js.map +1 -0
- package/dist/services/task/TaskFactory.js +49 -0
- package/dist/services/task/TaskFactory.js.map +1 -0
- package/dist/services/task/TaskManager.js +1172 -521
- package/dist/services/task/TaskManager.js.map +1 -1
- package/dist/services/task/TaskUtils.js +211 -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 +12 -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 +228 -5
- package/dist/services/task/types.js.map +1 -1
- package/dist/services/task/voice/Voice.js +1485 -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/wxAppVoiceMethods.js +354 -0
- package/dist/services/task/voice/wxAppVoiceMethods.js.map +1 -0
- package/dist/services/wxAppDiagnosticLogging.js +122 -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 +193 -6
- package/dist/types/config.d.ts +13 -0
- package/dist/types/constants.d.ts +29 -1
- package/dist/types/index.d.ts +35 -8
- package/dist/types/metrics/MetricsManager.d.ts +6 -0
- package/dist/types/metrics/constants.d.ts +43 -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 +56 -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/constants.d.ts +34 -5
- package/dist/types/services/config/types.d.ts +197 -12
- package/dist/types/services/core/Err.d.ts +6 -0
- package/dist/types/services/core/Utils.d.ts +35 -13
- package/dist/types/services/core/WebexRequest.d.ts +1 -0
- package/dist/types/services/core/types.d.ts +2 -0
- package/dist/types/services/core/websocket/WebSocketManager.d.ts +1 -0
- package/dist/types/services/core/websocket/types.d.ts +1 -1
- package/dist/types/services/index.d.ts +1 -1
- package/dist/types/services/task/Task.d.ts +175 -0
- package/dist/types/services/task/TaskFactory.d.ts +13 -0
- package/dist/types/services/task/TaskUtils.d.ts +48 -2
- package/dist/types/services/task/WebexCallingUtils.d.ts +11 -0
- package/dist/types/services/task/constants.d.ts +10 -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 +22 -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 +680 -66
- package/dist/types/services/task/voice/Voice.d.ts +227 -0
- package/dist/types/services/task/voice/WebRTC.d.ts +53 -0
- package/dist/types/services/task/voice/wxAppVoiceMethods.d.ts +55 -0
- package/dist/types/services/wxAppDiagnosticLogging.d.ts +51 -0
- package/dist/types/services/wxAppTelephonyUtils.d.ts +5 -0
- package/dist/types/types.d.ts +205 -9
- package/dist/types/utils/PageCache.d.ts +20 -3
- package/dist/types/webex.d.ts +1 -0
- package/dist/types.js +162 -4
- 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/package.json +16 -12
- package/src/cc.ts +1289 -112
- package/src/config.ts +13 -0
- package/src/constants.ts +29 -1
- package/src/index.ts +36 -5
- package/src/metrics/MetricsManager.ts +16 -0
- package/src/metrics/ai-docs/AGENTS.md +350 -0
- package/src/metrics/ai-docs/ARCHITECTURE.md +338 -0
- package/src/metrics/ai-docs/metrics-spec.md +921 -0
- package/src/metrics/behavioral-events.ts +212 -0
- package/src/metrics/constants.ts +52 -4
- package/src/services/AddressBook.ts +17 -6
- package/src/services/AnswerCallOnWebexService.ts +239 -0
- package/src/services/ApiAiAssistant.ts +356 -9
- package/src/services/EntryPoint.ts +59 -60
- package/src/services/Queue.ts +29 -12
- package/src/services/UserPreference.ts +509 -0
- package/src/services/WebexCrossClientService.ts +293 -0
- package/src/services/WxAppTelephonyMercurySync.ts +142 -0
- package/src/services/agent/ai-docs/AGENTS.md +240 -0
- package/src/services/agent/ai-docs/ARCHITECTURE.md +304 -0
- package/src/services/agent/ai-docs/agent-spec.md +505 -0
- package/src/services/ai-docs/AGENTS.md +386 -0
- package/src/services/ai-docs/services-spec.md +505 -0
- package/src/services/config/Util.ts +12 -3
- package/src/services/config/ai-docs/AGENTS.md +255 -0
- package/src/services/config/ai-docs/ARCHITECTURE.md +426 -0
- package/src/services/config/ai-docs/config-spec.md +686 -0
- package/src/services/config/constants.ts +46 -6
- package/src/services/config/index.ts +65 -0
- package/src/services/config/types.ts +197 -13
- package/src/services/core/Err.ts +3 -0
- package/src/services/core/Utils.ts +127 -37
- package/src/services/core/WebexRequest.ts +3 -1
- package/src/services/core/ai-docs/AGENTS.md +381 -0
- package/src/services/core/ai-docs/ARCHITECTURE.md +698 -0
- package/src/services/core/ai-docs/core-spec.md +787 -0
- package/src/services/core/aqm-reqs.ts +30 -15
- package/src/services/core/types.ts +2 -0
- package/src/services/core/websocket/WebSocketManager.ts +2 -0
- package/src/services/core/websocket/types.ts +1 -1
- package/src/services/index.ts +1 -1
- package/src/services/task/Task.ts +908 -0
- package/src/services/task/TaskFactory.ts +60 -0
- package/src/services/task/TaskManager.ts +1419 -608
- package/src/services/task/TaskUtils.ts +303 -25
- package/src/services/task/WebexCallingUtils.ts +136 -0
- package/src/services/task/ai-docs/AGENTS.md +457 -0
- package/src/services/task/ai-docs/ARCHITECTURE.md +595 -0
- package/src/services/task/ai-docs/task-spec.md +1474 -0
- package/src/services/task/constants.ts +10 -0
- package/src/services/task/contact.ts +30 -0
- package/src/services/task/dialer.ts +80 -0
- package/src/services/task/digital/Digital.ts +97 -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/ai-docs/AGENTS.md +460 -0
- package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +1156 -0
- package/src/services/task/state-machine/ai-docs/task-state-machine-spec.md +2247 -0
- package/src/services/task/state-machine/constants.ts +172 -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 +819 -70
- package/src/services/task/voice/Voice.ts +1851 -0
- package/src/services/task/voice/WebRTC.ts +191 -0
- package/src/services/task/voice/wxAppVoiceMethods.ts +516 -0
- package/src/services/wxAppDiagnosticLogging.ts +174 -0
- package/src/services/wxAppTelephonyUtils.ts +14 -0
- package/src/types.ts +262 -11
- package/src/utils/AGENTS.md +289 -0
- package/src/utils/PageCache.ts +38 -5
- package/src/utils/ai-docs/utils-spec.md +391 -0
- package/src/webex.js +10 -0
- package/test/unit/spec/cc.ts +2210 -119
- 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 +311 -21
- 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 +7 -1
- package/test/unit/spec/services/WebexCrossClientService.ts +467 -0
- package/test/unit/spec/services/WxAppTelephonyMercurySync.ts +136 -0
- package/test/unit/spec/services/config/Util.ts +129 -0
- package/test/unit/spec/services/config/index.ts +97 -29
- package/test/unit/spec/services/core/Utils.ts +425 -8
- package/test/unit/spec/services/core/WebexRequest.ts +3 -1
- package/test/unit/spec/services/core/aqm-reqs.ts +113 -1
- package/test/unit/spec/services/core/websocket/WebSocketManager.ts +66 -40
- package/test/unit/spec/services/task/AutoWrapup.ts +63 -0
- package/test/unit/spec/services/task/Task.ts +745 -0
- package/test/unit/spec/services/task/TaskFactory.ts +99 -0
- package/test/unit/spec/services/task/TaskManager.ts +2518 -1494
- package/test/unit/spec/services/task/TaskUtils.ts +235 -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 +2061 -0
- package/test/unit/spec/services/task/voice/WebRTC.ts +235 -0
- package/test/unit/spec/services/task/voice/wxAppVoiceMethods.ts +603 -0
- package/test/unit/spec/services/wxAppDiagnosticLogging.ts +143 -0
- package/test/unit/spec/wellnessSampleUtils.ts +288 -0
- 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
|
@@ -0,0 +1,839 @@
|
|
|
1
|
+
import {guards, GuardParams} from '../../../../../../src/services/task/state-machine/guards';
|
|
2
|
+
import {
|
|
3
|
+
TaskContext,
|
|
4
|
+
TaskEventPayload,
|
|
5
|
+
} from '../../../../../../src/services/task/state-machine/types';
|
|
6
|
+
import {TaskEvent} from '../../../../../../src/services/task/state-machine/constants';
|
|
7
|
+
import {TaskData, InteractionParticipant} from '../../../../../../src/services/task/types';
|
|
8
|
+
|
|
9
|
+
describe('State Machine Guards', () => {
|
|
10
|
+
const createParticipant = (
|
|
11
|
+
id: string,
|
|
12
|
+
pType: string,
|
|
13
|
+
hasLeft = false
|
|
14
|
+
): InteractionParticipant => ({
|
|
15
|
+
id,
|
|
16
|
+
pType,
|
|
17
|
+
type: pType,
|
|
18
|
+
hasJoined: true,
|
|
19
|
+
hasLeft,
|
|
20
|
+
isInPredial: false,
|
|
21
|
+
});
|
|
22
|
+
// Note: media key must match mainInteractionId for getIsConferenceInProgress to work
|
|
23
|
+
const INTERACTION_ID = 'interaction-123';
|
|
24
|
+
|
|
25
|
+
const createTaskData = (overrides: Partial<TaskData> = {}): TaskData =>
|
|
26
|
+
({
|
|
27
|
+
mediaResourceId: INTERACTION_ID,
|
|
28
|
+
eventType: 'TEST_EVENT',
|
|
29
|
+
agentId: 'agent-123',
|
|
30
|
+
destAgentId: '',
|
|
31
|
+
trackingId: 'track-123',
|
|
32
|
+
consultMediaResourceId: '',
|
|
33
|
+
interactionId: INTERACTION_ID,
|
|
34
|
+
orgId: 'org-123',
|
|
35
|
+
owner: 'agent-123',
|
|
36
|
+
queueMgr: 'queue-mgr',
|
|
37
|
+
type: 'voice',
|
|
38
|
+
isConferencing: false,
|
|
39
|
+
interaction: {
|
|
40
|
+
mainInteractionId: INTERACTION_ID,
|
|
41
|
+
interactionId: INTERACTION_ID,
|
|
42
|
+
participants: {},
|
|
43
|
+
media: {
|
|
44
|
+
[INTERACTION_ID]: {
|
|
45
|
+
mediaResourceId: INTERACTION_ID,
|
|
46
|
+
mediaType: 'telephony',
|
|
47
|
+
mediaMgr: 'media-mgr',
|
|
48
|
+
participants: ['agent-123'],
|
|
49
|
+
mType: 'mainCall',
|
|
50
|
+
isHold: false,
|
|
51
|
+
holdTimestamp: null,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
owner: 'agent-123',
|
|
55
|
+
mediaChannel: 'telephony',
|
|
56
|
+
contactDirection: {type: 'inbound'},
|
|
57
|
+
},
|
|
58
|
+
...overrides,
|
|
59
|
+
} as TaskData);
|
|
60
|
+
|
|
61
|
+
const createContext = (overrides: Partial<TaskContext> = {}): TaskContext =>
|
|
62
|
+
({
|
|
63
|
+
recordingControlsAvailable: false,
|
|
64
|
+
recordingInProgress: false,
|
|
65
|
+
consultDestinationAgentJoined: false,
|
|
66
|
+
consultCallHeld: false,
|
|
67
|
+
consultInitiator: false,
|
|
68
|
+
exitingConference: false,
|
|
69
|
+
hideBlindTransferForEpDnPendingMerge: false,
|
|
70
|
+
consultDestinationType: null,
|
|
71
|
+
taskData: createTaskData(),
|
|
72
|
+
uiControlConfig: {agentId: 'agent-123'},
|
|
73
|
+
uiControls: {
|
|
74
|
+
main: {
|
|
75
|
+
accept: {isVisible: false, isEnabled: false},
|
|
76
|
+
decline: {isVisible: false, isEnabled: false},
|
|
77
|
+
hold: {isVisible: false, isEnabled: false},
|
|
78
|
+
end: {isVisible: false, isEnabled: false},
|
|
79
|
+
transfer: {isVisible: false, isEnabled: false},
|
|
80
|
+
consult: {isVisible: false, isEnabled: false},
|
|
81
|
+
consultTransfer: {isVisible: false, isEnabled: false},
|
|
82
|
+
endConsult: {isVisible: false, isEnabled: false},
|
|
83
|
+
recording: {isVisible: false, isEnabled: false},
|
|
84
|
+
conference: {isVisible: false, isEnabled: false},
|
|
85
|
+
wrapup: {isVisible: false, isEnabled: false},
|
|
86
|
+
exitConference: {isVisible: false, isEnabled: false},
|
|
87
|
+
transferConference: {isVisible: false, isEnabled: false},
|
|
88
|
+
mergeToConference: {isVisible: false, isEnabled: false},
|
|
89
|
+
switch: {isVisible: false, isEnabled: false},
|
|
90
|
+
mute: {isVisible: false, isEnabled: false},
|
|
91
|
+
},
|
|
92
|
+
consult: {
|
|
93
|
+
accept: {isVisible: false, isEnabled: false},
|
|
94
|
+
decline: {isVisible: false, isEnabled: false},
|
|
95
|
+
hold: {isVisible: false, isEnabled: false},
|
|
96
|
+
end: {isVisible: false, isEnabled: false},
|
|
97
|
+
transfer: {isVisible: false, isEnabled: false},
|
|
98
|
+
consult: {isVisible: false, isEnabled: false},
|
|
99
|
+
consultTransfer: {isVisible: false, isEnabled: false},
|
|
100
|
+
endConsult: {isVisible: false, isEnabled: false},
|
|
101
|
+
recording: {isVisible: false, isEnabled: false},
|
|
102
|
+
conference: {isVisible: false, isEnabled: false},
|
|
103
|
+
wrapup: {isVisible: false, isEnabled: false},
|
|
104
|
+
exitConference: {isVisible: false, isEnabled: false},
|
|
105
|
+
transferConference: {isVisible: false, isEnabled: false},
|
|
106
|
+
mergeToConference: {isVisible: false, isEnabled: false},
|
|
107
|
+
switch: {isVisible: false, isEnabled: false},
|
|
108
|
+
mute: {isVisible: false, isEnabled: false},
|
|
109
|
+
},
|
|
110
|
+
activeLeg: 'main',
|
|
111
|
+
},
|
|
112
|
+
...overrides,
|
|
113
|
+
} as TaskContext);
|
|
114
|
+
|
|
115
|
+
const createParams = (context: TaskContext, event?: TaskEventPayload): GuardParams => ({
|
|
116
|
+
context,
|
|
117
|
+
event,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const createEventWithTaskData = (taskData: TaskData): TaskEventPayload =>
|
|
121
|
+
({taskData} as TaskEventPayload);
|
|
122
|
+
|
|
123
|
+
describe('Conference Guards', () => {
|
|
124
|
+
it('conferenceInProgressFromEvent returns true with 2+ agents in event', () => {
|
|
125
|
+
const ctx = createContext();
|
|
126
|
+
const taskData = createTaskData({
|
|
127
|
+
interaction: {
|
|
128
|
+
...createTaskData().interaction,
|
|
129
|
+
participants: {
|
|
130
|
+
a1: createParticipant('a1', 'Agent'),
|
|
131
|
+
a2: createParticipant('a2', 'Agent'),
|
|
132
|
+
},
|
|
133
|
+
media: {
|
|
134
|
+
[INTERACTION_ID]: {
|
|
135
|
+
mediaResourceId: INTERACTION_ID,
|
|
136
|
+
mediaType: 'telephony',
|
|
137
|
+
mediaMgr: 'media-mgr',
|
|
138
|
+
participants: ['a1', 'a2'],
|
|
139
|
+
mType: 'mainCall',
|
|
140
|
+
isHold: false,
|
|
141
|
+
holdTimestamp: null,
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
expect(
|
|
147
|
+
guards.conferenceInProgressFromEvent(createParams(ctx, createEventWithTaskData(taskData)))
|
|
148
|
+
).toBe(true);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('conferenceInProgressFromEvent returns false with 1 agent', () => {
|
|
152
|
+
const ctx = createContext();
|
|
153
|
+
const taskData = createTaskData({
|
|
154
|
+
interaction: {
|
|
155
|
+
...createTaskData().interaction,
|
|
156
|
+
participants: {
|
|
157
|
+
a1: createParticipant('a1', 'Agent'),
|
|
158
|
+
},
|
|
159
|
+
media: {
|
|
160
|
+
[INTERACTION_ID]: {
|
|
161
|
+
mediaResourceId: INTERACTION_ID,
|
|
162
|
+
mediaType: 'telephony',
|
|
163
|
+
mediaMgr: 'media-mgr',
|
|
164
|
+
participants: ['a1'],
|
|
165
|
+
mType: 'mainCall',
|
|
166
|
+
isHold: false,
|
|
167
|
+
holdTimestamp: null,
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
expect(
|
|
173
|
+
guards.conferenceInProgressFromEvent(createParams(ctx, createEventWithTaskData(taskData)))
|
|
174
|
+
).toBe(false);
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
describe('Consult Guards', () => {
|
|
179
|
+
it('didInitiateConsult returns true when consultingAgentId matches', () => {
|
|
180
|
+
const ctx = createContext();
|
|
181
|
+
const taskData = createTaskData({
|
|
182
|
+
consultingAgentId: 'agent-123',
|
|
183
|
+
isConsulted: false,
|
|
184
|
+
});
|
|
185
|
+
expect(guards.didInitiateConsult(createParams(ctx, createEventWithTaskData(taskData)))).toBe(
|
|
186
|
+
true
|
|
187
|
+
);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('didInitiateConsult returns false when isConsulted is true', () => {
|
|
191
|
+
const ctx = createContext();
|
|
192
|
+
const taskData = createTaskData({isConsulted: true});
|
|
193
|
+
expect(guards.didInitiateConsult(createParams(ctx, createEventWithTaskData(taskData)))).toBe(
|
|
194
|
+
false
|
|
195
|
+
);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it('isInteractionConsulting returns true for pending self consult on hydrate', () => {
|
|
199
|
+
const ctx = createContext();
|
|
200
|
+
const taskData = createTaskData({
|
|
201
|
+
isConsulted: false,
|
|
202
|
+
interaction: {
|
|
203
|
+
...createTaskData().interaction,
|
|
204
|
+
state: 'conference',
|
|
205
|
+
participants: {
|
|
206
|
+
'agent-123': {
|
|
207
|
+
...createParticipant('agent-123', 'Agent'),
|
|
208
|
+
consultState: 'consultInitiated',
|
|
209
|
+
isConsulted: false,
|
|
210
|
+
},
|
|
211
|
+
'agent-456': {
|
|
212
|
+
...createParticipant('agent-456', 'Agent'),
|
|
213
|
+
hasJoined: false,
|
|
214
|
+
consultState: 'consultReserved',
|
|
215
|
+
isConsulted: true,
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
media: {
|
|
219
|
+
[INTERACTION_ID]: {
|
|
220
|
+
mediaResourceId: INTERACTION_ID,
|
|
221
|
+
mediaType: 'telephony',
|
|
222
|
+
mediaMgr: 'media-mgr',
|
|
223
|
+
participants: ['agent-123'],
|
|
224
|
+
mType: 'mainCall',
|
|
225
|
+
isHold: true,
|
|
226
|
+
holdTimestamp: Date.now(),
|
|
227
|
+
},
|
|
228
|
+
'consult-media': {
|
|
229
|
+
mediaResourceId: 'consult-media',
|
|
230
|
+
mediaType: 'telephony',
|
|
231
|
+
mediaMgr: 'media-mgr',
|
|
232
|
+
participants: ['agent-123', 'agent-456'],
|
|
233
|
+
mType: 'consult',
|
|
234
|
+
isHold: false,
|
|
235
|
+
holdTimestamp: null,
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
} as any,
|
|
239
|
+
});
|
|
240
|
+
expect(
|
|
241
|
+
guards.isInteractionConsulting(createParams(ctx, createEventWithTaskData(taskData)))
|
|
242
|
+
).toBe(true);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it('isInteractionConsulting returns false for consulted agent pending consult state', () => {
|
|
246
|
+
const ctx = createContext();
|
|
247
|
+
const taskData = createTaskData({
|
|
248
|
+
isConsulted: true,
|
|
249
|
+
interaction: {
|
|
250
|
+
...createTaskData().interaction,
|
|
251
|
+
state: 'conference',
|
|
252
|
+
participants: {
|
|
253
|
+
'agent-123': {
|
|
254
|
+
...createParticipant('agent-123', 'Agent'),
|
|
255
|
+
consultState: 'consultInitiated',
|
|
256
|
+
isConsulted: true,
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
media: {
|
|
260
|
+
[INTERACTION_ID]: {
|
|
261
|
+
mediaResourceId: INTERACTION_ID,
|
|
262
|
+
mediaType: 'telephony',
|
|
263
|
+
mediaMgr: 'media-mgr',
|
|
264
|
+
participants: ['agent-123'],
|
|
265
|
+
mType: 'mainCall',
|
|
266
|
+
isHold: true,
|
|
267
|
+
holdTimestamp: Date.now(),
|
|
268
|
+
},
|
|
269
|
+
'consult-media': {
|
|
270
|
+
mediaResourceId: 'consult-media',
|
|
271
|
+
mediaType: 'telephony',
|
|
272
|
+
mediaMgr: 'media-mgr',
|
|
273
|
+
participants: ['agent-123'],
|
|
274
|
+
mType: 'consult',
|
|
275
|
+
isHold: false,
|
|
276
|
+
holdTimestamp: null,
|
|
277
|
+
},
|
|
278
|
+
},
|
|
279
|
+
} as any,
|
|
280
|
+
});
|
|
281
|
+
expect(
|
|
282
|
+
guards.isInteractionConsulting(createParams(ctx, createEventWithTaskData(taskData)))
|
|
283
|
+
).toBe(false);
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
describe('Wrap-up Guards', () => {
|
|
288
|
+
it('shouldWrapUp returns true for owner', () => {
|
|
289
|
+
const ctx = createContext();
|
|
290
|
+
const taskData = createTaskData({
|
|
291
|
+
interaction: {
|
|
292
|
+
...createTaskData().interaction,
|
|
293
|
+
owner: 'agent-123',
|
|
294
|
+
},
|
|
295
|
+
});
|
|
296
|
+
expect(guards.shouldWrapUp(createParams(ctx, createEventWithTaskData(taskData)))).toBe(true);
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
it('shouldWrapUp returns false for non-owner', () => {
|
|
300
|
+
const ctx = createContext();
|
|
301
|
+
const taskData = createTaskData({
|
|
302
|
+
interaction: {
|
|
303
|
+
...createTaskData().interaction,
|
|
304
|
+
owner: 'other-agent',
|
|
305
|
+
},
|
|
306
|
+
});
|
|
307
|
+
expect(guards.shouldWrapUp(createParams(ctx, createEventWithTaskData(taskData)))).toBe(false);
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
it('shouldWrapUp returns true when agentsPendingWrapUp includes agent', () => {
|
|
311
|
+
const ctx = createContext();
|
|
312
|
+
const taskData = createTaskData({
|
|
313
|
+
agentsPendingWrapUp: ['agent-123', 'other-agent'],
|
|
314
|
+
} as Partial<TaskData>);
|
|
315
|
+
expect(guards.shouldWrapUp(createParams(ctx, createEventWithTaskData(taskData)))).toBe(true);
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
it('shouldWrapUp uses isConsulted fallback when no owner', () => {
|
|
319
|
+
const taskData = createTaskData({
|
|
320
|
+
isConsulted: false,
|
|
321
|
+
interaction: {
|
|
322
|
+
...createTaskData().interaction,
|
|
323
|
+
owner: undefined as unknown as string, // No owner
|
|
324
|
+
},
|
|
325
|
+
});
|
|
326
|
+
const ctx = createContext({taskData});
|
|
327
|
+
expect(guards.shouldWrapUp(createParams(ctx, createEventWithTaskData(taskData)))).toBe(true);
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
describe('isPassiveConferenceTransferObserver', () => {
|
|
332
|
+
it('returns false when transfer was initiated via widgets', () => {
|
|
333
|
+
const ctx = createContext({transferConferenceRequested: true, consultInitiator: false});
|
|
334
|
+
expect(
|
|
335
|
+
guards.isPassiveConferenceTransferObserver(createParams(ctx, createEventWithTaskData()))
|
|
336
|
+
).toBe(false);
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
it('returns false when this agent initiated the consult transfer', () => {
|
|
340
|
+
const ctx = createContext({transferConferenceRequested: false, consultInitiator: false});
|
|
341
|
+
const taskData = createTaskData({consultingAgentId: 'agent-123'});
|
|
342
|
+
expect(
|
|
343
|
+
guards.isPassiveConferenceTransferObserver(
|
|
344
|
+
createParams(ctx, createEventWithTaskData(taskData))
|
|
345
|
+
)
|
|
346
|
+
).toBe(false);
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
it('returns true when only stale consultInitiator is set without consultingAgentId evidence', () => {
|
|
350
|
+
const ctx = createContext({transferConferenceRequested: false, consultInitiator: true});
|
|
351
|
+
expect(
|
|
352
|
+
guards.isPassiveConferenceTransferObserver(createParams(ctx, createEventWithTaskData()))
|
|
353
|
+
).toBe(true);
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
it('returns false when self is absent from participants snapshot', () => {
|
|
357
|
+
const ctx = createContext({consultInitiator: false});
|
|
358
|
+
const taskData = createTaskData({
|
|
359
|
+
interaction: {
|
|
360
|
+
...createTaskData().interaction,
|
|
361
|
+
participants: {
|
|
362
|
+
'other-agent': createParticipant('other-agent', 'Agent'),
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
});
|
|
366
|
+
expect(
|
|
367
|
+
guards.isPassiveConferenceTransferObserver(
|
|
368
|
+
createParams(ctx, createEventWithTaskData(taskData))
|
|
369
|
+
)
|
|
370
|
+
).toBe(false);
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
it('returns false when self hasLeft in participants snapshot', () => {
|
|
374
|
+
const ctx = createContext({consultInitiator: false});
|
|
375
|
+
const taskData = createTaskData({
|
|
376
|
+
interaction: {
|
|
377
|
+
...createTaskData().interaction,
|
|
378
|
+
participants: {
|
|
379
|
+
'agent-123': createParticipant('agent-123', 'Agent', true),
|
|
380
|
+
},
|
|
381
|
+
},
|
|
382
|
+
});
|
|
383
|
+
expect(
|
|
384
|
+
guards.isPassiveConferenceTransferObserver(
|
|
385
|
+
createParams(ctx, createEventWithTaskData(taskData))
|
|
386
|
+
)
|
|
387
|
+
).toBe(false);
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
it('returns true for passive observer still in the conference', () => {
|
|
391
|
+
const ctx = createContext({transferConferenceRequested: false, consultInitiator: false});
|
|
392
|
+
const taskData = createTaskData({
|
|
393
|
+
interaction: {
|
|
394
|
+
...createTaskData().interaction,
|
|
395
|
+
participants: {
|
|
396
|
+
'agent-123': createParticipant('agent-123', 'Agent'),
|
|
397
|
+
'other-agent': createParticipant('other-agent', 'Agent'),
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
});
|
|
401
|
+
expect(
|
|
402
|
+
guards.isPassiveConferenceTransferObserver(
|
|
403
|
+
createParams(ctx, createEventWithTaskData(taskData))
|
|
404
|
+
)
|
|
405
|
+
).toBe(true);
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
it('returns false when secondary agent initiated transfer via payload consultingAgentId', () => {
|
|
409
|
+
const ctx = createContext({transferConferenceRequested: false, consultInitiator: false});
|
|
410
|
+
const taskData = createTaskData({
|
|
411
|
+
isConsulted: true,
|
|
412
|
+
consultingAgentId: 'agent-123',
|
|
413
|
+
interaction: {
|
|
414
|
+
...createTaskData().interaction,
|
|
415
|
+
participants: {
|
|
416
|
+
'agent-123': {...createParticipant('agent-123', 'Agent'), consultState: 'consulting'},
|
|
417
|
+
},
|
|
418
|
+
media: {
|
|
419
|
+
...createTaskData().interaction!.media,
|
|
420
|
+
'consult-media': {
|
|
421
|
+
mediaResourceId: 'consult-media',
|
|
422
|
+
mediaType: 'telephony',
|
|
423
|
+
mediaMgr: 'media-mgr',
|
|
424
|
+
participants: ['agent-123', 'agent-456'],
|
|
425
|
+
mType: 'consult',
|
|
426
|
+
isHold: false,
|
|
427
|
+
holdTimestamp: null,
|
|
428
|
+
},
|
|
429
|
+
},
|
|
430
|
+
},
|
|
431
|
+
});
|
|
432
|
+
expect(
|
|
433
|
+
guards.isPassiveConferenceTransferObserver(
|
|
434
|
+
createParams(ctx, createEventWithTaskData(taskData))
|
|
435
|
+
)
|
|
436
|
+
).toBe(false);
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
describe('isSelfConferenceTransferInitiator', () => {
|
|
441
|
+
it('returns true when consultingAgentId matches self even if isConsulted is true', () => {
|
|
442
|
+
const ctx = createContext({consultInitiator: false, transferConferenceRequested: false});
|
|
443
|
+
const taskData = createTaskData({
|
|
444
|
+
isConsulted: true,
|
|
445
|
+
consultingAgentId: 'agent-123',
|
|
446
|
+
});
|
|
447
|
+
expect(
|
|
448
|
+
guards.isSelfConferenceTransferInitiator(
|
|
449
|
+
createParams(ctx, createEventWithTaskData(taskData))
|
|
450
|
+
)
|
|
451
|
+
).toBe(true);
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
it('returns false when consultee has consultState consulting but consultingAgentId is another agent', () => {
|
|
455
|
+
const ctx = createContext({consultInitiator: false, transferConferenceRequested: false});
|
|
456
|
+
const taskData = createTaskData({
|
|
457
|
+
isConsulted: true,
|
|
458
|
+
consultingAgentId: 'agent-456',
|
|
459
|
+
interaction: {
|
|
460
|
+
...createTaskData().interaction,
|
|
461
|
+
participants: {
|
|
462
|
+
'agent-123': {...createParticipant('agent-123', 'Agent'), consultState: 'consulting'},
|
|
463
|
+
},
|
|
464
|
+
media: {
|
|
465
|
+
[INTERACTION_ID]: createTaskData().interaction!.media![INTERACTION_ID],
|
|
466
|
+
'consult-media': {
|
|
467
|
+
mediaResourceId: 'consult-media',
|
|
468
|
+
mediaType: 'telephony',
|
|
469
|
+
mediaMgr: 'media-mgr',
|
|
470
|
+
participants: ['agent-123', 'agent-456'],
|
|
471
|
+
mType: 'consult',
|
|
472
|
+
isHold: false,
|
|
473
|
+
holdTimestamp: null,
|
|
474
|
+
},
|
|
475
|
+
},
|
|
476
|
+
},
|
|
477
|
+
});
|
|
478
|
+
expect(
|
|
479
|
+
guards.isSelfConferenceTransferInitiator(
|
|
480
|
+
createParams(ctx, createEventWithTaskData(taskData))
|
|
481
|
+
)
|
|
482
|
+
).toBe(false);
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
it('returns false for passive observer without consult signals', () => {
|
|
486
|
+
const ctx = createContext({consultInitiator: false, transferConferenceRequested: false});
|
|
487
|
+
const taskData = createTaskData({
|
|
488
|
+
isConsulted: true,
|
|
489
|
+
interaction: {
|
|
490
|
+
...createTaskData().interaction,
|
|
491
|
+
participants: {
|
|
492
|
+
'agent-123': createParticipant('agent-123', 'Agent'),
|
|
493
|
+
},
|
|
494
|
+
},
|
|
495
|
+
});
|
|
496
|
+
expect(
|
|
497
|
+
guards.isSelfConferenceTransferInitiator(
|
|
498
|
+
createParams(ctx, createEventWithTaskData(taskData))
|
|
499
|
+
)
|
|
500
|
+
).toBe(false);
|
|
501
|
+
});
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
describe('Hydration Guards - isInteractionConsulting', () => {
|
|
505
|
+
it('returns true when interaction state is consulting', () => {
|
|
506
|
+
const ctx = createContext();
|
|
507
|
+
const taskData = createTaskData({
|
|
508
|
+
interaction: {
|
|
509
|
+
...createTaskData().interaction,
|
|
510
|
+
state: 'consulting',
|
|
511
|
+
},
|
|
512
|
+
});
|
|
513
|
+
expect(
|
|
514
|
+
guards.isInteractionConsulting(createParams(ctx, createEventWithTaskData(taskData)))
|
|
515
|
+
).toBe(true);
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
it('returns true for EP_DN consulted agent (state=connected, CPD relationshipType=consult)', () => {
|
|
519
|
+
const ctx = createContext();
|
|
520
|
+
const taskData = createTaskData({
|
|
521
|
+
interaction: {
|
|
522
|
+
...createTaskData().interaction,
|
|
523
|
+
state: 'connected',
|
|
524
|
+
callProcessingDetails: {
|
|
525
|
+
...createTaskData().interaction!.callProcessingDetails,
|
|
526
|
+
relationshipType: 'consult',
|
|
527
|
+
},
|
|
528
|
+
},
|
|
529
|
+
});
|
|
530
|
+
expect(
|
|
531
|
+
guards.isInteractionConsulting(createParams(ctx, createEventWithTaskData(taskData)))
|
|
532
|
+
).toBe(true);
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
it('returns true when post_call with active consult (consultState=consulting + consult media)', () => {
|
|
536
|
+
const ctx = createContext();
|
|
537
|
+
const taskData = createTaskData({
|
|
538
|
+
interaction: {
|
|
539
|
+
...createTaskData().interaction,
|
|
540
|
+
state: 'post_call',
|
|
541
|
+
participants: {
|
|
542
|
+
'agent-123': {
|
|
543
|
+
...createParticipant('agent-123', 'Agent'),
|
|
544
|
+
consultState: 'consulting',
|
|
545
|
+
},
|
|
546
|
+
},
|
|
547
|
+
media: {
|
|
548
|
+
[INTERACTION_ID]: {
|
|
549
|
+
mediaResourceId: INTERACTION_ID,
|
|
550
|
+
mediaType: 'telephony',
|
|
551
|
+
mediaMgr: 'media-mgr',
|
|
552
|
+
participants: ['agent-123'],
|
|
553
|
+
mType: 'mainCall',
|
|
554
|
+
isHold: false,
|
|
555
|
+
holdTimestamp: null,
|
|
556
|
+
},
|
|
557
|
+
'consult-media': {
|
|
558
|
+
mediaResourceId: 'consult-media',
|
|
559
|
+
mediaType: 'telephony',
|
|
560
|
+
mediaMgr: 'media-mgr',
|
|
561
|
+
participants: ['agent-123', 'agent-2'],
|
|
562
|
+
mType: 'consult',
|
|
563
|
+
isHold: false,
|
|
564
|
+
holdTimestamp: null,
|
|
565
|
+
},
|
|
566
|
+
},
|
|
567
|
+
},
|
|
568
|
+
});
|
|
569
|
+
expect(
|
|
570
|
+
guards.isInteractionConsulting(createParams(ctx, createEventWithTaskData(taskData)))
|
|
571
|
+
).toBe(true);
|
|
572
|
+
});
|
|
573
|
+
|
|
574
|
+
it('returns false for post_call without consult media', () => {
|
|
575
|
+
const ctx = createContext();
|
|
576
|
+
const taskData = createTaskData({
|
|
577
|
+
interaction: {
|
|
578
|
+
...createTaskData().interaction,
|
|
579
|
+
state: 'post_call',
|
|
580
|
+
participants: {
|
|
581
|
+
'agent-123': {
|
|
582
|
+
...createParticipant('agent-123', 'Agent'),
|
|
583
|
+
consultState: undefined,
|
|
584
|
+
},
|
|
585
|
+
},
|
|
586
|
+
},
|
|
587
|
+
});
|
|
588
|
+
expect(
|
|
589
|
+
guards.isInteractionConsulting(createParams(ctx, createEventWithTaskData(taskData)))
|
|
590
|
+
).toBe(false);
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
it('returns false for plain connected state without consult CPD', () => {
|
|
594
|
+
const ctx = createContext();
|
|
595
|
+
const taskData = createTaskData({
|
|
596
|
+
interaction: {
|
|
597
|
+
...createTaskData().interaction,
|
|
598
|
+
state: 'connected',
|
|
599
|
+
},
|
|
600
|
+
});
|
|
601
|
+
expect(
|
|
602
|
+
guards.isInteractionConsulting(createParams(ctx, createEventWithTaskData(taskData)))
|
|
603
|
+
).toBe(false);
|
|
604
|
+
});
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
describe('didCurrentAgentLeaveMainInteraction', () => {
|
|
608
|
+
const activeTaskData = createTaskData({
|
|
609
|
+
interaction: {
|
|
610
|
+
...createTaskData().interaction,
|
|
611
|
+
participants: {
|
|
612
|
+
'agent-123': createParticipant('agent-123', 'Agent'),
|
|
613
|
+
'agent-456': createParticipant('agent-456', 'Agent'),
|
|
614
|
+
},
|
|
615
|
+
media: {
|
|
616
|
+
'non-interaction-main-key': {
|
|
617
|
+
mediaResourceId: INTERACTION_ID,
|
|
618
|
+
mediaType: 'telephony',
|
|
619
|
+
mediaMgr: 'media-mgr',
|
|
620
|
+
participants: ['agent-123', 'agent-456'],
|
|
621
|
+
mType: 'mainCall',
|
|
622
|
+
isHold: false,
|
|
623
|
+
holdTimestamp: null,
|
|
624
|
+
},
|
|
625
|
+
},
|
|
626
|
+
},
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
it('returns true when the lifecycle event explicitly names the current agent', () => {
|
|
630
|
+
const context = createContext({taskData: activeTaskData});
|
|
631
|
+
const event = {
|
|
632
|
+
...createEventWithTaskData(activeTaskData),
|
|
633
|
+
participantId: 'agent-123',
|
|
634
|
+
} as TaskEventPayload;
|
|
635
|
+
|
|
636
|
+
expect(guards.didCurrentAgentLeaveMainInteraction(createParams(context, event))).toBe(true);
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
it('returns false when the current participant is marked hasLeft but remains in the map', () => {
|
|
640
|
+
const context = createContext({taskData: activeTaskData});
|
|
641
|
+
const updatedTaskData = createTaskData({
|
|
642
|
+
interaction: {
|
|
643
|
+
...activeTaskData.interaction,
|
|
644
|
+
participants: {
|
|
645
|
+
...activeTaskData.interaction.participants,
|
|
646
|
+
'agent-123': createParticipant('agent-123', 'Agent', true),
|
|
647
|
+
},
|
|
648
|
+
},
|
|
649
|
+
});
|
|
650
|
+
|
|
651
|
+
expect(
|
|
652
|
+
guards.didCurrentAgentLeaveMainInteraction(
|
|
653
|
+
createParams(context, createEventWithTaskData(updatedTaskData))
|
|
654
|
+
)
|
|
655
|
+
).toBe(false);
|
|
656
|
+
});
|
|
657
|
+
|
|
658
|
+
it('does not infer departure from CONSULT_END mainCall membership', () => {
|
|
659
|
+
const context = createContext({taskData: activeTaskData, consultFromConference: true});
|
|
660
|
+
const updatedTaskData = createTaskData({
|
|
661
|
+
interaction: {
|
|
662
|
+
...activeTaskData.interaction,
|
|
663
|
+
participants: activeTaskData.interaction.participants,
|
|
664
|
+
media: {
|
|
665
|
+
'another-arbitrary-key': {
|
|
666
|
+
mediaResourceId: INTERACTION_ID,
|
|
667
|
+
mediaType: 'telephony',
|
|
668
|
+
mediaMgr: 'media-mgr',
|
|
669
|
+
participants: ['agent-456'],
|
|
670
|
+
mType: 'mainCall',
|
|
671
|
+
isHold: false,
|
|
672
|
+
holdTimestamp: null,
|
|
673
|
+
},
|
|
674
|
+
'consult-media-key': {
|
|
675
|
+
mediaResourceId: 'consult-media-id',
|
|
676
|
+
mediaType: 'telephony',
|
|
677
|
+
mediaMgr: 'media-mgr',
|
|
678
|
+
participants: ['agent-123', 'agent-789'],
|
|
679
|
+
mType: 'consult',
|
|
680
|
+
isHold: false,
|
|
681
|
+
holdTimestamp: null,
|
|
682
|
+
},
|
|
683
|
+
},
|
|
684
|
+
},
|
|
685
|
+
});
|
|
686
|
+
const event = {
|
|
687
|
+
type: TaskEvent.CONSULT_END,
|
|
688
|
+
taskData: updatedTaskData,
|
|
689
|
+
} as TaskEventPayload;
|
|
690
|
+
|
|
691
|
+
expect(
|
|
692
|
+
guards.didCurrentAgentLeaveMainInteraction(createParams(context, event))
|
|
693
|
+
).toBe(false);
|
|
694
|
+
});
|
|
695
|
+
|
|
696
|
+
it('returns true when another participant leaves and the map omits self', () => {
|
|
697
|
+
const context = createContext({taskData: activeTaskData});
|
|
698
|
+
const partialTaskData = createTaskData({
|
|
699
|
+
interaction: {
|
|
700
|
+
...activeTaskData.interaction,
|
|
701
|
+
participants: {'agent-456': createParticipant('agent-456', 'Agent')},
|
|
702
|
+
media: {
|
|
703
|
+
'partial-main-key': {
|
|
704
|
+
mediaResourceId: INTERACTION_ID,
|
|
705
|
+
mediaType: 'telephony',
|
|
706
|
+
mediaMgr: 'media-mgr',
|
|
707
|
+
participants: ['agent-456'],
|
|
708
|
+
mType: 'mainCall',
|
|
709
|
+
isHold: false,
|
|
710
|
+
holdTimestamp: null,
|
|
711
|
+
},
|
|
712
|
+
},
|
|
713
|
+
},
|
|
714
|
+
});
|
|
715
|
+
const event = {
|
|
716
|
+
type: TaskEvent.PARTICIPANT_LEAVE,
|
|
717
|
+
participantId: 'agent-456',
|
|
718
|
+
taskData: partialTaskData,
|
|
719
|
+
} as TaskEventPayload;
|
|
720
|
+
|
|
721
|
+
expect(guards.didCurrentAgentLeaveMainInteraction(createParams(context, event))).toBe(true);
|
|
722
|
+
});
|
|
723
|
+
|
|
724
|
+
it.each(['connected', 'held'])(
|
|
725
|
+
'does not infer departure from a partial CONSULT_END snapshot while %s',
|
|
726
|
+
(state) => {
|
|
727
|
+
const previousTaskData = createTaskData({
|
|
728
|
+
...activeTaskData,
|
|
729
|
+
interaction: {...activeTaskData.interaction, state},
|
|
730
|
+
});
|
|
731
|
+
const context = createContext({taskData: previousTaskData});
|
|
732
|
+
const partialTaskData = createTaskData({
|
|
733
|
+
interaction: {
|
|
734
|
+
...previousTaskData.interaction,
|
|
735
|
+
participants: previousTaskData.interaction.participants,
|
|
736
|
+
media: {
|
|
737
|
+
'partial-main-key': {
|
|
738
|
+
mediaResourceId: INTERACTION_ID,
|
|
739
|
+
mediaType: 'telephony',
|
|
740
|
+
mediaMgr: 'media-mgr',
|
|
741
|
+
participants: ['agent-456'],
|
|
742
|
+
mType: 'mainCall',
|
|
743
|
+
isHold: state === 'held',
|
|
744
|
+
holdTimestamp: state === 'held' ? Date.now() : null,
|
|
745
|
+
},
|
|
746
|
+
},
|
|
747
|
+
},
|
|
748
|
+
});
|
|
749
|
+
const event = {type: TaskEvent.CONSULT_END, taskData: partialTaskData} as TaskEventPayload;
|
|
750
|
+
|
|
751
|
+
expect(guards.didCurrentAgentLeaveMainInteraction(createParams(context, event))).toBe(
|
|
752
|
+
false
|
|
753
|
+
);
|
|
754
|
+
}
|
|
755
|
+
);
|
|
756
|
+
|
|
757
|
+
it('returns true when an active current participant disappears from the updated map', () => {
|
|
758
|
+
const context = createContext({taskData: activeTaskData});
|
|
759
|
+
const updatedTaskData = createTaskData({
|
|
760
|
+
interaction: {
|
|
761
|
+
...activeTaskData.interaction,
|
|
762
|
+
participants: {'agent-456': createParticipant('agent-456', 'Agent')},
|
|
763
|
+
media: activeTaskData.interaction.media,
|
|
764
|
+
},
|
|
765
|
+
});
|
|
766
|
+
|
|
767
|
+
expect(
|
|
768
|
+
guards.didCurrentAgentLeaveMainInteraction(
|
|
769
|
+
createParams(context, createEventWithTaskData(updatedTaskData))
|
|
770
|
+
)
|
|
771
|
+
).toBe(true);
|
|
772
|
+
});
|
|
773
|
+
|
|
774
|
+
it('does not infer departure from missing partial interaction membership', () => {
|
|
775
|
+
const context = createContext({taskData: activeTaskData});
|
|
776
|
+
const partialTaskData = createTaskData({
|
|
777
|
+
interaction: {
|
|
778
|
+
interactionId: INTERACTION_ID,
|
|
779
|
+
mainInteractionId: INTERACTION_ID,
|
|
780
|
+
state: 'conference',
|
|
781
|
+
} as TaskData['interaction'],
|
|
782
|
+
});
|
|
783
|
+
|
|
784
|
+
expect(
|
|
785
|
+
guards.didCurrentAgentLeaveMainInteraction(
|
|
786
|
+
createParams(context, createEventWithTaskData(partialTaskData))
|
|
787
|
+
)
|
|
788
|
+
).toBe(false);
|
|
789
|
+
});
|
|
790
|
+
});
|
|
791
|
+
|
|
792
|
+
describe('Server State Guards', () => {
|
|
793
|
+
it('isPrimaryMediaOnHold returns true when media isHold is true', () => {
|
|
794
|
+
const ctx = createContext();
|
|
795
|
+
const taskData = createTaskData({
|
|
796
|
+
interaction: {
|
|
797
|
+
...createTaskData().interaction,
|
|
798
|
+
media: {
|
|
799
|
+
[INTERACTION_ID]: {
|
|
800
|
+
mediaResourceId: INTERACTION_ID,
|
|
801
|
+
mediaType: 'telephony',
|
|
802
|
+
mediaMgr: 'media-mgr',
|
|
803
|
+
participants: ['agent-123'],
|
|
804
|
+
mType: 'mainCall',
|
|
805
|
+
isHold: true,
|
|
806
|
+
holdTimestamp: Date.now(),
|
|
807
|
+
},
|
|
808
|
+
},
|
|
809
|
+
},
|
|
810
|
+
});
|
|
811
|
+
expect(
|
|
812
|
+
guards.isPrimaryMediaOnHold(createParams(ctx, createEventWithTaskData(taskData)))
|
|
813
|
+
).toBe(true);
|
|
814
|
+
});
|
|
815
|
+
|
|
816
|
+
it('isPrimaryMediaOnHold returns false when media isHold is false', () => {
|
|
817
|
+
const ctx = createContext();
|
|
818
|
+
const taskData = createTaskData({
|
|
819
|
+
interaction: {
|
|
820
|
+
...createTaskData().interaction,
|
|
821
|
+
media: {
|
|
822
|
+
[INTERACTION_ID]: {
|
|
823
|
+
mediaResourceId: INTERACTION_ID,
|
|
824
|
+
mediaType: 'telephony',
|
|
825
|
+
mediaMgr: 'media-mgr',
|
|
826
|
+
participants: ['agent-123'],
|
|
827
|
+
mType: 'mainCall',
|
|
828
|
+
isHold: false,
|
|
829
|
+
holdTimestamp: null,
|
|
830
|
+
},
|
|
831
|
+
},
|
|
832
|
+
},
|
|
833
|
+
});
|
|
834
|
+
expect(
|
|
835
|
+
guards.isPrimaryMediaOnHold(createParams(ctx, createEventWithTaskData(taskData)))
|
|
836
|
+
).toBe(false);
|
|
837
|
+
});
|
|
838
|
+
});
|
|
839
|
+
});
|