Remove titles from the library with a confirmation (M10)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-20 22:36:19 +02:00
co-authored by Claude Sonnet 5.5
parent ebbb3cd178
commit 7582504268
11 changed files with 174 additions and 5 deletions
+46
View File
@@ -0,0 +1,46 @@
package ui
import (
"testing"
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
)
func TestDeleteDialogDefaultsAreSafe(t *testing.T) {
a := newTestApp(t)
var calls [][2]bool
_, form := a.newDeleteDialog("Heat (1995)", "3 GB on disk", func(files, exclude bool) { calls = append(calls, [2]bool{files, exclude}) })
var focus func(p tview.Primitive)
focus = func(p tview.Primitive) { p.Focus(focus) }
form.Focus(focus)
press := func(k tcell.Key) { form.InputHandler()(tcell.NewEventKey(k, 0, 0), focus) }
space := func() { form.InputHandler()(tcell.NewEventKey(tcell.KeyRune, ' ', 0), focus) }
// Both boxes start unticked and the focus starts on Cancel: a stray Enter does nothing.
press(tcell.KeyEnter)
if len(calls) != 0 {
t.Fatalf("Enter on the initial focus deleted: %v", calls)
}
// Moving to Delete and confirming removes the entry only.
form.SetFocus(form.GetFormItemCount())
press(tcell.KeyRight)
press(tcell.KeyEnter)
if len(calls) != 1 || calls[0] != [2]bool{false, false} {
t.Fatalf("calls = %v, want one call without files and exclusion", calls)
}
// Ticking the boxes is passed on.
form.SetFocus(0)
space() // delete files
press(tcell.KeyDown)
space() // exclusion
press(tcell.KeyDown)
press(tcell.KeyDown) // Delete button
press(tcell.KeyEnter)
if len(calls) != 2 || calls[1] != [2]bool{true, true} {
t.Errorf("calls = %v, want the second with both ticked", calls)
}
}