Skip to content
Closed
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
8 changes: 6 additions & 2 deletions webview-ui/src/components/chat/TaskActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const TaskActions = ({ item, buttonsDisabled }: TaskActionsProps) => {
onClick={(e) => copyWithFeedback(item.task, e)}
/>
)}
{!!item?.size && item.size > 0 && (
{item && (
<>
<div className="flex items-center">
<IconButton
Expand All @@ -53,7 +53,11 @@ export const TaskActions = ({ item, buttonsDisabled }: TaskActionsProps) => {
}
}}
/>
<span className="ml-1 text-xs text-vscode-foreground opacity-85">{prettyBytes(item.size)}</span>
{!!item?.size && item.size > 0 && (
<span className="ml-1 text-xs text-vscode-foreground opacity-85">
{prettyBytes(item.size)}
</span>
)}
</div>
{deleteTaskId && (
<DeleteTaskDialog
Expand Down
25 changes: 23 additions & 2 deletions webview-ui/src/components/chat/__tests__/TaskActions.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,33 @@ describe("TaskActions", () => {
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(<TaskActions item={itemWithoutSize} buttonsDisabled={false} />)

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(<TaskActions item={itemWithUndefinedSize} buttonsDisabled={false} />)

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(<TaskActions item={mockItem} buttonsDisabled={false} />)

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()
})
})

Expand Down