This commit is contained in:
greeneclipse committed 2026-10-14 19:23:16 +02:00
1 parent ff6c2df618
commit 43cfaa0411
18 files changed
+683 -299

No files matched your search

+36 -17
View File
@@ -77,8 +77,12 @@ func TestDedupeStructuredA1Descriptions(t *testing.T) {
}
}
func TestNormalizeA1RepeatedBenefitsKeepsFiveDistinctSections(t *testing.T) {
source := `<H2>{Napiši Novo ime izdelka brez barve in izpostavi en benefit}</H2>
func TestNormalizeA1LegacySEOHTML(t *testing.T) {
source := `--- Title ---
Napiši Novo ime izdelka
--- End Title ---
--- Description ---
<H2>{Napiši Novo ime izdelka brez barve in izpostavi en benefit}</H2>
<p>{Napiši odstavek, ki je dolg 100 besed, ki NE vsebuje Novo ime izdelka.}</p>
<H2>{Izpostavi en benefit, in NE napiši Novo ime izdelka}</H2>
<p>{Napiši odstavek, ki je dolg 100 besed in VKLJUČI tudi Novo ime izdelka.}</p>
@@ -87,26 +91,26 @@ func TestNormalizeA1RepeatedBenefitsKeepsFiveDistinctSections(t *testing.T) {
<H2>{Izpostavi en benefit, in NE napiši Novo ime izdelka}</H2>
<p>{Napiši odstavek, ki je dolg 100 besed in VKLJUČI tudi Novo ime izdelka.}</p>
<H2>{Izpostavi en benefit, in NE napiši Novo ime izdelka}</H2>
<p>{Napiši odstavek, ki je dolg 100 besed, ki NE vsebuje Novo ime izdelka.}</p><b>{Tehnične specifikacije}</b><ul><li>{Napiši 3-10 tehničnih specifikacij v alinejah}</li></ul>`
result, rewritten := NormalizeA1RepeatedBenefits(source)
if rewritten != 3 {
t.Fatalf("rewritten=%d want 3", rewritten)
<p>{Napiši odstavek, ki je dolg 100 besed, ki NE vsebuje Novo ime izdelka.}</p><b>{Tehnične specifikacije}</b><ul><li>{Napiši 3-10 tehničnih specifikacij v alinejah}</li></ul>
--- End Description ---
--- Meta ---
Najprej Novo ime izdelka
--- End Meta ---`
result, changed := NormalizeA1RepeatedBenefits(source)
if changed != 5 {
t.Fatalf("expected five legacy boilerplate pairs, got %d", changed)
}
if strings.Count(result, "<H2>") != 5 || strings.Count(result, "<p>") != 5 {
t.Fatalf("lost section: %s", result)
for _, want := range []string{"--- Title ---", "Napiši Novo ime izdelka", "--- Meta ---", "Najprej Novo ime izdelka", "<p>{", "<h2>{", "<ul><li>{"} {
if !strings.Contains(result, want) {
t.Fatalf("missing %q: %s", want, result)
}
}
if !strings.Contains(result, "3. drugačno") || !strings.Contains(result, "4. drugačno") || !strings.Contains(result, "5. drugačno") {
t.Fatalf("not distinct: %s", result)
}
if strings.Count(result, "VKLJUČI") != 1 || strings.Count(result, "vključi naravno natanko enkrat") != 1 {
t.Fatalf("failed inclusion preservation: %s", result)
}
if !strings.Contains(result, "Tehnične specifikacije") {
t.Fatal("lost technical specifications")
if strings.Count(result, "<h2>") != 2 || strings.Contains(result, "100 besed") {
t.Fatalf("still repetitive: %s", result)
}
again, n := NormalizeA1RepeatedBenefits(result)
if n != 0 || again != result {
t.Fatalf("not idempotent: %d %s", n, again)
t.Fatal("SEO upgrade must be idempotent")
}
}
@@ -124,3 +128,18 @@ func TestNormalizeA1StructuredKeepsSections(t *testing.T) {
t.Fatal("not idempotent")
}
}
func TestNormalizeA1LegacyStructuredSEO(t *testing.T) {
raw := `{"sections":[{"type":"h2","instructions":"Napiši Novo ime izdelka brez barve in izpostavi en benefit"},{"type":"p","instructions":"Napiši odstavek, ki je dolg 100 besed, ki NE vsebuje Novo ime izdelka"},{"type":"h2","instructions":"Izpostavi en benefit"},{"type":"p","instructions":"Napiši odstavek, ki je dolg 100 besed in VKLJUČI Novo ime izdelka"},{"type":"h2","instructions":"Napiši Novo ime izdelka"},{"type":"p","instructions":"Napiši odstavek, ki je dolg 100 besed"},{"type":"h2","instructions":"Benefit"},{"type":"p","instructions":"Napiši odstavek, ki je dolg 100 besed"},{"type":"ul","instructions":"Tehnične specifikacije"}],"metaDescription":"140 znakov"}`
clean, n, err := NormalizeA1DescriptionTemplate(raw)
if err != nil || n != 4 {
t.Fatalf("changed=%d err=%v", n, err)
}
if !strings.Contains(clean, `"type":"ul"`) || !strings.Contains(clean, `140 znakov`) || strings.Contains(clean, "100 besed") {
t.Fatal(clean)
}
twice, n, err := NormalizeA1DescriptionTemplate(clean)
if err != nil || n != 0 || twice != clean {
t.Fatal("not repeatable")
}
}