refactor(web): share poll-state derivation; keep zebra parity across a row swap (#146)

Review round: pollState() unifies the CanPoll/Pending/Requested derivation
used by the list row and the detail page, and the row anchor carries its
band parity with the press (hx-vals) so the swapped answer keeps the
alternation.
This commit is contained in:
2026-08-22 01:02:55 +07:00
parent fe2cd12049
commit 5b7adf5f2c
4 changed files with 51 additions and 19 deletions
+14
View File
@@ -2645,6 +2645,20 @@ func TestSeriesPollRoundTrip(t *testing.T) {
t.Errorf("poll response lacks the pending marker:\n%s", body)
}
// The press answers with the row's own band parity (hx-vals), so the swap
// keeps the zebra alternation.
req = httptest.NewRequest(http.MethodPost, "/admin/series/asura:x/poll", strings.NewReader("band=1"))
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.AddCookie(sessionCookie(t, st))
rr = httptest.NewRecorder()
router.ServeHTTP(rr, req)
if rr.Code != http.StatusOK {
t.Fatalf("POST poll (banded) status = %d, want 200", rr.Code)
}
if !strings.Contains(rr.Body.String(), `class="trow`) || !strings.Contains(rr.Body.String(), ` band"`) {
t.Errorf("banded press answer lost the zebra parity:\n%s", rr.Body.String())
}
// Detail surface: the meta fragment carries the same marker.
req = httptest.NewRequest(http.MethodPost, "/admin/series/asura:x/poll", nil)
req.AddCookie(sessionCookie(t, st))