Skip to content
quarry Artifact [a518988419]
Login

Artifact [a518988419]

Artifact a5189884195aeaf31e928fad3845dee954e832fbaa95ce38fffbb8f29cbe3d9a:


package web

import (
	"strings"
	"testing"
)

// A branch tip is drawn as the quarry mark is: an open ring with the
// check-in dot at its centre. The ring alone only said "nothing follows
// this"; the dot says "and this is where the branch is now", which is
// the fact a reader is actually scanning the graph for.
//
// Every other check-in stays a solid node — if the two ever render the
// same, the graph stops answering "where is each branch now?" and the
// only way to find a tip is to read the branch list instead.
func TestBranchTipsCarryTheCentreDot(t *testing.T) {
	days := buildTimeline("r", []timelineEntry{
		{Kind: "checkin", Hash: "aaa", Date: "2026-08-18 10:00:00", Branch: "trunk", IsLeaf: true, Parents: []string{"bbb"}},
		{Kind: "checkin", Hash: "bbb", Date: "2026-08-18 09:00:00", Branch: "trunk"},
	})

	var tip, mid string
	for _, d := range days {
		for _, row := range d.Rows {
			switch row.Hash {
			case "aaa":
				tip = string(row.Head)
			case "bbb":
				mid = string(row.Head)
			}
		}
	}
	if tip == "" || mid == "" {
		t.Fatalf("timeline dropped a row: tip=%q mid=%q", tip, mid)
	}

	if !strings.Contains(tip, `r="4"`) || !strings.Contains(tip, `fill:var(--bg)`) {
		t.Errorf("the tip is not an open ring:\n%s", tip)
	}
	if !strings.Contains(tip, `r="1.6"`) {
		t.Errorf("the tip has no centre dot, so it reads as a dead end:\n%s", tip)
	}
	// The ring must stay hollow: a filled ring plus a dot is just a
	// slightly larger solid node and tells the reader nothing.
	if strings.Count(tip, "<circle") != 2 {
		t.Errorf("a tip should be exactly ring + dot, got:\n%s", tip)
	}

	if strings.Contains(mid, `r="1.6"`) || strings.Contains(mid, `fill:var(--bg)`) {
		t.Errorf("an ordinary check-in is being drawn as a tip:\n%s", mid)
	}
	if strings.Count(mid, "<circle") != 1 {
		t.Errorf("an ordinary check-in should be one solid node, got:\n%s", mid)
	}
}