Latest Chapter provenance line naming the actor class (#152)

This commit is contained in:
2026-08-22 09:32:25 +07:00
parent e1d61534bb
commit a4491babed
4 changed files with 117 additions and 2 deletions
+54
View File
@@ -2722,6 +2722,60 @@ func TestAdminSeriesDetailRendersMarks(t *testing.T) {
}
}
// The provenance line beside the chapter names the actor class behind the
// value — "machine read" for a checked Series, "correction" for the owner's
// stamp, "sighting" for a Reader-raised one — and appears nowhere in the
// rendered Series list: an actor class is context for the Series the owner is
// already looking at, never a population to sweep (#152).
func TestAdminSeriesDetailProvenanceLine(t *testing.T) {
router, st := newWebTestServer(t, testConfig())
seed(t, st, store.Bookmark{
Key: "asura:machine", Site: "asura", SeriesID: "machine",
Title: "Machine", SeriesURL: "https://asurascans.com/series/machine",
Kind: "manga", LatestChapter: "45", LatestChapterNum: floatPtr(45),
})
if err := st.MarkLatestChecked("asura", "machine", time.Now().Add(-time.Hour).UnixMilli()); err != nil {
t.Fatalf("MarkLatestChecked: %v", err)
}
seed(t, st, store.Bookmark{
Key: "asura:hand", Site: "asura", SeriesID: "hand",
Title: "Hand", SeriesURL: "https://asurascans.com/series/hand",
Kind: "manga", LatestChapter: "12", LatestChapterNum: floatPtr(12),
})
if err := st.CorrectLatestChapter("asura", "hand", 13, time.Now().UnixMilli()); err != nil {
t.Fatalf("CorrectLatestChapter: %v", err)
}
seed(t, st, store.Bookmark{
Key: "demonic:raised", Site: "demonic", SeriesID: "raised",
Title: "Raised", SeriesURL: "https://demonicscans.org/series/raised",
Kind: "manga",
})
if err := st.RecordSighting(st.OwnerID(), "demonic", "raised", floatPtr(7), time.Now().UnixMilli()); err != nil {
t.Fatalf("RecordSighting: %v", err)
}
for _, tc := range []struct{ key, want string }{
{"asura:machine", "machine read"},
{"asura:hand", "correction"},
{"demonic:raised", "sighting"},
} {
body := seriesDetailPage(t, router, st, tc.key)
if !strings.Contains(body, "<span>"+tc.want+"</span>") {
t.Errorf("detail %s lacks the %q provenance line:\n%s", tc.key, tc.want, body)
}
}
listBody := adminSeriesPage(t, router, st, "")
for _, word := range []string{"machine read", "correction", "sighting"} {
if strings.Contains(listBody, "<span>"+word+"</span>") {
t.Errorf("Series list carries a %q provenance line:\n%s", word, listBody)
}
}
}
// A well-formed key naming no row is a 404, and so is a key with no ":",
// an empty Site or an empty SeriesID — the detail page never answers 500 for
// an address nobody can reach.