package web
import (
"strings"
"testing"
)
// A tracking mirror that holds check-ins its upstream lacks says so on
// the fleet row, with the count as data, so the operator can decide to
// detach it; a mirror with none carries no badge (5d40f151).
func TestTheFleetRowFlagsADivergedMirror(t *testing.T) {
var sb strings.Builder
rows := []mirrorRow{
{Repo: "fossil", Enabled: true, State: "current"},
{Repo: "wapp", Enabled: true, State: "current", Diverged: 2, DivergedLast: "abcdef0123456789"},
}
err := fleetAdminPage.ExecuteTemplate(&sb, "fleet-mirrors", pageData{
Mirrors: rows,
MirrorCounts: map[string]int{"all": 2, "current": 2},
})
if err != nil {
t.Fatal(err)
}
body := sb.String()
if strings.Count(body, `data-hook="mirror-diverged"`) != 1 || !strings.Contains(body, `data-hook="mirror-diverged" data-count="2"`) {
t.Fatal("FAIL: exactly one row should carry the diverged badge with its count")
}
t.Log("ok: wapp flagged with 2 local check-ins, fossil clean")
}