diff --git a/webview-ui/src/components/chat/TaskActions.tsx b/webview-ui/src/components/chat/TaskActions.tsx index 603b6be3e0..bb63ce0bc6 100644 --- a/webview-ui/src/components/chat/TaskActions.tsx +++ b/webview-ui/src/components/chat/TaskActions.tsx @@ -36,7 +36,7 @@ export const TaskActions = ({ item, buttonsDisabled }: TaskActionsProps) => { onClick={(e) => copyWithFeedback(item.task, e)} /> )} - {!!item?.size && item.size > 0 && ( + {item && ( <>
{ } }} /> - {prettyBytes(item.size)} + {!!item?.size && item.size > 0 && ( + + {prettyBytes(item.size)} + + )}
{deleteTaskId && ( { expect(screen.getByText("1024 B")).toBeInTheDocument() }) - it("does not render delete button when item has no size", () => { + it("renders delete button even when item has no size", () => { const itemWithoutSize = { ...mockItem, size: 0 } render() const deleteButton = screen.queryByLabelText("Delete Task (Shift + Click to skip confirmation)") - expect(deleteButton).not.toBeInTheDocument() + expect(deleteButton).toBeInTheDocument() + // Size should not be displayed when size is 0 + expect(screen.queryByText("0 B")).not.toBeInTheDocument() + }) + + it("renders delete button when item has undefined size", () => { + const itemWithUndefinedSize = { ...mockItem, size: undefined } + render() + + const deleteButton = screen.queryByLabelText("Delete Task (Shift + Click to skip confirmation)") + expect(deleteButton).toBeInTheDocument() + // Size should not be displayed when size is undefined + expect(screen.queryByText("undefined B")).not.toBeInTheDocument() + }) + + it("renders delete button and size when item has valid size", () => { + render() + + const deleteButton = screen.queryByLabelText("Delete Task (Shift + Click to skip confirmation)") + expect(deleteButton).toBeInTheDocument() + // Size should be displayed when size > 0 + expect(screen.getByText("1024 B")).toBeInTheDocument() }) })