fix(web): detail row lookup walks all pages of the Site read (#144)
This commit is contained in:
+33
-1
@@ -1881,7 +1881,7 @@ func TestAdminSeriesDetailRendersFacts(t *testing.T) {
|
||||
"SP Baby",
|
||||
"kagane:sp-baby · kagane · manga",
|
||||
"ch 45",
|
||||
"checked 2h0m0s ago",
|
||||
"checked 2h0m",
|
||||
"2 readers",
|
||||
} {
|
||||
if !strings.Contains(body, want) {
|
||||
@@ -2009,6 +2009,38 @@ func TestAdminSeriesDetailUnknownKey404(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// A Series past the first page of its Site's read (50 rows) must still
|
||||
// render: the list shows it, so its detail link may not answer 404. The row
|
||||
// lookup walks the window total, not just page 1.
|
||||
func TestAdminSeriesDetailBeyondFirstPage(t *testing.T) {
|
||||
router, st := newWebTestServer(t, testConfig())
|
||||
for i := 0; i < 55; i++ {
|
||||
seed(t, st, store.Bookmark{
|
||||
Key: fmt.Sprintf("asura:s%03d", i), Site: "asura", SeriesID: fmt.Sprintf("s%03d", i),
|
||||
Title: "Bulk", SeriesURL: "https://asurascans.com/series/bulk",
|
||||
Kind: "manga",
|
||||
})
|
||||
}
|
||||
// Rows order by (latest_checked_at, site, series_id), all zero stamps, so
|
||||
// "zzz" lands on page 2 behind the fifty-five "s*" rows.
|
||||
seed(t, st, store.Bookmark{
|
||||
Key: "asura:zzz", Site: "asura", SeriesID: "zzz",
|
||||
Title: "Late", SeriesURL: "https://asurascans.com/series/zzz",
|
||||
Kind: "manga",
|
||||
})
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/admin/series/asura:zzz", nil)
|
||||
req.AddCookie(sessionCookie(t, st))
|
||||
rr := httptest.NewRecorder()
|
||||
router.ServeHTTP(rr, req)
|
||||
if rr.Code != http.StatusOK {
|
||||
t.Fatalf("GET /admin/series/asura:zzz status = %d, want 200 for a page-2 row", rr.Code)
|
||||
}
|
||||
if !strings.Contains(rr.Body.String(), "Late") {
|
||||
t.Errorf("page-2 row did not render:\n%s", rr.Body.String())
|
||||
}
|
||||
}
|
||||
|
||||
// The title and the key line come from the database, so they must render
|
||||
// escaped: a title that is markup stays markup in the response, never HTML.
|
||||
func TestAdminSeriesDetailEscapesStoredStrings(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user