Artifact 68388b11db03f6092268be10c40c92ca37e728d23d4b107bd497994ffc8fc151:
- File
internal/web/strata_test.go
— part of check-in
[02f6aadcad]
at
2026-08-27 00:03:48
on branch strata-ui
— Landings: a strata is one row, and a map on the record
The open queue folds a stack under its base: a strata mark, the segment count, the landable end named, and the rungs in a details element with 1/N badges — no script. Settled views stay flat; a settled segment has left its chain.
The record page draws the map: every rung bottom-up, this one marked, the landable one named, a rejected base as a broken rung. Above the bottom the accept control is disabled and says the segment below lands first.
Proved with a real zit: two stacked landings count one decision; the top rung's accept is refused; accepting the base retargets the next onto trunk and it becomes the landable end, still one decision. (user: dmestas, size: 4427) [annotate] [blame] [check-ins using] [more...]
package web import ( "strings" "testing" "craftdesign.group/quarry/internal/api" "craftdesign.group/quarry/internal/artifact" "craftdesign.group/quarry/internal/index" "craftdesign.group/quarry/internal/ops" "net/http/httptest" "path/filepath" ) // Three landings chained feat-c → feat-b → feat-a → trunk, all open, // plus one standalone. Four open landings; two decisions. func strataIndex(t *testing.T) *index.Index { t.Helper() ix, err := index.Open(filepath.Join(t.TempDir(), "index.db")) if err != nil { t.Fatal(err) } t.Cleanup(func() { ix.Close() }) root := func(hash, branch, target, title, date string) index.Parsed { return index.Parsed{Hash: hash, Art: &artifact.Artifact{Type: artifact.Forum, ThreadTitle: title, Date: date, User: "dan", Mimetype: "text/x-markdown", Body: []byte("zit-landing: 1\nbranch: " + branch + "\ntarget: " + target + "\n\n" + title + "\n")}} } if err := ix.FoldNow([]index.Parsed{ root(strings.Repeat("a1", 20), "feat-a", "trunk", "phase one", "2026-08-20T09:00:00"), root(strings.Repeat("b2", 20), "feat-b", "feat-a", "phase two", "2026-08-20T09:10:00"), root(strings.Repeat("c3", 20), "feat-c", "feat-b", "phase three", "2026-08-20T09:20:00"), root(strings.Repeat("d4", 20), "lone", "trunk", "a loner", "2026-08-20T09:30:00"), }); err != nil { t.Fatal(err) } return ix } func strataServer(t *testing.T, ix *index.Index) *httptest.Server { t.Helper() r := ops.NewRegistry() if err := api.RegisterAll(r, api.Deps{Version: "v", Repos: api.NewRepos(map[string]*api.Repo{"alpha": {Index: ix}})}); err != nil { t.Fatal(err) } srv := httptest.NewServer(HandlerWith(r, nil, nil, []Option{WithSessions(fakeSessions{user: "dan"}), WithCaps(stubCaps{letters: "i"})})) t.Cleanup(srv.Close) return srv } // RFC 0006: a strata that looks like three landings is worse than no // strata feature. The open queue shows it as ONE row, counts it as one // decision, and folds the rungs under it with their positions. func TestStrataListsAsOneDecision(t *testing.T) { srv := strataServer(t, strataIndex(t)) html := asDan(t, srv, "/r/alpha/landing") if strings.Count(html, `<li class="t-row`) != 2 { t.Fatalf("want 2 rows (the stack and the loner), got %d:\n%.1200s", strings.Count(html, `<li class="t-row`), html) } if !strings.Contains(html, `t-strata`) || !strings.Contains(html, "3 segments") { t.Errorf("the stack row is not marked as a strata of 3") } if !strings.Contains(html, `title="2">2</span> Open<`) { i := strings.Index(html, "Open</a>") if i < 0 { i = len(html) } t.Errorf("the count chip does not count decisions (want 2 Open): %q", html[max(0, i-160):min(len(html), i+12)]) } for _, badge := range []string{">1/3<", ">2/3<", ">3/3<"} { if !strings.Contains(html, badge) { t.Errorf("rung badge %s missing", badge) } } if !strings.Contains(html, "<details class=\"strata\">") { t.Error("the rungs are not folded under the base without script") } // The settled views stay flat: nothing to group. if all := asDan(t, srv, "/r/alpha/landing?state=all"); strings.Contains(all, "t-strata") { t.Error("the flat view grouped") } } // The record page: a map with this rung marked and the landable one // named; above the bottom, the accept control is disabled and says why. func TestStrataMapOnTheRecord(t *testing.T) { srv := strataServer(t, strataIndex(t)) top := asDan(t, srv, "/r/alpha/landing/"+strings.Repeat("c3", 6)) if !strings.Contains(top, `class="strata-map"`) || !strings.Contains(top, "3 segments") { t.Fatalf("no stack map on the top rung:\n%.1200s", top) } if !strings.Contains(top, `aria-current="true"`) { t.Error("the current rung is not marked") } if !strings.Contains(top, "phase one</a>") || !strings.Contains(top, "· landable") { t.Error("the landable base is not named in the map") } if !strings.Contains(top, "stacked — the segment below lands first") { t.Error("the accept control above the bottom is not disabled with the reason") } base := asDan(t, srv, "/r/alpha/landing/"+strings.Repeat("a1", 6)) if !strings.Contains(base, `formaction="/r/alpha/landing/a1a1a1a1a1a1/accept"`) { t.Error("the base's accept control is missing") } // A standalone landing has no map. if lone := asDan(t, srv, "/r/alpha/landing/"+strings.Repeat("d4", 6)); strings.Contains(lone, `class="strata-map"`) { t.Error("a standalone landing drew a stack map") } }