Config view: Test connections below the service settings; hide a stale cursor

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-20 23:59:02 +02:00
co-authored by Claude Sonnet 5.5
parent 56bd80f7bb
commit 26e1679e4e
6 changed files with 112 additions and 11 deletions
+40
View File
@@ -272,3 +272,43 @@ func TestFormHeadingNeverTakesFocus(t *testing.T) {
t.Error("a heading got the focus")
}
}
func TestTestConnectionsButtonSitsBelowTheServices(t *testing.T) {
a := newTestApp(t)
v := a.settings
send := func(g *tview.Form, k tcell.Key) { g.GetInputCapture()(tcell.NewEventKey(k, 0, 0)) }
focusedItem := func() tview.FormItem { i, _ := v.form.GetFocusedItemIndex(); return v.form.GetFormItem(i) }
// It comes right after the SABnzbd API key and before the Interface section.
v.focusGroup(0, false)
for i := 0; i < 10; i++ { // Radarr 4, Sonarr 4, SABnzbd 2 fields
send(v.form, tcell.KeyDown)
}
if focusedItem() != tview.FormItem(v.testItem) {
t.Fatalf("↓ after the SABnzbd API key reached %T %q, want the Test connections button", focusedItem(), focusedItem().GetLabel())
}
send(v.form, tcell.KeyDown)
if got := focusedItem().GetLabel(); got != "Downloads refresh (seconds)" {
t.Errorf("after the button comes %q", got)
}
send(v.form, tcell.KeyUp)
if focusedItem() != tview.FormItem(v.testItem) {
t.Error("↑ must come back to the button")
}
// Save and Revert stay below everything; Test connections is not among them.
if v.actions.GetButtonCount() != 2 || v.actions.GetButton(0).GetLabel() != "Save" || v.actions.GetButton(1).GetLabel() != "Revert" {
t.Errorf("actions bar has %d buttons", v.actions.GetButtonCount())
}
// Space and Enter press it.
var focus func(p tview.Primitive)
focus = func(p tview.Primitive) { p.Focus(focus) }
for _, ev := range []*tcell.EventKey{tcell.NewEventKey(tcell.KeyRune, ' ', 0), tcell.NewEventKey(tcell.KeyEnter, 0, 0)} {
v.describe()
v.testItem.InputHandler()(ev, focus)
if !strings.Contains(v.status.GetText(false), "Testing the connections") {
t.Errorf("key %v did not start the test: %q", ev.Name(), v.status.GetText(false))
}
}
}