Offer nvim or OpenCode when creating a pipeline

This commit is contained in:
2026-10-09 20:53:00 +01:00
parent a50e8648f6
commit dd50344170
10 changed files with 102 additions and 16 deletions
+41
View File
@@ -60,6 +60,47 @@ func TestPipelineEditPickerHasTabNavigationFuzzySearchAndRetainedDraft(t *testin
}
}
func TestNewPickerSupportsBothEditorsWithoutCreatingDraftOnCancel(t *testing.T) {
t.Setenv("PIPELINES_DRAFT_DIR", t.TempDir())
source := pipeline.Template([]string{"worker"}, true)
for _, choice := range []string{"nv", "ocd"} {
m := New(context.Background(), "ws://example/connect")
m.width = 120
updated, _ := m.newPipeline(source)
m = updated.(Model)
view := ansi.Strip(m.editorPickerView(30))
for _, text := range []string{"New pipeline with", "nvim", "OpenCode", "retained draft file", "write it together"} {
if !strings.Contains(view, text) {
t.Fatal("missing new authoring choice", text, view)
}
}
m.editorInput.SetValue(choice)
updated, cmd := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
m = updated.(Model)
if cmd == nil || m.editorOpen || m.confirmOpen || m.submitID != "" {
t.Fatal("new choice did not launch editor or bypassed publication")
}
}
items, err := draft.List()
if err != nil || len(items) != 2 {
t.Fatal("new choices did not retain drafts", items, err)
}
for _, item := range items {
text, err := draft.Read(item.Path)
if err != nil || text != source || !item.CreateOnly || item.BaseVersion != 0 || item.Server != "ws://example/connect" {
t.Fatal("new draft lost source/create-only/server metadata", item, err)
}
}
m := New(context.Background(), "")
updated, _ := m.newPipeline(source)
m = updated.(Model)
m = press(m, "esc")
after, _ := draft.List()
if m.editorOpen || len(after) != 2 {
t.Fatal("canceling New created a draft")
}
}
func TestDraftCleanupRequiresConfirmationAndPreservesOtherDraft(t *testing.T) {
t.Setenv("PIPELINES_DRAFT_DIR", t.TempDir())
a, _ := draft.Create("discard", "discard", "server", true, 0)