@webex/contact-center 3.12.0-llmrefactor.6 → 3.12.0-llmrefactor.8

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.
@@ -199,7 +199,7 @@ describe('Task state machine', () => {
199
199
  expect(emitTaskEnd).not.toHaveBeenCalled();
200
200
  });
201
201
 
202
- it('terminates CONNECTED when an out-of-order participant leave identifies the current agent', () => {
202
+ it('ignores PARTICIPANT_LEAVE in CONNECTED even when it identifies the current agent', () => {
203
203
  const {service, emitTaskEnd} = startMachineWithEndSpy();
204
204
  const taskData = createActiveMainCallTaskData();
205
205
 
@@ -213,53 +213,71 @@ describe('Task state machine', () => {
213
213
  taskData: createPartialMainCallTaskData(false, true),
214
214
  });
215
215
 
216
+ expect(service.getSnapshot().value).toBe(TaskState.CONNECTED);
217
+ expect(emitTaskEnd).not.toHaveBeenCalled();
218
+ });
219
+
220
+ it('ignores PARTICIPANT_LEAVE in HOLD_INITIATING when a remote Drop identifies the current agent', () => {
221
+ const {service, emitTaskEnd} = startMachineWithEndSpy();
222
+ const taskData = createActiveMainCallTaskData();
223
+
224
+ enterTransientHoldState(service, TaskState.HOLD_INITIATING, taskData);
225
+ service.send({
226
+ type: TaskEvent.PARTICIPANT_LEAVE,
227
+ participantId: 'agent-1',
228
+ taskData: createPartialMainCallTaskData(false, true),
229
+ });
230
+
231
+ expect(service.getSnapshot().value).toBe(TaskState.HOLD_INITIATING);
232
+ expect(emitTaskEnd).not.toHaveBeenCalled();
233
+ });
234
+
235
+ it('terminates RESUME_INITIATING when a remote Drop identifies the current agent', () => {
236
+ const {service, emitTaskEnd} = startMachineWithEndSpy();
237
+ const taskData = createActiveMainCallTaskData(true);
238
+
239
+ enterTransientHoldState(service, TaskState.RESUME_INITIATING, taskData);
240
+ service.send({
241
+ type: TaskEvent.PARTICIPANT_LEAVE,
242
+ participantId: 'agent-1',
243
+ taskData: createPartialMainCallTaskData(true, true),
244
+ });
245
+
216
246
  expect(service.getSnapshot().value).toBe(TaskState.TERMINATED);
217
247
  expect(emitTaskEnd).toHaveBeenCalledTimes(1);
218
248
  });
219
249
 
220
- it.each([TaskState.HOLD_INITIATING, TaskState.RESUME_INITIATING])(
221
- 'terminates %s when a remote Drop identifies the current agent',
222
- (state) => {
223
- const {service, emitTaskEnd} = startMachineWithEndSpy();
224
- const taskData = createActiveMainCallTaskData(state === TaskState.RESUME_INITIATING);
225
-
226
- enterTransientHoldState(service, state, taskData);
227
- service.send({
228
- type: TaskEvent.PARTICIPANT_LEAVE,
229
- participantId: 'agent-1',
230
- taskData: createPartialMainCallTaskData(
231
- state === TaskState.RESUME_INITIATING,
232
- true
233
- ),
234
- });
235
-
236
- expect(service.getSnapshot().value).toBe(TaskState.TERMINATED);
237
- expect(emitTaskEnd).toHaveBeenCalledTimes(1);
238
- }
239
- );
240
-
241
- it.each([TaskState.HOLD_INITIATING, TaskState.RESUME_INITIATING])(
242
- 'keeps %s when ParticipantLeftConference identifies another participant',
243
- (state) => {
244
- const {service, emitTaskEnd} = startMachineWithEndSpy();
245
- const taskData = createActiveMainCallTaskData(state === TaskState.RESUME_INITIATING);
246
-
247
- enterTransientHoldState(service, state, taskData);
248
- service.send({
249
- type: TaskEvent.PARTICIPANT_LEAVE,
250
- participantId: 'agent-2',
251
- taskData: createPartialMainCallTaskData(
252
- state === TaskState.RESUME_INITIATING,
253
- true
254
- ),
255
- });
256
-
257
- expect(service.getSnapshot().value).toBe(state);
258
- expect(emitTaskEnd).not.toHaveBeenCalled();
259
- }
260
- );
250
+ it('keeps HOLD_INITIATING when ParticipantLeftConference identifies another participant', () => {
251
+ const {service, emitTaskEnd} = startMachineWithEndSpy();
252
+ const taskData = createActiveMainCallTaskData();
261
253
 
262
- it('keeps HELD when another participant leave event omits self from its roster', () => {
254
+ enterTransientHoldState(service, TaskState.HOLD_INITIATING, taskData);
255
+ service.send({
256
+ type: TaskEvent.PARTICIPANT_LEAVE,
257
+ participantId: 'agent-2',
258
+ taskData: createPartialMainCallTaskData(false, true),
259
+ });
260
+
261
+ expect(service.getSnapshot().value).toBe(TaskState.HOLD_INITIATING);
262
+ expect(emitTaskEnd).not.toHaveBeenCalled();
263
+ });
264
+
265
+ it('terminates RESUME_INITIATING when another participant leave omits self from the roster', () => {
266
+ const {service, emitTaskEnd} = startMachineWithEndSpy();
267
+ const taskData = createActiveMainCallTaskData(true);
268
+
269
+ enterTransientHoldState(service, TaskState.RESUME_INITIATING, taskData);
270
+ service.send({
271
+ type: TaskEvent.PARTICIPANT_LEAVE,
272
+ participantId: 'agent-2',
273
+ taskData: createPartialMainCallTaskData(true, true),
274
+ });
275
+
276
+ expect(service.getSnapshot().value).toBe(TaskState.TERMINATED);
277
+ expect(emitTaskEnd).toHaveBeenCalledTimes(1);
278
+ });
279
+
280
+ it('terminates HELD when another participant leave event omits self from its roster', () => {
263
281
  const {service, emitTaskEnd} = startMachineWithEndSpy();
264
282
  const taskData = createActiveMainCallTaskData(true);
265
283
 
@@ -275,8 +293,8 @@ describe('Task state machine', () => {
275
293
  taskData: createPartialMainCallTaskData(true, true),
276
294
  });
277
295
 
278
- expect(service.getSnapshot().value).toBe(TaskState.HELD);
279
- expect(emitTaskEnd).not.toHaveBeenCalled();
296
+ expect(service.getSnapshot().value).toBe(TaskState.TERMINATED);
297
+ expect(emitTaskEnd).toHaveBeenCalledTimes(1);
280
298
  });
281
299
 
282
300
  it('keeps HELD when CONSULT_END has a partial mainCall', () => {
@@ -2064,7 +2082,15 @@ describe('Task state machine', () => {
2064
2082
 
2065
2083
  it('transitions to CONNECTED on CONSULT_END without isTerminated during CONF_INITIATING', () => {
2066
2084
  const service = startMachine();
2067
- const taskData = createTaskData({consultingAgentId: 'agent-1'});
2085
+ const taskData = createTaskData({
2086
+ consultingAgentId: 'agent-1',
2087
+ interaction: {
2088
+ participants: {
2089
+ 'agent-1': {id: 'agent-1', pType: 'Agent', hasLeft: false},
2090
+ 'customer-1': {id: 'customer-1', pType: 'Customer', hasLeft: false},
2091
+ },
2092
+ } as any,
2093
+ });
2068
2094
 
2069
2095
  service.send({type: TaskEvent.TASK_INCOMING, taskData});
2070
2096
  service.send({type: TaskEvent.ASSIGN, taskData});
@@ -636,7 +636,7 @@ describe('State Machine Guards', () => {
636
636
  expect(guards.didCurrentAgentLeaveMainInteraction(createParams(context, event))).toBe(true);
637
637
  });
638
638
 
639
- it('returns true when the current participant is marked as departed', () => {
639
+ it('returns false when the current participant is marked hasLeft but remains in the map', () => {
640
640
  const context = createContext({taskData: activeTaskData});
641
641
  const updatedTaskData = createTaskData({
642
642
  interaction: {
@@ -652,10 +652,10 @@ describe('State Machine Guards', () => {
652
652
  guards.didCurrentAgentLeaveMainInteraction(
653
653
  createParams(context, createEventWithTaskData(updatedTaskData))
654
654
  )
655
- ).toBe(true);
655
+ ).toBe(false);
656
656
  });
657
657
 
658
- it('uses mainCall membership for nested CONSULT_END cleanup', () => {
658
+ it('does not infer departure from CONSULT_END mainCall membership', () => {
659
659
  const context = createContext({taskData: activeTaskData, consultFromConference: true});
660
660
  const updatedTaskData = createTaskData({
661
661
  interaction: {
@@ -690,10 +690,10 @@ describe('State Machine Guards', () => {
690
690
 
691
691
  expect(
692
692
  guards.didCurrentAgentLeaveMainInteraction(createParams(context, event))
693
- ).toBe(true);
693
+ ).toBe(false);
694
694
  });
695
695
 
696
- it('does not infer self departure when another participant leaves and the map omits self', () => {
696
+ it('returns true when another participant leaves and the map omits self', () => {
697
697
  const context = createContext({taskData: activeTaskData});
698
698
  const partialTaskData = createTaskData({
699
699
  interaction: {
@@ -718,7 +718,7 @@ describe('State Machine Guards', () => {
718
718
  taskData: partialTaskData,
719
719
  } as TaskEventPayload;
720
720
 
721
- expect(guards.didCurrentAgentLeaveMainInteraction(createParams(context, event))).toBe(false);
721
+ expect(guards.didCurrentAgentLeaveMainInteraction(createParams(context, event))).toBe(true);
722
722
  });
723
723
 
724
724
  it.each(['connected', 'held'])(