@webex/contact-center 3.9.0-next.3 → 3.9.0-next.5

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.
@@ -276,4 +276,54 @@ describe('Utils', () => {
276
276
  });
277
277
  });
278
278
  });
279
+
280
+ describe('getDestinationAgentId', () => {
281
+ const currentAgentId = 'agent-current-123';
282
+
283
+ it('returns another Agent id when present and not in wrap-up', () => {
284
+ const participants: any = {
285
+ [currentAgentId]: {type: 'Agent', id: currentAgentId, isWrapUp: false},
286
+ agent1: {type: 'Agent', id: 'agent-1', isWrapUp: false},
287
+ customer1: {type: 'Customer', id: 'cust-1', isWrapUp: false},
288
+ };
289
+
290
+ const result = Utils.getDestinationAgentId(participants, currentAgentId);
291
+ expect(result).toBe('agent-1');
292
+ });
293
+
294
+ it('ignores self and wrap-up participants', () => {
295
+ const participants: any = {
296
+ [currentAgentId]: {type: 'Agent', id: currentAgentId, isWrapUp: false},
297
+ agentWrap: {type: 'Agent', id: 'agent-wrap', isWrapUp: true},
298
+ };
299
+
300
+ const result = Utils.getDestinationAgentId(participants, currentAgentId);
301
+ expect(result).toBe('');
302
+ });
303
+
304
+ it('supports DN, EpDn and entryPoint types', () => {
305
+ const participantsDN: any = {
306
+ [currentAgentId]: {type: 'Agent', id: currentAgentId, isWrapUp: false},
307
+ dn1: {type: 'DN', id: 'dn-1', isWrapUp: false},
308
+ };
309
+ expect(Utils.getDestinationAgentId(participantsDN, currentAgentId)).toBe('dn-1');
310
+
311
+ const participantsEpDn: any = {
312
+ [currentAgentId]: {type: 'Agent', id: currentAgentId, isWrapUp: false},
313
+ epdn1: {type: 'EpDn', id: 'epdn-1', isWrapUp: false},
314
+ };
315
+ expect(Utils.getDestinationAgentId(participantsEpDn, currentAgentId)).toBe('epdn-1');
316
+
317
+ const participantsEntry: any = {
318
+ [currentAgentId]: {type: 'Agent', id: currentAgentId, isWrapUp: false},
319
+ entry1: {type: 'entryPoint', id: 'entry-1', isWrapUp: false},
320
+ };
321
+ expect(Utils.getDestinationAgentId(participantsEntry, currentAgentId)).toBe('entry-1');
322
+ });
323
+
324
+ it('returns empty string when participants is missing or empty', () => {
325
+ expect(Utils.getDestinationAgentId(undefined as any, currentAgentId)).toBe('');
326
+ expect(Utils.getDestinationAgentId({} as any, currentAgentId)).toBe('');
327
+ });
328
+ });
279
329
  });
@@ -39,6 +39,7 @@ describe('Task', () => {
39
39
  let loggerInfoSpy;
40
40
  let loggerLogSpy;
41
41
  let loggerErrorSpy;
42
+ let getDestinationAgentIdSpy;
42
43
 
43
44
  const taskId = '0ae913a4-c857-4705-8d49-76dd3dde75e4';
44
45
  const mockTrack = {} as MediaStreamTrack;
@@ -141,6 +142,11 @@ describe('Task', () => {
141
142
  },
142
143
  };
143
144
 
145
+ // Mock destination agent id resolution from participants
146
+ getDestinationAgentIdSpy = jest
147
+ .spyOn(Utils, 'getDestinationAgentId')
148
+ .mockReturnValue(taskDataMock.destAgentId);
149
+
144
150
  // Create an instance of Task
145
151
  task = new Task(contactMock, webCallingService, taskDataMock);
146
152
 
@@ -163,6 +169,7 @@ describe('Task', () => {
163
169
 
164
170
  afterEach(() => {
165
171
  jest.clearAllMocks();
172
+ jest.restoreAllMocks();
166
173
  });
167
174
 
168
175
  it('test the on spy', async () => {
@@ -863,6 +870,9 @@ describe('Task', () => {
863
870
  destinationType: CONSULT_TRANSFER_DESTINATION_TYPE.QUEUE,
864
871
  };
865
872
 
873
+ // For this negative case, ensure computed destination is empty
874
+ getDestinationAgentIdSpy.mockReturnValueOnce('');
875
+
866
876
  await expect(
867
877
  taskWithoutDestAgentId.consultTransfer(queueConsultTransferPayload)
868
878
  ).rejects.toThrow('Error while performing consultTransfer');