c42a19f7d3
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.
64 lines
2.1 KiB
Go
64 lines
2.1 KiB
Go
package tui
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.a-wan.net/alan/pipelines/internal/protocol"
|
|
"github.com/charmbracelet/x/ansi"
|
|
)
|
|
|
|
func TestRunPanesExpandWithTabFocus(t *testing.T) {
|
|
m := New(context.Background(), "")
|
|
m.width, m.height = 120, 48
|
|
m.runOpen, m.keys.runs = true, true
|
|
m.requestedRunID = 1
|
|
run := &protocol.RunDetail{RunSummary: protocol.RunSummary{ID: 1}, Steps: []protocol.RunStep{{Stage: "one", Status: "completed"}}}
|
|
updated, _ := m.Update(receivedMsg(protocol.Message{Type: protocol.Run, RunDetail: run}))
|
|
m = updated.(Model)
|
|
graph, details := m.runPaneHeights(44)
|
|
if !m.runDetailFocus || m.runGraphFocus || details <= graph || graph+details != 44 {
|
|
t.Fatal("new run did not prioritize results", graph, details)
|
|
}
|
|
m = runKey(m, "tab")
|
|
graph, details = m.runPaneHeights(44)
|
|
if !m.runGraphFocus || graph <= details {
|
|
t.Fatal("graph focus did not expand")
|
|
}
|
|
graphPage := m.runPageSize()
|
|
m = runKey(m, "tab")
|
|
graph, details = m.runPaneHeights(44)
|
|
if m.runGraphFocus || !m.runDetailFocus || details <= graph || m.runDetailWidth() != m.width-4 || m.runPageSize() <= graphPage {
|
|
t.Fatal("details did not expand directly to full width", graph, details)
|
|
}
|
|
updated, _ = m.Update(receivedMsg(protocol.Message{Type: protocol.Run, RunDetail: run}))
|
|
m = updated.(Model)
|
|
if !m.runDetailFocus || m.runGraphFocus {
|
|
t.Fatal("polling reset chosen focus")
|
|
}
|
|
m = runKey(m, "tab")
|
|
graph, details = m.runPaneHeights(44)
|
|
if !m.runGraphFocus || graph <= details {
|
|
t.Fatal("graph did not expand again")
|
|
}
|
|
for _, height := range []int{14, 18, 24, 44, 80} {
|
|
for _, graphFocus := range []bool{false, true} {
|
|
m.runDetailFocus, m.runGraphFocus = !graphFocus, graphFocus
|
|
graph, details = m.runPaneHeights(height)
|
|
if graph+details != height || graph < 2 || details < 2 {
|
|
t.Fatal("pane sizes exceed available height", height, graph, details)
|
|
}
|
|
view := m.runsView(height)
|
|
if len(strings.Split(view, "\n")) > height {
|
|
t.Fatal("expanded pane exceeds height")
|
|
}
|
|
for _, line := range strings.Split(view, "\n") {
|
|
if ansi.StringWidth(line) > m.width {
|
|
t.Fatal("expanded pane exceeds width")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|