Validate providers and retain complete run debugging context

This commit is contained in:
2026-10-09 23:21:01 +01:00
parent f3d829bea5
commit 08b8647d5b
51 changed files with 1036 additions and 159 deletions
+43
View File
@@ -0,0 +1,43 @@
package tui
import (
"context"
"git.a-wan.net/alan/pipelines/internal/protocol"
tea "github.com/charmbracelet/bubbletea"
"testing"
)
func TestDirectRunSenderCannotBypassConfirmation(t *testing.T) {
for _, kind := range []string{protocol.RunPipeline, protocol.RetryRun, protocol.CancelRun} {
m := New(context.Background(), "")
updated, cmd := m.sendRunRequest(protocol.Message{Type: kind, RunID: 42})
m = updated.(Model)
if cmd != nil || m.actionConfirm == nil {
t.Fatal(kind, "bypassed modal")
}
m = press(m, "enter")
if m.actionConfirm == nil {
t.Fatal(kind, "Enter approved")
}
m = press(m, "esc")
if m.actionConfirm != nil {
t.Fatal(kind, "cancel failed")
}
}
}
func TestMutationFactoryOnlyRunsAfterExplicitApproval(t *testing.T) {
for _, key := range []string{"enter", "n", "esc", "y"} {
called := false
m := New(context.Background(), "")
updated, cmd := m.confirmMutation("Create draft?", func() tea.Cmd { called = true; return func() tea.Msg { return nil } })
m = updated.(Model)
if cmd != nil || called {
t.Fatal("factory ran before confirmation")
}
updated, cmd = m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune(key)})
if called != (key == "y") || (cmd != nil) != (key == "y") {
t.Fatal(key, "incorrect approval", called)
}
}
}