From d9d2f14b7bae5d54647a5cd4e1dcc061be4dee83 Mon Sep 17 00:00:00 2001 From: Bharath Balan <62698609+bhabalan@users.noreply.github.com> Date: Thu, 14 May 2026 07:25:30 +0530 Subject: [PATCH] fix(cc-components): correct recording state during hold/unhold operations The recording indicator incorrectly showed paused state when a call was held because isPaused from the backend is a string ("true"/"false"), not a boolean. Using !isPaused on string "false" evaluates to false, causing the UI to show recording as paused. Changed to explicit string comparison. COMPLETES CAI-7859 --- .../task/CallControl/call-control.utils.ts | 2 +- .../task/CallControl/call-control.utils.tsx | 44 +++++++++++++++++-- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/packages/contact-center/cc-components/src/components/task/CallControl/call-control.utils.ts b/packages/contact-center/cc-components/src/components/task/CallControl/call-control.utils.ts index 778725954..6f82f3352 100644 --- a/packages/contact-center/cc-components/src/components/task/CallControl/call-control.utils.ts +++ b/packages/contact-center/cc-components/src/components/task/CallControl/call-control.utils.ts @@ -358,7 +358,7 @@ export const updateCallStateFromTask = ( if (callProcessingDetails) { const {isPaused} = callProcessingDetails; - setIsRecording(!isPaused); + setIsRecording(isPaused !== 'true'); } } catch (error) { logger?.error('CC-Widgets: CallControl: Error in updateCallStateFromTask', { diff --git a/packages/contact-center/cc-components/tests/components/task/CallControl/call-control.utils.tsx b/packages/contact-center/cc-components/tests/components/task/CallControl/call-control.utils.tsx index 0e8976e59..b21f715f2 100644 --- a/packages/contact-center/cc-components/tests/components/task/CallControl/call-control.utils.tsx +++ b/packages/contact-center/cc-components/tests/components/task/CallControl/call-control.utils.tsx @@ -722,7 +722,7 @@ describe('CallControl Utils', () => { it('should update recording state from task data', () => { updateCallStateFromTask(mockCurrentTask as unknown as ITask, mockSetIsRecording); - expect(mockSetIsRecording).toHaveBeenCalledWith(true); // !isPaused = !false = true + expect(mockSetIsRecording).toHaveBeenCalledWith(true); }); it('should handle task with recording paused', () => { @@ -733,7 +733,7 @@ describe('CallControl Utils', () => { interaction: { ...mockCurrentTask.data.interaction, callProcessingDetails: { - isPaused: true, + isPaused: 'true', }, }, }, @@ -741,7 +741,45 @@ describe('CallControl Utils', () => { updateCallStateFromTask(taskWithPausedRecording as unknown as ITask, mockSetIsRecording); - expect(mockSetIsRecording).toHaveBeenCalledWith(false); // !isPaused = !true = false + expect(mockSetIsRecording).toHaveBeenCalledWith(false); + }); + + it('should handle isPaused as string "true" from backend', () => { + const taskWithStringPaused = { + ...mockCurrentTask, + data: { + ...mockCurrentTask.data, + interaction: { + ...mockCurrentTask.data.interaction, + callProcessingDetails: { + isPaused: 'true', + }, + }, + }, + }; + + updateCallStateFromTask(taskWithStringPaused as unknown as ITask, mockSetIsRecording); + + expect(mockSetIsRecording).toHaveBeenCalledWith(false); + }); + + it('should handle isPaused as string "false" from backend', () => { + const taskWithStringNotPaused = { + ...mockCurrentTask, + data: { + ...mockCurrentTask.data, + interaction: { + ...mockCurrentTask.data.interaction, + callProcessingDetails: { + isPaused: 'false', + }, + }, + }, + }; + + updateCallStateFromTask(taskWithStringNotPaused as unknown as ITask, mockSetIsRecording); + + expect(mockSetIsRecording).toHaveBeenCalledWith(true); }); it('should return early when currentTask is null', () => {