Remove digit view shortcuts; check all services at startup and every 30s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-20 20:58:18 +02:00
co-authored by Claude Sonnet 5.5
parent 8a357f7418
commit cd4e3b8841
2 changed files with 89 additions and 7 deletions
+40
View File
@@ -0,0 +1,40 @@
package ui
import (
"testing"
"github.com/gdamore/tcell/v2"
"git.stinnesbeck.com/nils/arr-tui/internal/config"
)
func newTestApp(t *testing.T) *App {
t.Helper()
// Unreachable services: the views only start background requests that fail.
cfg := &config.Config{
Radarr: config.Arr{Service: config.Service{URL: "http://127.0.0.1:1", APIKey: "k"}},
Sonarr: config.Arr{Service: config.Service{URL: "http://127.0.0.1:1", APIKey: "k"}},
SABnzbd: config.Service{URL: "http://127.0.0.1:1", APIKey: "k"},
UI: config.UI{RefreshSeconds: 3},
}
return New(cfg)
}
func TestOnlyFunctionKeysSwitchViews(t *testing.T) {
a := newTestApp(t)
for _, r := range "12345\t" {
key := tcell.NewEventKey(tcell.KeyRune, r, 0)
if r == '\t' {
key = tcell.NewEventKey(tcell.KeyTab, 0, 0)
}
a.handleKey(key)
if a.active != 0 {
t.Fatalf("key %q switched to view %d", r, a.active)
}
}
for i, k := range []tcell.Key{tcell.KeyF1, tcell.KeyF2, tcell.KeyF3, tcell.KeyF4, tcell.KeyF5} {
if a.handleKey(tcell.NewEventKey(k, 0, 0)) != nil || a.active != i {
t.Errorf("F%d: active view %d, want %d", i+1, a.active, i)
}
}
}