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
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -733,15 +733,53 @@ describe('CallControl Utils', () => {
interaction: {
...mockCurrentTask.data.interaction,
callProcessingDetails: {
isPaused: true,
isPaused: 'true',
},
},
},
};

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', () => {
Expand Down
Loading