Add movie search and add flow (M2)
Movies view with debounced Radarr lookup, detail pane, and an add dialog (quality profile, root folder, monitored, search now). Global shortcuts are suspended while typing or in a dialog. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.stinnesbeck.com/nils/arr-tui/internal/arr"
|
||||
"git.stinnesbeck.com/nils/arr-tui/internal/radarr"
|
||||
)
|
||||
|
||||
func TestMovieLabel(t *testing.T) {
|
||||
if got := movieLabel(radarr.Movie{Title: "Alien", Year: 1979}); got != "Alien (1979)" {
|
||||
t.Errorf("got %q", got)
|
||||
}
|
||||
if got := movieLabel(radarr.Movie{ID: 3, Title: "Alien", Year: 1979}); !strings.Contains(got, "✓") {
|
||||
t.Errorf("in-library marker missing: %q", got)
|
||||
}
|
||||
// tview color tags in titles must be escaped
|
||||
if got := movieLabel(radarr.Movie{Title: "[red]x"}); strings.Contains(got, "[red]x") {
|
||||
t.Errorf("title not escaped: %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMovieDetails(t *testing.T) {
|
||||
got := movieDetails(radarr.Movie{
|
||||
ID: 1, Title: "Alien", Year: 1979, Runtime: 117, Genres: []string{"Horror", "Sci-Fi"},
|
||||
Overview: "In space...", Ratings: radarr.Ratings{IMDB: &radarr.Rating{Value: 8.5}},
|
||||
})
|
||||
for _, want := range []string{"Alien (1979)", "★ 8.5", "1h57m", "Horror, Sci-Fi", "In library, not downloaded", "In space..."} {
|
||||
if !strings.Contains(got, want) {
|
||||
t.Errorf("details missing %q:\n%s", want, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultIndexes(t *testing.T) {
|
||||
profiles := []arr.QualityProfile{{Name: "Any"}, {Name: "HD-1080p"}}
|
||||
if profileIndex(profiles, "hd-1080p") != 1 || profileIndex(profiles, "nope") != 0 {
|
||||
t.Error("profileIndex")
|
||||
}
|
||||
folders := []arr.RootFolder{{Path: "/a"}, {Path: "/movies/"}}
|
||||
if folderIndex(folders, "/movies") != 1 || folderIndex(folders, "") != 0 {
|
||||
t.Error("folderIndex")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user