package cli import ( "strings" "testing" "time" tea "github.com/charmbracelet/bubbletea" "gitea.mynodes.xyz/ilker/llmgw/internal/control/adminapi" "gitea.mynodes.xyz/ilker/llmgw/internal/control/federation" ) func TestTheConsoleShowsEachPeerAndOpensItsModels(t *testing.T) { m, _ := consoleWith(t, cFederation) m.data.federation = adminapi.FederationView{Cluster: "c-west", Peers: []federation.Status{ {Name: "east", URL: "https://east.example", Cluster: "c-east", Health: federation.Health{Up: true, Latency: 12 * time.Millisecond, Checked: time.Now()}, LatencyMs: 12, Models: []federation.ModelStatus{{Name: "east/qwen", Upstream: "qwen"}, {Name: "east/old", Upstream: "old", Withdrawn: true}}}, {Name: "north", URL: "https://north.example", Health: federation.Health{Error: "the peer did not answer"}}, }} var tm tea.Model = m view := tm.View() for _, want := range []string{"east", "12.0ms", "north", "down", "c-west"} { if !strings.Contains(view, want) { t.Errorf("the federation view has no %q:\n%s", want, view) } } tm = press(tm, "enter") view = tm.View() for _, want := range []string{"east/qwen", "east/old", "withdrawn", "c-east"} { if !strings.Contains(view, want) { t.Errorf("the peer's dialog has no %q:\n%s", want, view) } } }