generated from mathias/template-go-web
Makes the atlas self-explanatory. Every stage/node gains a plain-language layer (plain_title + plain "what happens" + jargon-free node text); the previous technical copy demotes to a subtitle + on-demand detail. A Plain⇄Technical toggle (default Plain, persisted) flips the whole atlas. Biggest win: every transition arrow is now LABELLED with "what must be true to advance" (the gated- flow story that was invisible), gate hops (human @04, CI @06) styled distinctly. Spine repositioned into a uniform header band so labels never collide with copy. Copy grounded in a fresh-eyes UX review (docs/UX-REVIEW.md, reviewer≠implementer). Data model: plain_title/plain/trans_label/trans on Stage, plain on Node — guarded by a test (every stage has plain_title + a transition). Live overlays unchanged. Verified: build/vet/lint(0)/test green; Plain render screenshot-checked. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
72 lines
2.0 KiB
Go
72 lines
2.0 KiB
Go
package atlas_test
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
"git.d-ma.be/mathias/cad-atlas/internal/atlas"
|
|
)
|
|
|
|
func TestBuild_OverlaysCIStageNodesFromWorkflow(t *testing.T) {
|
|
atlasJSON := []byte(`{
|
|
"substrate": [{"n":"koala","k":"gpu"}],
|
|
"stages": [
|
|
{"no":"STAGE 06","title":"PR → CI","generate":"ci-jobs","nodes":[]},
|
|
{"no":"STAGE 01","title":"TELOS","nodes":[{"t":"Intention substrate"}]}
|
|
]}`)
|
|
workflow := []byte("jobs:\n check:\n a: 1\n build:\n b: 2\n deploy:\n c: 3\n")
|
|
|
|
a, err := atlas.Build(atlasJSON, workflow)
|
|
if err != nil {
|
|
t.Fatalf("Build: %v", err)
|
|
}
|
|
|
|
// CI stage nodes generated from the workflow's jobs, in order.
|
|
var titles []string
|
|
for _, n := range a.Stages[0].Nodes {
|
|
titles = append(titles, n.Title)
|
|
}
|
|
if want := []string{"check", "build", "deploy"}; !reflect.DeepEqual(titles, want) {
|
|
t.Fatalf("CI stage nodes = %v, want %v", titles, want)
|
|
}
|
|
|
|
// Non-generated stage is untouched.
|
|
if a.Stages[1].Nodes[0].Title != "Intention substrate" {
|
|
t.Fatalf("authored stage was altered: %+v", a.Stages[1])
|
|
}
|
|
|
|
// Substrate preserved.
|
|
if len(a.Substrate) != 1 || a.Substrate[0].Name != "koala" {
|
|
t.Fatalf("substrate not preserved: %+v", a.Substrate)
|
|
}
|
|
}
|
|
|
|
func TestDefault_HasPlainLayerAndTransitions(t *testing.T) {
|
|
a, err := atlas.Build(atlas.DataJSON, []byte("jobs:\n guard:\n a: 1\n"))
|
|
if err != nil {
|
|
t.Fatalf("Build embedded atlas: %v", err)
|
|
}
|
|
for _, s := range a.Stages {
|
|
if s.PlainTitle == "" {
|
|
t.Fatalf("stage %s missing plain_title", s.No)
|
|
}
|
|
if s.TransLabel == "" {
|
|
t.Fatalf("stage %s missing trans_label", s.No)
|
|
}
|
|
if s.Generate == "ci-jobs" {
|
|
continue // nodes are generated live, no authored plain
|
|
}
|
|
for _, n := range s.Nodes {
|
|
if n.Plain == "" {
|
|
t.Fatalf("stage %s node %q missing plain", s.No, n.Title)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestBuild_ErrorsOnBadAtlasJSON(t *testing.T) {
|
|
if _, err := atlas.Build([]byte("{not json"), []byte("jobs:\n x:\n a: 1\n")); err == nil {
|
|
t.Fatal("expected error on bad atlas JSON, got nil")
|
|
}
|
|
}
|