test: Journal-shaped records in the hreflang test

TestHreflangAlternates uses a record shaped as the Journal descriptors
describe one: every enabled locale in sort order, the untranslated one
with URL "" and the default locale's title, description and word
count; the files still carry no hreflang for that locale.
This commit is contained in:
Jakub Zych
2026-11-04 23:28:49 +01:00
parent da32044d5b
commit b2b3a1d218

View File

@@ -644,8 +644,14 @@ func TestHreflangAlternates(t *testing.T) {
t.Fatal(err)
}
mod := time.Date(2026, 10, 1, 8, 0, 0, 0, time.UTC)
// G3: a Journal-shaped record (P33-64): every enabled locale in sort
// order, the untranslated de with URL "" and the default locale's
// title, description and word count.
words := 120
contentStore.put(pageType, fakeRecord{ID: 1, Published: true, LastMod: mod, Locales: []pact.ContentLocale{
{Locale: "en", URL: "/en/pages/a"}, {Locale: "pl", URL: "/strony/a"}, {Locale: "de", URL: ""},
{Locale: "pl", URL: "/strony/a", Title: "Strona A", Description: "O stronie", Words: &words},
{Locale: "en", URL: "/en/pages/a", Title: "Page A", Description: "About the page", Words: &words},
{Locale: "de", URL: "", Title: "Strona A", Description: "O stronie", Words: &words},
}})
contentStore.put(pageType, fakeRecord{ID: 2, Published: true, LastMod: mod, Locales: []pact.ContentLocale{{Locale: "pl", URL: "/strony/b"}}})
e.rebuild(t)
@@ -653,8 +659,8 @@ func TestHreflangAlternates(t *testing.T) {
if !strings.Contains(body, `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">`) {
t.Fatalf("the xhtml namespace is not declared:\n%s", body)
}
alts := `<xhtml:link rel="alternate" hreflang="en" href="https://api.example.test/en/pages/a"/>` +
`<xhtml:link rel="alternate" hreflang="pl" href="https://api.example.test/strony/a"/>` +
alts := `<xhtml:link rel="alternate" hreflang="pl" href="https://api.example.test/strony/a"/>` +
`<xhtml:link rel="alternate" hreflang="en" href="https://api.example.test/en/pages/a"/>` +
`<xhtml:link rel="alternate" hreflang="x-default" href="https://api.example.test/strony/a"/>`
for _, loc := range []string{"https://api.example.test/en/pages/a", "https://api.example.test/strony/a"} {
if !strings.Contains(body, "<url><loc>"+loc+"</loc><lastmod>2026-10-01T08:00:00Z</lastmod>"+alts+"</url>") {