@webex/contact-center 3.10.0-next.9 → 3.10.0-wxc-disconnect.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cc.js +1 -12
- package/dist/cc.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/services/config/types.js +2 -2
- package/dist/services/config/types.js.map +1 -1
- package/dist/services/core/Utils.js +71 -90
- package/dist/services/core/Utils.js.map +1 -1
- package/dist/services/core/constants.js +1 -17
- package/dist/services/core/constants.js.map +1 -1
- package/dist/services/task/TaskManager.js +17 -89
- package/dist/services/task/TaskManager.js.map +1 -1
- package/dist/services/task/constants.js +1 -20
- package/dist/services/task/constants.js.map +1 -1
- package/dist/services/task/index.js +98 -123
- package/dist/services/task/index.js.map +1 -1
- package/dist/services/task/types.js +4 -2
- package/dist/services/task/types.js.map +1 -1
- package/dist/types/cc.d.ts +0 -6
- package/dist/types/index.d.ts +1 -1
- package/dist/types/services/config/types.d.ts +4 -4
- package/dist/types/services/core/Utils.d.ts +17 -32
- package/dist/types/services/core/constants.d.ts +0 -14
- package/dist/types/services/task/constants.d.ts +0 -17
- package/dist/types/services/task/index.d.ts +2 -41
- package/dist/types/services/task/types.d.ts +33 -133
- package/dist/webex.js +1 -1
- package/package.json +9 -9
- package/src/cc.ts +1 -12
- package/src/index.ts +0 -1
- package/src/services/config/types.ts +2 -2
- package/src/services/core/Utils.ts +85 -101
- package/src/services/core/constants.ts +0 -16
- package/src/services/task/TaskManager.ts +15 -112
- package/src/services/task/constants.ts +0 -19
- package/src/services/task/index.ts +82 -108
- package/src/services/task/types.ts +33 -142
- package/test/unit/spec/services/core/Utils.ts +31 -262
- package/test/unit/spec/services/task/TaskManager.ts +6 -620
- package/test/unit/spec/services/task/index.ts +79 -502
- package/umd/contact-center.min.js +2 -2
- package/umd/contact-center.min.js.map +1 -1
- package/dist/services/task/TaskUtils.js +0 -104
- package/dist/services/task/TaskUtils.js.map +0 -1
- package/dist/types/services/task/TaskUtils.d.ts +0 -42
- package/src/services/task/TaskUtils.ts +0 -113
- package/test/unit/spec/services/task/TaskUtils.ts +0 -131
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isSecondaryEpDnAgent = exports.isSecondaryAgent = exports.isPrimary = exports.isParticipantInMainInteraction = exports.getIsConferenceInProgress = exports.checkParticipantNotInInteraction = void 0;
|
|
7
|
-
/* eslint-disable import/prefer-default-export */
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Determines if the given agent is the primary agent (owner) of the task
|
|
11
|
-
* @param task - The task to check
|
|
12
|
-
* @param agentId - The agent ID to check for primary status
|
|
13
|
-
* @returns true if the agent is the primary agent, false otherwise
|
|
14
|
-
*/
|
|
15
|
-
const isPrimary = (task, agentId) => {
|
|
16
|
-
if (!task.data?.interaction?.owner) {
|
|
17
|
-
// Fall back to checking data.agentId when owner is not set
|
|
18
|
-
return task.data.agentId === agentId;
|
|
19
|
-
}
|
|
20
|
-
return task.data.interaction.owner === agentId;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Checks if the given agent is a participant in the main interaction (mainCall)
|
|
25
|
-
* @param task - The task to check
|
|
26
|
-
* @param agentId - The agent ID to check for participation
|
|
27
|
-
* @returns true if the agent is a participant in the main interaction, false otherwise
|
|
28
|
-
*/
|
|
29
|
-
exports.isPrimary = isPrimary;
|
|
30
|
-
const isParticipantInMainInteraction = (task, agentId) => {
|
|
31
|
-
if (!task?.data?.interaction?.media) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
return Object.values(task.data.interaction.media).some(mediaObj => mediaObj && mediaObj.mType === 'mainCall' && mediaObj.participants?.includes(agentId));
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Checks if the given agent is not in the interaction or has left the interaction
|
|
39
|
-
* @param task - The task to check
|
|
40
|
-
* @param agentId - The agent ID to check
|
|
41
|
-
* @returns true if the agent is not in the interaction or has left, false otherwise
|
|
42
|
-
*/
|
|
43
|
-
exports.isParticipantInMainInteraction = isParticipantInMainInteraction;
|
|
44
|
-
const checkParticipantNotInInteraction = (task, agentId) => {
|
|
45
|
-
if (!task?.data?.interaction?.participants) {
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
const {
|
|
49
|
-
data
|
|
50
|
-
} = task;
|
|
51
|
-
return !(agentId in data.interaction.participants) || agentId in data.interaction.participants && data.interaction.participants[agentId].hasLeft;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Determines if a conference is currently in progress based on the number of active agent participants
|
|
56
|
-
* @param TaskData - The payLoad data to check for conference status
|
|
57
|
-
* @returns true if there are 2 or more active agent participants in the main call, false otherwise
|
|
58
|
-
*/
|
|
59
|
-
exports.checkParticipantNotInInteraction = checkParticipantNotInInteraction;
|
|
60
|
-
const getIsConferenceInProgress = data => {
|
|
61
|
-
const mediaMainCall = data.interaction.media?.[data?.interactionId];
|
|
62
|
-
const participantsInMainCall = new Set(mediaMainCall?.participants);
|
|
63
|
-
const participants = data.interaction.participants;
|
|
64
|
-
const agentParticipants = new Set();
|
|
65
|
-
if (participantsInMainCall.size > 0) {
|
|
66
|
-
participantsInMainCall.forEach(participantId => {
|
|
67
|
-
const participant = participants?.[participantId];
|
|
68
|
-
if (participant && participant.pType !== 'Customer' && participant.pType !== 'Supervisor' && !participant.hasLeft && participant.pType !== 'VVA') {
|
|
69
|
-
agentParticipants.add(participantId);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
return agentParticipants.size >= 2;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Checks if the current agent is a secondary agent in a consultation scenario.
|
|
78
|
-
* Secondary agents are those who were consulted (not the original call owner).
|
|
79
|
-
* @param task - The task object containing interaction details
|
|
80
|
-
* @returns true if this is a secondary agent (consulted party), false otherwise
|
|
81
|
-
*/
|
|
82
|
-
exports.getIsConferenceInProgress = getIsConferenceInProgress;
|
|
83
|
-
const isSecondaryAgent = interaction => {
|
|
84
|
-
if (!interaction.callProcessingDetails) {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
return interaction.callProcessingDetails.relationshipType === 'consult' && !!interaction.callProcessingDetails.parentInteractionId && interaction.callProcessingDetails.parentInteractionId !== interaction.interactionId;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Checks if the current agent is a secondary EP-DN (Entry Point Dial Number) agent.
|
|
92
|
-
* This is specifically for telephony consultations to external numbers/entry points.
|
|
93
|
-
* @param task - The task object containing interaction details
|
|
94
|
-
* @returns true if this is a secondary EP-DN agent in telephony consultation, false otherwise
|
|
95
|
-
*/
|
|
96
|
-
exports.isSecondaryAgent = isSecondaryAgent;
|
|
97
|
-
const isSecondaryEpDnAgent = interaction => {
|
|
98
|
-
if (!interaction) {
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
return interaction.mediaType === 'telephony' && isSecondaryAgent(interaction);
|
|
102
|
-
};
|
|
103
|
-
exports.isSecondaryEpDnAgent = isSecondaryEpDnAgent;
|
|
104
|
-
//# sourceMappingURL=TaskUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["isPrimary","task","agentId","data","interaction","owner","exports","isParticipantInMainInteraction","media","Object","values","some","mediaObj","mType","participants","includes","checkParticipantNotInInteraction","hasLeft","getIsConferenceInProgress","mediaMainCall","interactionId","participantsInMainCall","Set","agentParticipants","size","forEach","participantId","participant","pType","add","isSecondaryAgent","callProcessingDetails","relationshipType","parentInteractionId","isSecondaryEpDnAgent","mediaType"],"sources":["TaskUtils.ts"],"sourcesContent":["/* eslint-disable import/prefer-default-export */\nimport {Interaction, ITask, TaskData} from './types';\n\n/**\n * Determines if the given agent is the primary agent (owner) of the task\n * @param task - The task to check\n * @param agentId - The agent ID to check for primary status\n * @returns true if the agent is the primary agent, false otherwise\n */\nexport const isPrimary = (task: ITask, agentId: string): boolean => {\n if (!task.data?.interaction?.owner) {\n // Fall back to checking data.agentId when owner is not set\n return task.data.agentId === agentId;\n }\n\n return task.data.interaction.owner === agentId;\n};\n\n/**\n * Checks if the given agent is a participant in the main interaction (mainCall)\n * @param task - The task to check\n * @param agentId - The agent ID to check for participation\n * @returns true if the agent is a participant in the main interaction, false otherwise\n */\nexport const isParticipantInMainInteraction = (task: ITask, agentId: string): boolean => {\n if (!task?.data?.interaction?.media) {\n return false;\n }\n\n return Object.values(task.data.interaction.media).some(\n (mediaObj) =>\n mediaObj && mediaObj.mType === 'mainCall' && mediaObj.participants?.includes(agentId)\n );\n};\n\n/**\n * Checks if the given agent is not in the interaction or has left the interaction\n * @param task - The task to check\n * @param agentId - The agent ID to check\n * @returns true if the agent is not in the interaction or has left, false otherwise\n */\nexport const checkParticipantNotInInteraction = (task: ITask, agentId: string): boolean => {\n if (!task?.data?.interaction?.participants) {\n return true;\n }\n const {data} = task;\n\n return (\n !(agentId in data.interaction.participants) ||\n (agentId in data.interaction.participants && data.interaction.participants[agentId].hasLeft)\n );\n};\n\n/**\n * Determines if a conference is currently in progress based on the number of active agent participants\n * @param TaskData - The payLoad data to check for conference status\n * @returns true if there are 2 or more active agent participants in the main call, false otherwise\n */\nexport const getIsConferenceInProgress = (data: TaskData): boolean => {\n const mediaMainCall = data.interaction.media?.[data?.interactionId];\n const participantsInMainCall = new Set(mediaMainCall?.participants);\n const participants = data.interaction.participants;\n\n const agentParticipants = new Set();\n if (participantsInMainCall.size > 0) {\n participantsInMainCall.forEach((participantId: string) => {\n const participant = participants?.[participantId];\n if (\n participant &&\n participant.pType !== 'Customer' &&\n participant.pType !== 'Supervisor' &&\n !participant.hasLeft &&\n participant.pType !== 'VVA'\n ) {\n agentParticipants.add(participantId);\n }\n });\n }\n\n return agentParticipants.size >= 2;\n};\n\n/**\n * Checks if the current agent is a secondary agent in a consultation scenario.\n * Secondary agents are those who were consulted (not the original call owner).\n * @param task - The task object containing interaction details\n * @returns true if this is a secondary agent (consulted party), false otherwise\n */\nexport const isSecondaryAgent = (interaction: Interaction): boolean => {\n if (!interaction.callProcessingDetails) {\n return false;\n }\n\n return (\n interaction.callProcessingDetails.relationshipType === 'consult' &&\n !!interaction.callProcessingDetails.parentInteractionId &&\n interaction.callProcessingDetails.parentInteractionId !== interaction.interactionId\n );\n};\n\n/**\n * Checks if the current agent is a secondary EP-DN (Entry Point Dial Number) agent.\n * This is specifically for telephony consultations to external numbers/entry points.\n * @param task - The task object containing interaction details\n * @returns true if this is a secondary EP-DN agent in telephony consultation, false otherwise\n */\nexport const isSecondaryEpDnAgent = (interaction: Interaction): boolean => {\n if (!interaction) {\n return false;\n }\n\n return interaction.mediaType === 'telephony' && isSecondaryAgent(interaction);\n};\n"],"mappings":"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"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Interaction, ITask, TaskData } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Determines if the given agent is the primary agent (owner) of the task
|
|
4
|
-
* @param task - The task to check
|
|
5
|
-
* @param agentId - The agent ID to check for primary status
|
|
6
|
-
* @returns true if the agent is the primary agent, false otherwise
|
|
7
|
-
*/
|
|
8
|
-
export declare const isPrimary: (task: ITask, agentId: string) => boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Checks if the given agent is a participant in the main interaction (mainCall)
|
|
11
|
-
* @param task - The task to check
|
|
12
|
-
* @param agentId - The agent ID to check for participation
|
|
13
|
-
* @returns true if the agent is a participant in the main interaction, false otherwise
|
|
14
|
-
*/
|
|
15
|
-
export declare const isParticipantInMainInteraction: (task: ITask, agentId: string) => boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Checks if the given agent is not in the interaction or has left the interaction
|
|
18
|
-
* @param task - The task to check
|
|
19
|
-
* @param agentId - The agent ID to check
|
|
20
|
-
* @returns true if the agent is not in the interaction or has left, false otherwise
|
|
21
|
-
*/
|
|
22
|
-
export declare const checkParticipantNotInInteraction: (task: ITask, agentId: string) => boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Determines if a conference is currently in progress based on the number of active agent participants
|
|
25
|
-
* @param TaskData - The payLoad data to check for conference status
|
|
26
|
-
* @returns true if there are 2 or more active agent participants in the main call, false otherwise
|
|
27
|
-
*/
|
|
28
|
-
export declare const getIsConferenceInProgress: (data: TaskData) => boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Checks if the current agent is a secondary agent in a consultation scenario.
|
|
31
|
-
* Secondary agents are those who were consulted (not the original call owner).
|
|
32
|
-
* @param task - The task object containing interaction details
|
|
33
|
-
* @returns true if this is a secondary agent (consulted party), false otherwise
|
|
34
|
-
*/
|
|
35
|
-
export declare const isSecondaryAgent: (interaction: Interaction) => boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Checks if the current agent is a secondary EP-DN (Entry Point Dial Number) agent.
|
|
38
|
-
* This is specifically for telephony consultations to external numbers/entry points.
|
|
39
|
-
* @param task - The task object containing interaction details
|
|
40
|
-
* @returns true if this is a secondary EP-DN agent in telephony consultation, false otherwise
|
|
41
|
-
*/
|
|
42
|
-
export declare const isSecondaryEpDnAgent: (interaction: Interaction) => boolean;
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/prefer-default-export */
|
|
2
|
-
import {Interaction, ITask, TaskData} from './types';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Determines if the given agent is the primary agent (owner) of the task
|
|
6
|
-
* @param task - The task to check
|
|
7
|
-
* @param agentId - The agent ID to check for primary status
|
|
8
|
-
* @returns true if the agent is the primary agent, false otherwise
|
|
9
|
-
*/
|
|
10
|
-
export const isPrimary = (task: ITask, agentId: string): boolean => {
|
|
11
|
-
if (!task.data?.interaction?.owner) {
|
|
12
|
-
// Fall back to checking data.agentId when owner is not set
|
|
13
|
-
return task.data.agentId === agentId;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return task.data.interaction.owner === agentId;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Checks if the given agent is a participant in the main interaction (mainCall)
|
|
21
|
-
* @param task - The task to check
|
|
22
|
-
* @param agentId - The agent ID to check for participation
|
|
23
|
-
* @returns true if the agent is a participant in the main interaction, false otherwise
|
|
24
|
-
*/
|
|
25
|
-
export const isParticipantInMainInteraction = (task: ITask, agentId: string): boolean => {
|
|
26
|
-
if (!task?.data?.interaction?.media) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return Object.values(task.data.interaction.media).some(
|
|
31
|
-
(mediaObj) =>
|
|
32
|
-
mediaObj && mediaObj.mType === 'mainCall' && mediaObj.participants?.includes(agentId)
|
|
33
|
-
);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Checks if the given agent is not in the interaction or has left the interaction
|
|
38
|
-
* @param task - The task to check
|
|
39
|
-
* @param agentId - The agent ID to check
|
|
40
|
-
* @returns true if the agent is not in the interaction or has left, false otherwise
|
|
41
|
-
*/
|
|
42
|
-
export const checkParticipantNotInInteraction = (task: ITask, agentId: string): boolean => {
|
|
43
|
-
if (!task?.data?.interaction?.participants) {
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
const {data} = task;
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
!(agentId in data.interaction.participants) ||
|
|
50
|
-
(agentId in data.interaction.participants && data.interaction.participants[agentId].hasLeft)
|
|
51
|
-
);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Determines if a conference is currently in progress based on the number of active agent participants
|
|
56
|
-
* @param TaskData - The payLoad data to check for conference status
|
|
57
|
-
* @returns true if there are 2 or more active agent participants in the main call, false otherwise
|
|
58
|
-
*/
|
|
59
|
-
export const getIsConferenceInProgress = (data: TaskData): boolean => {
|
|
60
|
-
const mediaMainCall = data.interaction.media?.[data?.interactionId];
|
|
61
|
-
const participantsInMainCall = new Set(mediaMainCall?.participants);
|
|
62
|
-
const participants = data.interaction.participants;
|
|
63
|
-
|
|
64
|
-
const agentParticipants = new Set();
|
|
65
|
-
if (participantsInMainCall.size > 0) {
|
|
66
|
-
participantsInMainCall.forEach((participantId: string) => {
|
|
67
|
-
const participant = participants?.[participantId];
|
|
68
|
-
if (
|
|
69
|
-
participant &&
|
|
70
|
-
participant.pType !== 'Customer' &&
|
|
71
|
-
participant.pType !== 'Supervisor' &&
|
|
72
|
-
!participant.hasLeft &&
|
|
73
|
-
participant.pType !== 'VVA'
|
|
74
|
-
) {
|
|
75
|
-
agentParticipants.add(participantId);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return agentParticipants.size >= 2;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Checks if the current agent is a secondary agent in a consultation scenario.
|
|
85
|
-
* Secondary agents are those who were consulted (not the original call owner).
|
|
86
|
-
* @param task - The task object containing interaction details
|
|
87
|
-
* @returns true if this is a secondary agent (consulted party), false otherwise
|
|
88
|
-
*/
|
|
89
|
-
export const isSecondaryAgent = (interaction: Interaction): boolean => {
|
|
90
|
-
if (!interaction.callProcessingDetails) {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return (
|
|
95
|
-
interaction.callProcessingDetails.relationshipType === 'consult' &&
|
|
96
|
-
!!interaction.callProcessingDetails.parentInteractionId &&
|
|
97
|
-
interaction.callProcessingDetails.parentInteractionId !== interaction.interactionId
|
|
98
|
-
);
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Checks if the current agent is a secondary EP-DN (Entry Point Dial Number) agent.
|
|
103
|
-
* This is specifically for telephony consultations to external numbers/entry points.
|
|
104
|
-
* @param task - The task object containing interaction details
|
|
105
|
-
* @returns true if this is a secondary EP-DN agent in telephony consultation, false otherwise
|
|
106
|
-
*/
|
|
107
|
-
export const isSecondaryEpDnAgent = (interaction: Interaction): boolean => {
|
|
108
|
-
if (!interaction) {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return interaction.mediaType === 'telephony' && isSecondaryAgent(interaction);
|
|
113
|
-
};
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { checkParticipantNotInInteraction,
|
|
2
|
-
getIsConferenceInProgress,
|
|
3
|
-
isParticipantInMainInteraction,
|
|
4
|
-
isPrimary,} from '../../../../../src/services/task/TaskUtils';
|
|
5
|
-
import {ITask} from '../../../../../src/services/task/types';
|
|
6
|
-
|
|
7
|
-
describe('TaskUtils', () => {
|
|
8
|
-
let mockTask: ITask;
|
|
9
|
-
const mockAgentId = 'agent-123';
|
|
10
|
-
const mockOtherAgentId = 'agent-456';
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
mockTask = {
|
|
14
|
-
data: {
|
|
15
|
-
interactionId: 'interaction-123',
|
|
16
|
-
agentId: mockAgentId,
|
|
17
|
-
interaction: {
|
|
18
|
-
owner: mockAgentId,
|
|
19
|
-
participants: {
|
|
20
|
-
[mockAgentId]: { hasLeft: false },
|
|
21
|
-
[mockOtherAgentId]: { hasLeft: false },
|
|
22
|
-
},
|
|
23
|
-
media: {
|
|
24
|
-
'media-1': {
|
|
25
|
-
mType: 'mainCall',
|
|
26
|
-
participants: [mockAgentId, mockOtherAgentId],
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
emit: jest.fn(),
|
|
32
|
-
updateTaskData: jest.fn(),
|
|
33
|
-
} as any;
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
describe('isPrimary', () => {
|
|
37
|
-
it('should return true when agent is the owner', () => {
|
|
38
|
-
expect(isPrimary(mockTask, mockAgentId)).toBe(true);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('should return false when agent is not the owner', () => {
|
|
42
|
-
expect(isPrimary(mockTask, mockOtherAgentId)).toBe(false);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('should fallback to data.agentId when owner is not set', () => {
|
|
46
|
-
mockTask.data.interaction.owner = undefined;
|
|
47
|
-
expect(isPrimary(mockTask, mockAgentId)).toBe(true);
|
|
48
|
-
expect(isPrimary(mockTask, mockOtherAgentId)).toBe(false);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
describe('isParticipantInMainInteraction', () => {
|
|
53
|
-
it('should return true when agent is in mainCall media', () => {
|
|
54
|
-
expect(isParticipantInMainInteraction(mockTask, mockAgentId)).toBe(true);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('should return false when agent is not in mainCall media', () => {
|
|
58
|
-
mockTask.data.interaction.media['media-1'].participants = [mockOtherAgentId];
|
|
59
|
-
expect(isParticipantInMainInteraction(mockTask, mockAgentId)).toBe(false);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('should return false when no mainCall media exists', () => {
|
|
63
|
-
mockTask.data.interaction.media['media-1'].mType = 'consult';
|
|
64
|
-
expect(isParticipantInMainInteraction(mockTask, mockAgentId)).toBe(false);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
describe('checkParticipantNotInInteraction', () => {
|
|
69
|
-
it('should return false when agent is active participant', () => {
|
|
70
|
-
expect(checkParticipantNotInInteraction(mockTask, mockAgentId)).toBe(false);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('should return true when agent is not in participants', () => {
|
|
74
|
-
delete mockTask.data.interaction.participants[mockAgentId];
|
|
75
|
-
expect(checkParticipantNotInInteraction(mockTask, mockAgentId)).toBe(true);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('should return true when agent has left', () => {
|
|
79
|
-
mockTask.data.interaction.participants[mockAgentId].hasLeft = true;
|
|
80
|
-
expect(checkParticipantNotInInteraction(mockTask, mockAgentId)).toBe(true);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
describe('getIsConferenceInProgress', () => {
|
|
85
|
-
beforeEach(() => {
|
|
86
|
-
// Set up mock task with proper media structure for conference detection
|
|
87
|
-
mockTask.data.interaction.media = {
|
|
88
|
-
[mockTask.data.interactionId]: {
|
|
89
|
-
mType: 'mainCall',
|
|
90
|
-
participants: [mockAgentId, mockOtherAgentId, 'customer-123'],
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
mockTask.data.interaction.participants = {
|
|
94
|
-
[mockAgentId]: { pType: 'Agent', hasLeft: false },
|
|
95
|
-
[mockOtherAgentId]: { pType: 'Agent', hasLeft: false },
|
|
96
|
-
'customer-123': { pType: 'Customer', hasLeft: false },
|
|
97
|
-
};
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('should return true when there are 2 or more active agents', () => {
|
|
101
|
-
expect(getIsConferenceInProgress(mockTask.data)).toBe(true);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('should return false when there is only 1 active agent', () => {
|
|
105
|
-
mockTask.data.interaction.participants[mockOtherAgentId].hasLeft = true;
|
|
106
|
-
expect(getIsConferenceInProgress(mockTask.data)).toBe(false);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('should exclude customers from agent count', () => {
|
|
110
|
-
// Remove one agent, should still be false with only 1 agent + customer
|
|
111
|
-
delete mockTask.data.interaction.participants[mockOtherAgentId];
|
|
112
|
-
mockTask.data.interaction.media[mockTask.data.interactionId].participants = [mockAgentId, 'customer-123'];
|
|
113
|
-
expect(getIsConferenceInProgress(mockTask.data)).toBe(false);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it('should exclude supervisors from agent count', () => {
|
|
117
|
-
mockTask.data.interaction.participants[mockOtherAgentId].pType = 'Supervisor';
|
|
118
|
-
expect(getIsConferenceInProgress(mockTask.data)).toBe(false);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('should exclude VVA from agent count', () => {
|
|
122
|
-
mockTask.data.interaction.participants[mockOtherAgentId].pType = 'VVA';
|
|
123
|
-
expect(getIsConferenceInProgress(mockTask.data)).toBe(false);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it('should return false when no main call media exists', () => {
|
|
127
|
-
mockTask.data.interaction.media = {};
|
|
128
|
-
expect(getIsConferenceInProgress(mockTask.data)).toBe(false);
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
});
|