Files
pipelines/internal/tui/resources_test.go
T
alan 9130ae8c7a Add stage-exclusive resource waiting
Add durable FIFO capacity-one resource leases for executable stages, including cleanup-confirmed release, conservative restart quarantine, queue state events, and CLI/TUI/Android waiting presentation. Add scheduler, cleanup, protocol, client, and Android coverage plus a proposed Android v3 resource draft.

Checked packaged templates and authoring skill references: neither needs updating in this item. The per-item docs note records the shared documentation that docs-fold must update; no shared README or packaged reference was edited.
2026-10-18 12:30:30 +01:00

44 lines
1.3 KiB
Go

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)
})
}
}
}