Files
pipelines/internal/tui/ux_review_test.go
T
alan a48e4a5b6a Replace starters with four graded examples seeded into new databases
The template catalog is now Example 1-4: one stage, two stages (handoff),
feedback loop (runner-owned limits, retries, timeout) and human decision
(type=human approve/revise/abort with notify hooks). All read-only or leave
changes uncommitted; none commits, pushes or deploys.

A brand-new database (schema created by this Open) gets the examples once at
server start, bound to the configured default model and harness. A
server_settings marker records the decision, so removed examples never come
back and existing installs are marked without any pipeline being added or
rewritten.
2026-11-03 19:35:47 +00:00

74 lines
2.7 KiB
Go

package tui
import (
"context"
"fmt"
"git.a-wan.net/alan/pipelines/internal/pipeline"
"git.a-wan.net/alan/pipelines/internal/protocol"
"github.com/charmbracelet/x/ansi"
"os"
"path/filepath"
"strings"
"testing"
)
// Opt-in rendered snapshots for human/independent UI review; no server mutations.
func TestUIUXReviewSnapshots(t *testing.T) {
directory := os.Getenv("PIPELINES_UX_SNAPSHOT_DIR")
if directory == "" {
t.Skip("set PIPELINES_UX_SNAPSHOT_DIR for rendered UI review")
}
if err := os.MkdirAll(directory, 0700); err != nil {
t.Fatal(err)
}
source, err := os.ReadFile("../../examples/human-decision.md")
if err != nil {
t.Fatal(err)
}
graph, err := pipeline.Parse(string(source))
if err != nil {
t.Fatal(err)
}
for _, width := range []int{80, 120, 160} {
m := New(context.Background(), "ws://127.0.0.1:8080/connect")
m.width = width
m.height = 36
m.loaded = true
m.status = "127.0.0.1:8080"
m.notificationEndpoints = []protocol.NotificationEndpoint{{Destination: "system", ServerURL: "http://100.85.25.33:8090", Topic: "pipelines"}}
m.pipelines = []protocol.PipelineSummary{{ID: 8, Name: "Example 4: human decision", Version: 1, Stages: 3, CreatedAt: "2026-10-08T20:00:00Z", UpdatedAt: "2026-10-08T20:00:00Z"}}
save := func(name string) {
t.Helper()
view := ansi.Strip(m.View())
for _, line := range strings.Split(view, "\n") {
if ansi.StringWidth(line) > width {
t.Fatalf("%s overflows", name)
}
}
if err := os.WriteFile(filepath.Join(directory, fmt.Sprintf("%s-%d.txt", name, width)), []byte(view), 0600); err != nil {
t.Fatal(err)
}
}
save("home")
m.keys.detail = true
m.detail = &protocol.PipelineDetail{PipelineSummary: m.pipelines[0], Source: string(source), Graph: graph, LatestVersion: 1, VersionCreatedAt: "2026-10-08T20:00:00Z"}
save("pipeline")
m = press(m, "n")
save("next-stage")
m = press(m, "tab")
save("focused-stage")
for i := 0; i < 24; i++ {
m = press(m, "j")
}
save("scrolled-stage")
m = press(m, "tab")
m = press(m, "3")
save("review-stage")
m.runOpen = true
m.keys.runs = true
m.runDetail = &protocol.RunDetail{RunSummary: protocol.RunSummary{ID: 1, Name: "Example 4: human decision", PipelineID: 8, Version: 1, Status: "succeeded", CreatedAt: "2026-10-08T20:00:00Z", FinishedAt: "2026-10-08T20:01:00Z"}, Graph: graph, Steps: []protocol.RunStep{{Sequence: 1, Stage: "plan", Status: "completed", Outcome: "success", Target: "decide"}, {Sequence: 2, Stage: "decide", Status: "completed", Outcome: "approve", Target: "act"}, {Sequence: 3, Stage: "act", Status: "completed", Outcome: "success", Target: protocol.SuccessEnd, Output: map[string]any{"summary": "Fixture review report", "findings": "Fixture findings"}}}}
m.runStepIndex = 3
save("run")
}
}