package web
import (
"strings"
"testing"
)
// A failing trunk puts a dot inside the Timeline tab; a passing one
// leaves the tab exactly as it was.
func TestAFailingTrunkMarksTheTimelineTab(t *testing.T) {
link := navlink("/r/q", "timeline", "Timeline", "", true, 12)
if got := withdot(link, false); got != link {
t.Errorf("FAIL: a green trunk changed the tab: %s", got)
}
got := string(withdot(link, true))
i, j := strings.Index(got, `data-hook="trunk-red"`), strings.LastIndex(got, "</a>")
if i < 0 || j < i {
t.Errorf("FAIL: a red trunk has no dot inside the tab: %s", got)
}
}
// Just accepted, the merge's run is still going: the record says the
// merge is being checked, not that the branch's checks passed.
func TestAnAcceptedLandingSaysItsMergeIsBeingChecked(t *testing.T) {
l := landingDetail{MergeCI: "ci-run", MergeCIRun: "run1"}
l.State = "accepted"
s := l.ChecksSummary()
if s.State != "wait" || !s.Merge {
t.Errorf("FAIL: a running merge reads as %+v", s)
}
}