Initial pipelines server, CLI, TUI, and Go installation
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
package tui
|
||||
|
||||
import (
|
||||
"context"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/x/ansi"
|
||||
"pipelines/internal/pipeline"
|
||||
"pipelines/internal/protocol"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCLIPickerAndMultilinePrompt(t *testing.T) {
|
||||
m := NewRun(context.Background(), "", RunOptions{Workspace: "/repos/example"})
|
||||
m.width = 120
|
||||
m.height = 36
|
||||
m.loaded = true
|
||||
m.pipelines = []protocol.PipelineSummary{{ID: 1, Name: "bug fix"}, {ID: 2, Name: "anime episodes today"}}
|
||||
m.runPickerInput.SetValue("bg fx")
|
||||
items := m.runChoices()
|
||||
if len(items) != 1 || items[0].ID != 1 {
|
||||
t.Fatal("fuzzy match failed", items)
|
||||
}
|
||||
if !strings.Contains(ansi.Strip(m.View()), "/repos/example") {
|
||||
t.Fatal("repository not shown in picker")
|
||||
}
|
||||
graph, err := pipeline.Parse(pipeline.Template([]string{"one"}, true))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m.detail = &protocol.PipelineDetail{PipelineSummary: protocol.PipelineSummary{ID: 1, Name: "bug fix", Version: 1}, Graph: graph}
|
||||
updated, _ := m.configureCLIRun()
|
||||
m = updated.(Model)
|
||||
m.runPrompt.SetValue("first line")
|
||||
updated, _ = m.updateRunForm(tea.KeyMsg{Type: tea.KeyEnter})
|
||||
m = updated.(Model)
|
||||
if m.runForm != 1 || !strings.Contains(m.runPrompt.Value(), "\n") {
|
||||
t.Fatal("Enter must add a prompt line")
|
||||
}
|
||||
m.runPrompt.SetValue("line one\nline two")
|
||||
updated, _ = m.updateRunForm(tea.KeyMsg{Type: tea.KeyCtrlS})
|
||||
m = updated.(Model)
|
||||
if m.runForm != 2 || m.runTask != "line one\nline two" {
|
||||
t.Fatal("multiline prompt lost")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCLISuppliedArgumentsStillRequireConfirmation(t *testing.T) {
|
||||
m := NewRun(context.Background(), "", RunOptions{Pipeline: "test", Prompt: "task", Workspace: "/repos/a"})
|
||||
m.detail = &protocol.PipelineDetail{PipelineSummary: protocol.PipelineSummary{ID: 1, Name: "test", Version: 1}}
|
||||
updated, _ := m.configureCLIRun()
|
||||
m = updated.(Model)
|
||||
if m.runForm != 3 || m.runOpen || m.runTask != "task" || m.runWorkspace != "/repos/a" {
|
||||
t.Fatal("arguments skipped approval or lost repository")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user