Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/@webex/plugin-cc/src/services/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const CC_TASK_EVENTS = {
AGENT_OFFER_CONTACT: 'AgentOfferContact',
AGENT_CONTACT_ASSIGNED: 'AgentContactAssigned',
AGENT_CONTACT_UNASSIGNED: 'AgentContactUnassigned',
AGENT_INVITE_FAILED: 'AgentInviteFailed',
} as const;

// Define the CC_AGENT_EVENTS object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export default class TaskManager extends EventEmitter {
task.emit(TASK_EVENTS.TASK_REJECT, payload.data.reason);
break;
case CC_EVENTS.CONTACT_ENDED:
case CC_EVENTS.AGENT_INVITE_FAILED:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might need to emit an event here and so create a TASK_EVENTS.AGENT_INVITE_FAILED ... then we might need to listen to that also.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now this also comes under contact_ended before even answer so we can combine CC_EVENTS.CONTACT_ENDED and CC_EVENTS.AGENT_INVITE_FAILED

task = this.updateTaskData(task, {
...payload.data,
wrapUpRequired: payload.data.interaction.state !== 'new',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,39 @@ describe('TaskManager', () => {
);
});

it('should emit TASK_END event on AGENT_INVITE_FAILED event', () => {
webSocketManagerMock.emit('message', JSON.stringify(initalPayload));

const taskEmitSpy = jest.spyOn(taskManager.getTask(taskId), 'emit');
const payload = {
data: {
type: CC_EVENTS.AGENT_INVITE_FAILED,
agentId: '723a8ffb-a26e-496d-b14a-ff44fb83b64f',
eventTime: 1733211616959,
eventType: 'RoutingMessage',
interaction: {state: 'connected'},
interactionId: taskId,
orgId: '6ecef209-9a34-4ed1-a07a-7ddd1dbe925a',
trackingId: '575c0ec2-618c-42af-a61c-53aeb0a221ee',
mediaResourceId: '0ae913a4-c857-4705-8d49-76dd3dde75e4',
destAgentId: 'ebeb893b-ba67-4f36-8418-95c7492b28c2',
owner: '723a8ffb-a26e-496d-b14a-ff44fb83b64f',
queueMgr: 'aqm',
},
};

taskManager.getTask(taskId).updateTaskData(payload.data);
webSocketManagerMock.emit('message', JSON.stringify(payload));
expect(taskEmitSpy).toHaveBeenCalledWith(
CC_EVENTS.AGENT_INVITE_FAILED,
{ ...payload.data}
);
expect(taskEmitSpy).toHaveBeenCalledWith(
TASK_EVENTS.TASK_END,
taskManager.getTask(taskId)
);
});

it('should emit TASK_HYDRATE event on AGENT_CONTACT event', () => {
const payload = {
data: {
Expand Down
Loading