package tui import ( "context" "git.a-wan.net/alan/pipelines/internal/protocol" "github.com/charmbracelet/x/ansi" "strings" "testing" ) func TestInfrastructureRetainedWithoutClutteringPageHeaders(t *testing.T) { m := New(context.Background(), "ws://localhost/connect") m.width = 120 m.height = 40 updated, _ := m.Update(receivedMsg(protocol.Message{Type: protocol.PipelineList, NotificationEndpoints: []protocol.NotificationEndpoint{{Destination: "system", ServerURL: "http://10.0.0.249:8090", Topic: "pipelines"}}})) m = updated.(Model) view := ansi.Strip(m.View()) header := strings.Split(view, "\n")[0] for _, text := range []string{"ntfy", "http://10.0.0.249:8090", "topic pipelines"} { if strings.Contains(header, text) { t.Fatal("infrastructure cluttered the result page header", text, view) } } if strings.Contains(strings.Join(m.homeLines(), "\n"), "Phone notifications") { t.Fatal("notification setup still occupies home panel") } m.runOpen = true if strings.Contains(strings.Split(ansi.Strip(m.View()), "\n")[0], "topic pipelines") || len(m.notificationEndpoints) != 1 || m.notificationEndpoints[0].Topic != "pipelines" { t.Fatal("notification information lost or leaked into run header") } for _, width := range []int{1, 12, 40, 80, 120} { m.width = width for _, line := range strings.Split(m.View(), "\n") { if ansi.StringWidth(line) > width { t.Fatalf("header/layout overflows at width %d", width) } } } }