docs(33-12): demo patch tags a post in TestSEOOutput
demo:seed tags no post, so the tag_pages check in TestSEOOutput passed without config/golem15.journal.yaml as well. The test now tags the seeded post and requires /blog/tag/releases to resolve not_found; without the config it fails.
This commit is contained in:
@@ -798,10 +798,10 @@ index e2bec68..c344ec7 100755
|
||||
grep -qF 'SummerCMS basics' "$TMP/body" || fail "GET $SITE/quizzes: the quiz list is not rendered"
|
||||
diff --git a/seo_output_test.go b/seo_output_test.go
|
||||
new file mode 100644
|
||||
index 0000000..901ef44
|
||||
index 0000000..c7c5192
|
||||
--- /dev/null
|
||||
+++ b/seo_output_test.go
|
||||
@@ -0,0 +1,151 @@
|
||||
@@ -0,0 +1,171 @@
|
||||
+package main
|
||||
+
|
||||
+import (
|
||||
@@ -822,16 +822,27 @@ index 0000000..901ef44
|
||||
+// TestSEOOutput checks the SEO output the Nuxt site reads from the demo
|
||||
+// binary (Phase 33, SC-1/SC-2) on the seeded content: /sitemap.xml is a
|
||||
+// sitemap index of per-type files on the public origin and a file lists
|
||||
+// the Journal posts without tag addresses (golem15.journal.tag_pages is
|
||||
+// false); the SEO plugin's site answer names the origin, the locales and
|
||||
+// the HTML sitemap; a seeded post resolves with one JSON-LD @graph and
|
||||
+// breadcrumbs through its category; and the route report is accepted with
|
||||
+// golem15.seo.route_report_token.
|
||||
+// the Journal posts, while a tagged post adds no tag address and the tag's
|
||||
+// path does not resolve (golem15.journal.tag_pages is false in
|
||||
+// config/golem15.journal.yaml); the SEO plugin's site answer names the
|
||||
+// origin, the locales and the HTML sitemap; a seeded post resolves with
|
||||
+// one JSON-LD @graph and breadcrumbs through its category; and the route
|
||||
+// report is accepted with golem15.seo.route_report_token.
|
||||
+func TestSEOOutput(t *testing.T) {
|
||||
+ skipUnlessSEOMounted(t)
|
||||
+ const reportToken = "seo-output-test-route-report-token"
|
||||
+ demo := bootDemo(t, visitorEnv, map[string]any{"golem15.seo.route_report_token": reportToken})
|
||||
+ mustSeed(t, demo)
|
||||
+ // demo:seed tags no post; one tag makes the tag_pages check meaningful.
|
||||
+ var tagID uint
|
||||
+ if err := demo.DB.Raw(`INSERT INTO golem15_journal_tags (name, slug, created_at, updated_at)
|
||||
+VALUES ('Releases', 'releases', NOW(), NOW()) RETURNING id`).Scan(&tagID).Error; err != nil || tagID == 0 {
|
||||
+ t.Fatalf("tag: id=%d err=%v", tagID, err)
|
||||
+ }
|
||||
+ if err := demo.DB.Exec(`INSERT INTO golem15_journal_posts_tags (post_id, tag_id)
|
||||
+SELECT id, ? FROM golem15_journal_posts WHERE slug = 'welcome-to-summercms'`, tagID).Error; err != nil {
|
||||
+ t.Fatal(err)
|
||||
+ }
|
||||
+ if out, err := runCommand(t, demo, "sitemap:rebuild"); err != nil {
|
||||
+ t.Fatalf("sitemap:rebuild: %v\n%s", err, out)
|
||||
+ }
|
||||
@@ -871,7 +882,16 @@ index 0000000..901ef44
|
||||
+ t.Fatalf("sitemap-posts-1.xml does not list the seeded post:\n%s", posts)
|
||||
+ }
|
||||
+ if strings.Contains(index, "sitemap-tags-") || strings.Contains(posts, "/blog/tag/") {
|
||||
+ t.Fatalf("the sitemaps name tag addresses although golem15.journal.tag_pages is false")
|
||||
+ t.Fatalf("the sitemaps name tag addresses although golem15.journal.tag_pages is false:\n%s", index)
|
||||
+ }
|
||||
+ var answer struct {
|
||||
+ Action string `json:"action"`
|
||||
+ }
|
||||
+ if err := json.Unmarshal([]byte(get("/_seo/api/v1/resolve?url=/blog/tag/releases")), &answer); err != nil {
|
||||
+ t.Fatal(err)
|
||||
+ }
|
||||
+ if answer.Action != "not_found" {
|
||||
+ t.Fatalf("/blog/tag/releases resolves %q, want not_found (no tag pages)", answer.Action)
|
||||
+ }
|
||||
+ })
|
||||
+
|
||||
|
||||
Reference in New Issue
Block a user