fix: technical debts left by the Sites, Authors and SEO slices, plus backend support for the new Sites and Authors pagination

This commit is contained in:
Florian Sylvain committed 2026-10-19 00:25:31 +02:00
1 parent 9f4ce426a8
commit daf3594316
86 files changed
+4223 -1485

No files matched your search

+62 -2
View File
@@ -164,7 +164,7 @@ func TestSeoOutputList(t *testing.T) {
})
}
list := e.list(t, "owner", "?seo=suggestions")
if !reflect.DeepEqual(list["counts"], map[string]any{"all": 6.0, "online": 4.0, "draft": 2.0}) || list["total"] != 3.0 {
if !reflect.DeepEqual(list["counts"], map[string]any{"all": 6.0, "online": 4.0, "draft": 2.0, "suggestions": 3.0}) || list["total"] != 3.0 {
t.Errorf("list = %v %v", list["counts"], list["total"])
}
})
@@ -227,8 +227,68 @@ func TestSeoOutputList(t *testing.T) {
t.Run("The existing list behaviour is unchanged without the filter", func(t *testing.T) {
e := newSeoOutEnv(t)
list := e.list(t, "owner", "")
if list["total"] != 2.0 || list["page"] != 1.0 || list["size"] != 25.0 || !reflect.DeepEqual(list["counts"], map[string]any{"all": 2.0, "online": 1.0, "draft": 1.0}) {
if list["total"] != 2.0 || list["page"] != 1.0 || list["size"] != 25.0 || !reflect.DeepEqual(list["counts"], map[string]any{"all": 2.0, "online": 1.0, "draft": 1.0, "suggestions": 2.0}) {
t.Errorf("list = %v", list)
}
})
t.Run("counts.suggestions", func(t *testing.T) {
t.Run("It counts visible suggestions and equals the filter total", func(t *testing.T) {
e := newSeoOutEnv(t)
e.seedFourListed()
list := e.list(t, "owner", "")
filtered := e.list(t, "owner", "?seo=suggestions")
counts := list["counts"].(map[string]any)
if counts["suggestions"] != 2.0 || filtered["total"] != 2.0 || filtered["counts"].(map[string]any)["suggestions"] != 2.0 {
t.Errorf("counts = %v filtered = %v", counts, filtered["counts"])
}
})
t.Run("It is zero when nothing needs attention", func(t *testing.T) {
e := newSeoOutEnv(t)
e.cleanArticles()
for id := uint32(1); id <= 5; id++ {
e.seedListed(id, "Clean"+strconv.Itoa(int(id)), true, nil)
}
if got := e.list(t, "owner", "")["counts"].(map[string]any)["suggestions"]; got != 0.0 {
t.Errorf("suggestions = %v", got)
}
})
t.Run("It is scoped to the caller's visibility", func(t *testing.T) {
e := newSeoOutEnv(t)
e.cleanArticles()
e.seedListed(1, "Offline", false, func(a *article.Article) { a.CoverImageID, a.CoverImageAlt = nil, "" })
e.seedListed(2, "Online", true, func(a *article.Article) { a.CoverImageID, a.CoverImageAlt = nil, "" })
if got := e.list(t, "", "")["counts"].(map[string]any)["suggestions"]; got != 1.0 {
t.Errorf("anonymous suggestions = %v", got)
}
if got := e.list(t, "owner", "")["counts"].(map[string]any)["suggestions"]; got != 2.0 {
t.Errorf("owner suggestions = %v", got)
}
})
t.Run("It ignores the other query parameters", func(t *testing.T) {
e := newSeoOutEnv(t)
e.seedFourListed()
for _, query := range []string{"?q=nomatch", "?status=draft", "?seo=ready", "?size=5&page=9", "?sort=title:asc"} {
if got := e.list(t, "owner", query)["counts"].(map[string]any)["suggestions"]; got != 2.0 {
t.Errorf("%s: suggestions = %v", query, got)
}
}
})
t.Run("Hidden and dismissed articles are not counted", func(t *testing.T) {
e := newSeoOutEnv(t)
e.cleanArticles()
e.seedListed(1, "Dismissed", true, func(a *article.Article) {
a.CoverImageID, a.CoverImageAlt = nil, ""
a.SEODismissed = []string{"cover_none"}
})
e.seedListed(2, "Hidden", true, func(a *article.Article) { a.Noindex = true; a.CoverImageID, a.CoverImageAlt = nil, "" })
if got := e.list(t, "owner", "")["counts"].(map[string]any)["suggestions"]; got != 0.0 {
t.Errorf("suggestions = %v", got)
}
})
})
}