Browse Source

test: update HistoryView delete task test to handle confirmation dialog

EMSHVAC 10 months ago
parent
commit
1922b8aea9
1 changed files with 6 additions and 1 deletions
  1. 6 1
      webview-ui/src/components/history/__tests__/HistoryView.test.tsx

+ 6 - 1
webview-ui/src/components/history/__tests__/HistoryView.test.tsx

@@ -135,7 +135,7 @@ describe("HistoryView", () => {
 		})
 	})
 
-	it("handles task deletion", () => {
+	it("handles task deletion", async () => {
 		const onDone = jest.fn()
 		render(<HistoryView onDone={onDone} />)
 
@@ -143,9 +143,14 @@ describe("HistoryView", () => {
 		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)
 
+		// Find and click the confirm delete button in the dialog
+		const confirmDeleteButton = screen.getByRole("button", { name: /delete/i })
+		fireEvent.click(confirmDeleteButton)
+
 		// Verify vscode message was sent
 		expect(vscode.postMessage).toHaveBeenCalledWith({
 			type: "deleteTaskWithId",