package thintest
import (
"regexp"
"strings"
"testing"
)
// taskRow is one task's row on a list page.
func taskRow(t *testing.T, page, id string) string {
t.Helper()
row := regexp.MustCompile(`(?s)
`).FindString(page)
if row == "" {
t.Fatalf("no row for %s in:\n%s", id, page)
}
return row
}
// TestPagesTaskRows: every row is one grid of project, task, status,
// from, updated and the action slot. A Needs you row carries its one
// action, mapped to the handler its decision card uses; an exploration
// waiting on its direction leads with What next?, which opens the
// direction card. Done shows the newest row and the rest behind "Show N
// more".
func TestPagesTaskRows(t *testing.T) {
f := newRowsFixture(t, 2)
r := f.r
owner := r.inst.Cookie()
tasks := r.get(owner, "/tasks", 200)
// The column names, once, for the eye only.
if n := strings.Count(tasks, `
`); n != 1 {
t.Fatalf("%d column heads", n)
}
for _, col := range []string{"Project", "Task", "Status", "From", "Updated"} {
if !strings.Contains(tasks, col) {
t.Fatalf("column head lacks %s", col)
}
}
// One action per Needs you row, each the decision's own handler.
for _, c := range []struct{ id, kind, label, open string }{
{f.retry, "retry", "Retry", `