Files
pipelines/internal/tui/run_focus_test.go
T
alan c42a19f7d3 Improve workflow UI, retain stage diffs, and add portable pipeline transfers
Make OpenCode authoring responsive and expand the managed skill references. Add conflict-aware import/export, real-provider reference workflows, and tracked V2 generation for reliable budget accounting.
2026-10-10 20:55:42 +01:00

93 lines
2.9 KiB
Go

package tui
import (
"strings"
"testing"
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/x/ansi"
"github.com/muesli/termenv"
)
func TestRunNextPreviousNavigatesExecutionVisitsFromEveryPane(t *testing.T) {
for _, pane := range []string{"details", "graph"} {
t.Run(pane, func(t *testing.T) {
m := runInspectionModel()
m.width = 100
m.runDetail.Steps[1].Stage = m.runDetail.Steps[0].Stage
m.runDetailFocus = pane == "details"
m.runGraphFocus = pane == "graph"
m.runTop = 7
m = runKey(m, "n")
if m.runStepIndex != 1 || m.runTop != 0 || !m.runOpen {
t.Fatal("next stage did not select first recorded visit")
}
m = runKey(m, "n")
if m.runStepIndex != 2 {
t.Fatal("repeated stage visit skipped")
}
m = runKey(m, "n")
if m.runStepIndex != 2 {
t.Fatal("next stage wrapped past last visit")
}
m = runKey(m, "p")
if m.runStepIndex != 1 || !m.runOpen {
t.Fatal("previous stage opened pipeline")
}
m = runKey(m, "p")
m = runKey(m, "p")
if m.runStepIndex != 0 || !m.runOpen {
t.Fatal("previous stage wrapped before overview")
}
if m.runDetailFocus != (pane == "details") || m.runGraphFocus != (pane == "graph") {
t.Fatal("navigation unexpectedly changed focus")
}
})
}
}
func TestRunFocusHighlightsSelectionPaneAndVisibleSection(t *testing.T) {
previous := lipgloss.ColorProfile()
lipgloss.SetColorProfile(termenv.TrueColor)
defer lipgloss.SetColorProfile(previous)
m := runInspectionModel()
m.width = 120
m = runKey(m, "n")
view := m.runsDetailsView(30)
if !strings.Contains(ansi.Strip(view), "▸ Details") || strings.Contains(ansi.Strip(view), "▸ Stages") || !strings.Contains(view, "48;") {
t.Fatal("details/visit selection lacks background highlight")
}
lines := m.runSectionLines(80)
row, title := runFocusedSection(lines, 0)
if title != "Result" || !strings.Contains(lines[row], "48;") {
t.Fatal("focused section not highlighted", lines[row])
}
for i, line := range lines {
if strings.HasPrefix(ansi.Strip(line), "[s]") {
m.runTop = i
break
}
}
lines = m.runSectionLines(80)
row, title = runFocusedSection(lines, m.runTop)
if title != "Stage progress" || !strings.Contains(lines[row], "48;") {
t.Fatal("scroll focus did not follow section", title)
}
view = ansi.Strip(m.runsDetailsView(30))
if !strings.Contains(view, "▸ Details") || !strings.Contains(view, "· Result") || strings.Contains(view, "▸ Stages") {
t.Fatal("focused pane ambiguous", view)
}
m = runKey(m, "g")
if !strings.HasPrefix(m.runGraphTitle(), "▸ ") || strings.Contains(ansi.Strip(m.runsDetailsView(30)), "▸ Details") {
t.Fatal("graph focus left details highlighted")
}
for _, width := range []int{120, 63, 35, 10} {
m.width = width
for _, line := range strings.Split(m.runsView(24), "\n") {
if ansi.StringWidth(line) > width {
t.Fatal("highlight exceeded viewport", width)
}
}
}
}