package web
import (
"strings"
"testing"
)
// The Landings tab is the review queue: each landing the reader could
// accept, linked into its own repository, counted on the tab. The
// reader's own landings moving is not what the tab is for.
func TestInboxLandingsTabIsTheReviewQueue(t *testing.T) {
queue := []queueRow{
{Repo: "quarry", ID: "7be08128b9420890", Branch: "zit-0.3.34", Target: "trunk",
Title: "Build with zit 0.3.34", Author: "zeitgeist", Updated: "2026-09-28T18:40:00Z", CI: "ci-pass"},
{Repo: "pikchr-studio", ID: "bc297c1c00000000", Branch: "readme", Target: "trunk",
Title: "README", Author: "zeitgeist", Updated: "2026-09-28T12:00:00Z"},
}
rows := append(inboxRows(), attnRow{ID: "local:3", Seq: 3, Kind: "landing", Repo: "quarry", Reason: "moved"})
data := pageData{Title: "inbox", AttnFilter: "landings", LandingQueue: queue,
AttnTabs: attnFilters(rows, len(queue), "landings"), AttnEmpty: inboxEmptyLine("landings")}
var b strings.Builder
if err := noHooks.template(inboxPage).ExecuteTemplate(&b, "content", data); err != nil {
t.Fatal(err)
}
got := b.String()
for _, want := range []string{
`data-hook="landing-queue"`,
`data-landing="7be08128b9420890"`, `data-repo="quarry"`,
`/landing/7be08128b942"`, `data-landing="bc297c1c00000000"`,
} {
if !strings.Contains(got, want) {
t.Errorf("FAIL: the queue misses %q:\n%s", want, got)
}
}
if strings.Contains(got, `data-seq="3"`) {
t.Error("FAIL: the landings tab lists attention rows instead of the queue")
}
for _, tab := range data.AttnTabs {
if tab.Key == "landings" && tab.Count != len(queue) {
t.Errorf("FAIL: the landings tab counts %d, the queue holds %d", tab.Count, len(queue))
}
}
t.Log("ok: the landings tab lists the review queue and counts it")
}