Offer nvim or OpenCode when creating a pipeline
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user