audit 4: cards ordered by number, a notification owed to each recipient
test / test (push) Canceled after 0s
test / test (push) Canceled after 0s
The cards layout (owner, 2026-10-13; the mockup first, b90a2f0): box_open
writes data-order for a box with InCards and a number, and panel.css orders
by it up to twelve - Health's eight and the kit's three.
TestCardsBoxesCarryTheirNumberAsTheirOrder reads the rendered pages.
Notifications (owner, 2026-10-14): migration 0011, notify_addressees. open
sends a subject's first message to every recipient and records who was
handed it; followUp, on every check while the subject is open and still
wrong, hands it to the owed and untold who are still recipients; closed
sends the end to the told (all recipients for a subject from before the
table). Tests: a failed copy goes out at the next check, once; the hourly
ceiling holds one back; a user added mid-subject hears nothing of it.
Also in the roadmap, from the owner today: dns-record-collapse,
notification-mail-recheck, settings-save-row (agreed, design first).
Tested on the test server: go vet + go test of 25 packages, make e2e (all
pass, 644 s) on this tree.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
package view
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// On a phone the cards layout shows its boxes in the order of their numbers,
|
||||
// whichever stack they stand in: each box of the layout carries its number as
|
||||
// data-order, and the stylesheet has a rule for it. Before, the stylesheet
|
||||
// ordered by a box's place in its stack and knew four to a stack; a fifth
|
||||
// landed out of place with nothing failing (owner, 2026-10-13).
|
||||
func TestCardsBoxesCarryTheirNumberAsTheirOrder(t *testing.T) {
|
||||
css, err := os.ReadFile("static/panel.css")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
box := regexp.MustCompile(`<div class="box[^"]*"[^>]*?(?: data-order="(\d+)")?>\s*<div class="sp-box-head"><span class="sp-no">(\d+)</span>`)
|
||||
rec := httptest.NewRecorder()
|
||||
kitEngine(t).Render(rec, http.StatusOK, "components", KitPage())
|
||||
for name, page := range map[string]string{
|
||||
"health": renderSignedIn(t, "health", healthFixture(false)),
|
||||
"kit": rec.Body.String(),
|
||||
} {
|
||||
start := strings.Index(page, `<div class="columns sp-cards">`)
|
||||
if start < 0 {
|
||||
t.Fatalf("%s has no cards layout", name)
|
||||
}
|
||||
// The layout runs to the first page part after it that is not a box
|
||||
// of it; its boxes are the numbered ones up to there.
|
||||
region := page[start:]
|
||||
if end := strings.Index(region, `<footer`); end > 0 {
|
||||
region = region[:end]
|
||||
}
|
||||
found := 0
|
||||
for _, m := range box.FindAllStringSubmatch(region, -1) {
|
||||
order, no := m[1], strings.TrimLeft(m[2], "0")
|
||||
if name == "kit" && found == 3 {
|
||||
break // the kit's cards hold three numbered boxes; the rest of the page is other sections
|
||||
}
|
||||
found++
|
||||
if order != no {
|
||||
t.Errorf("%s: box %s carries data-order %q", name, m[2], order)
|
||||
continue
|
||||
}
|
||||
if !strings.Contains(string(css), `.sp-cards [data-order="`+order+`"] { order: `+order+`; }`) {
|
||||
t.Errorf("%s: panel.css has no rule for data-order %s", name, order)
|
||||
}
|
||||
}
|
||||
if found == 0 {
|
||||
t.Errorf("%s: no numbered boxes in the cards layout", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Outside the cards layout a box has no order: the attribute is the layout's.
|
||||
func TestABoxOutsideCardsHasNoOrder(t *testing.T) {
|
||||
if got := (Box{No: "03"}).Order(); got != "" {
|
||||
t.Errorf("a box outside cards has order %q", got)
|
||||
}
|
||||
if got := (Box{No: "03", InCards: true}).Order(); got != "3" {
|
||||
t.Errorf("a cards box 03 has order %q", got)
|
||||
}
|
||||
if got := (Box{Icon: "ti-x", InCards: true}).Order(); got != "" {
|
||||
t.Errorf("a cards box without a number has order %q", got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user