Skip to content

Commit 6be4607

Browse files
authored
fix(cc-components): correct recording state during hold/unhold operations (#685)
1 parent 26a6dbe commit 6be4607

2 files changed

Lines changed: 42 additions & 4 deletions

File tree

packages/contact-center/cc-components/src/components/task/CallControl/call-control.utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ export const updateCallStateFromTask = (
358358

359359
if (callProcessingDetails) {
360360
const {isPaused} = callProcessingDetails;
361-
setIsRecording(!isPaused);
361+
setIsRecording(isPaused !== 'true');
362362
}
363363
} catch (error) {
364364
logger?.error('CC-Widgets: CallControl: Error in updateCallStateFromTask', {

packages/contact-center/cc-components/tests/components/task/CallControl/call-control.utils.tsx

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ describe('CallControl Utils', () => {
722722
it('should update recording state from task data', () => {
723723
updateCallStateFromTask(mockCurrentTask as unknown as ITask, mockSetIsRecording);
724724

725-
expect(mockSetIsRecording).toHaveBeenCalledWith(true); // !isPaused = !false = true
725+
expect(mockSetIsRecording).toHaveBeenCalledWith(true);
726726
});
727727

728728
it('should handle task with recording paused', () => {
@@ -733,15 +733,53 @@ describe('CallControl Utils', () => {
733733
interaction: {
734734
...mockCurrentTask.data.interaction,
735735
callProcessingDetails: {
736-
isPaused: true,
736+
isPaused: 'true',
737737
},
738738
},
739739
},
740740
};
741741

742742
updateCallStateFromTask(taskWithPausedRecording as unknown as ITask, mockSetIsRecording);
743743

744-
expect(mockSetIsRecording).toHaveBeenCalledWith(false); // !isPaused = !true = false
744+
expect(mockSetIsRecording).toHaveBeenCalledWith(false);
745+
});
746+
747+
it('should handle isPaused as string "true" from backend', () => {
748+
const taskWithStringPaused = {
749+
...mockCurrentTask,
750+
data: {
751+
...mockCurrentTask.data,
752+
interaction: {
753+
...mockCurrentTask.data.interaction,
754+
callProcessingDetails: {
755+
isPaused: 'true',
756+
},
757+
},
758+
},
759+
};
760+
761+
updateCallStateFromTask(taskWithStringPaused as unknown as ITask, mockSetIsRecording);
762+
763+
expect(mockSetIsRecording).toHaveBeenCalledWith(false);
764+
});
765+
766+
it('should handle isPaused as string "false" from backend', () => {
767+
const taskWithStringNotPaused = {
768+
...mockCurrentTask,
769+
data: {
770+
...mockCurrentTask.data,
771+
interaction: {
772+
...mockCurrentTask.data.interaction,
773+
callProcessingDetails: {
774+
isPaused: 'false',
775+
},
776+
},
777+
},
778+
};
779+
780+
updateCallStateFromTask(taskWithStringNotPaused as unknown as ITask, mockSetIsRecording);
781+
782+
expect(mockSetIsRecording).toHaveBeenCalledWith(true);
745783
});
746784

747785
it('should return early when currentTask is null', () => {

0 commit comments

Comments
 (0)