Files
pipelines/internal/tui/multi_picker_test.go
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

42 lines
1.2 KiB
Go

package tui
import (
"git.a-wan.net/alan/pipelines/internal/protocol"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/x/ansi"
"strings"
"testing"
)
func TestMultiPickerSelectionsSurviveFiltering(t *testing.T) {
p := multiPicker{picker: picker{items: []protocol.PipelineSummary{{ID: 1, Name: "alpha"}, {ID: 2, Name: "beta"}}, input: newInput(), width: 80, height: 20}, checked: map[int64]bool{}, title: "Select pipelines to export"}
key := func(k tea.KeyMsg) { t.Helper(); m, _ := p.Update(k); p = m.(multiPicker) }
key(tea.KeyMsg{Type: tea.KeyEnter})
if p.accepted {
t.Fatal("empty selection accepted")
}
key(tea.KeyMsg{Type: tea.KeySpace})
if !p.checked[1] {
t.Fatal("space did not check")
}
p.input.SetValue("beta")
key(tea.KeyMsg{Type: tea.KeyCtrlA})
if !p.checked[1] || !p.checked[2] {
t.Fatal("filtered select lost hidden item")
}
key(tea.KeyMsg{Type: tea.KeyCtrlA})
if !p.checked[1] || p.checked[2] {
t.Fatal("filtered deselect lost hidden item")
}
key(tea.KeyMsg{Type: tea.KeyEnter})
if !p.accepted {
t.Fatal("selection not accepted")
}
p.width = 25
for _, line := range strings.Split(p.View(), "\n") {
if ansi.StringWidth(line) > 23 {
t.Fatal("picker overflows", line)
}
}
}