package tui import ( "fmt" "strings" "testing" "git.a-wan.net/alan/pipelines/internal/protocol" "github.com/charmbracelet/lipgloss" "github.com/charmbracelet/x/ansi" "github.com/muesli/termenv" ) func TestResourceWaitFrames(t *testing.T) { previous := lipgloss.ColorProfile() defer lipgloss.SetColorProfile(previous) for _, width := range []int{60, 120} { for _, plain := range []bool{false, true} { t.Run(fmt.Sprintf("width-%d-plain-%t", width, plain), func(t *testing.T) { if plain { lipgloss.SetColorProfile(termenv.Ascii) } else { lipgloss.SetColorProfile(termenv.TrueColor) } m := decisionModel() m.width = width m.runDetail.Status = protocol.RunStatusQueued m.runDetail.Steps = nil m.runDetail.ResourceWait = &protocol.ResourceWait{Resource: "phone-X", Stage: "review", Sequence: 1, QueuedSince: "2026-10-18T10:00:00Z"} frame := ansi.Strip(m.runsDetailsView(24)) if !strings.Contains(frame, "Waiting for resource phone-X") || strings.Contains(frame, "c decide") || strings.Contains(frame, "Waiting for a person") { t.Fatal("wrong resource wait frame:\n", frame) } for _, line := range strings.Split(frame, "\n") { if ansi.StringWidth(line) > width { t.Fatalf("overflow: %q", line) } } t.Log("Rendered resource wait (no phone):\n" + frame) }) } } }