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
7 changes: 6 additions & 1 deletion webview-ui/src/components/history/HistoryView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,12 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
title="Delete Task"
onClick={(e) => {
e.stopPropagation()
setDeleteTaskId(item.id)
if (e.shiftKey) {
// directly delete without prompting if shift is pressed
vscode.postMessage({ type: "deleteTaskWithId", text: item.id })
} else {
setDeleteTaskId(item.id)
}
}}>
<span className="codicon codicon-trash" />
{item.size && prettyBytes(item.size)}
Expand Down
60 changes: 44 additions & 16 deletions webview-ui/src/components/history/__tests__/HistoryView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,26 +135,54 @@ describe("HistoryView", () => {
})
})

it("handles task deletion", async () => {
const onDone = jest.fn()
render(<HistoryView onDone={onDone} />)
describe("task deletion", () => {
it("shows confirmation dialog on regular click", () => {
const onDone = jest.fn()
render(<HistoryView onDone={onDone} />)

// Find and hover over first task
const taskContainer = screen.getByTestId("virtuoso-item-1")
fireEvent.mouseEnter(taskContainer)

// Click delete button to open confirmation dialog
const deleteButton = within(taskContainer).getByTitle("Delete Task")
fireEvent.click(deleteButton)

// Verify dialog is shown
const dialog = screen.getByRole("alertdialog")
expect(dialog).toBeInTheDocument()

// Find and click the confirm delete button in the dialog
const confirmDeleteButton = within(dialog).getByRole("button", { name: /delete/i })
fireEvent.click(confirmDeleteButton)

// Verify vscode message was sent
expect(vscode.postMessage).toHaveBeenCalledWith({
type: "deleteTaskWithId",
text: "1",
})
})

// Find and hover over first task
const taskContainer = screen.getByTestId("virtuoso-item-1")
fireEvent.mouseEnter(taskContainer)
it("deletes immediately on shift-click without confirmation", () => {
const onDone = jest.fn()
render(<HistoryView onDone={onDone} />)

// Click delete button to open confirmation dialog
const deleteButton = within(taskContainer).getByTitle("Delete Task")
fireEvent.click(deleteButton)
// Find and hover over first task
const taskContainer = screen.getByTestId("virtuoso-item-1")
fireEvent.mouseEnter(taskContainer)

// Find and click the confirm delete button in the dialog
const confirmDeleteButton = screen.getByRole("button", { name: /delete/i })
fireEvent.click(confirmDeleteButton)
// Shift-click delete button
const deleteButton = within(taskContainer).getByTitle("Delete Task")
fireEvent.click(deleteButton, { shiftKey: true })

// Verify vscode message was sent
expect(vscode.postMessage).toHaveBeenCalledWith({
type: "deleteTaskWithId",
text: "1",
// Verify no dialog is shown
expect(screen.queryByRole("alertdialog")).not.toBeInTheDocument()

// Verify vscode message was sent
expect(vscode.postMessage).toHaveBeenCalledWith({
type: "deleteTaskWithId",
text: "1",
})
})
})

Expand Down