upddate
This commit is contained in:
1 parent
ff6c2df618
commit
43cfaa0411
18 files changed
+683
-299
No files matched your search
@@ -0,0 +1,66 @@
|
||||
package aiprompts
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSEOProductHTMLAllLocales(t *testing.T) {
|
||||
for _, lang := range OfflinePromptLanguages() {
|
||||
prompt, err := OfflineDefaultPrompt(lang)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
body := DescriptionSectionInstructions(prompt)
|
||||
if strings.Count(body, "<p>{") != 2 || strings.Count(body, "<h2>{") != 2 || strings.Count(body, "<ul><li>{") != 1 {
|
||||
t.Fatalf("%s invalid HTML: %s", lang, body)
|
||||
}
|
||||
formula := DeriveDescriptionFormulaFromLegacyParts(LegacyEnhanceParts{DescriptionRules: body, WasLegacy: true})
|
||||
if len(formula.Sections) != 5 {
|
||||
t.Fatalf("%s got %d sections; want 5: %+v", lang, len(formula.Sections), formula.Sections)
|
||||
}
|
||||
got := []string{}
|
||||
for _, section := range formula.Sections {
|
||||
got = append(got, section.Type)
|
||||
}
|
||||
if strings.Join(got, ",") != "p,h2,p,h2,ul" {
|
||||
t.Fatalf("%s wrong sections %v", lang, got)
|
||||
}
|
||||
if !formula.Sections[3].Optional || !formula.Sections[4].Optional {
|
||||
t.Fatalf("%s missing optional flags", lang)
|
||||
}
|
||||
if strings.Contains(body, "<h1>") || strings.Contains(body, "<b>") {
|
||||
t.Fatalf("%s non-semantic HTML", lang)
|
||||
}
|
||||
if strings.Contains(body, "five distinct H2") || strings.Contains(body, "pet različitih naslova H2") {
|
||||
t.Fatalf("%s repetitive formula", lang)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSEOEnglishMetaSplit(t *testing.T) {
|
||||
parts := ParseLegacyCombinedEnhancePrompt(GenericDefaultCategoryPrompt)
|
||||
if !parts.WasLegacy {
|
||||
t.Fatal("English default not parsed")
|
||||
}
|
||||
meta := DeriveDescriptionFormulaFromLegacyParts(parts)
|
||||
if !strings.HasPrefix(meta.MetaTitle, "Create a distinct") {
|
||||
t.Fatalf("metaTitle=%s", meta.MetaTitle)
|
||||
}
|
||||
if !strings.HasPrefix(meta.MetaDescription, "Summarize what") {
|
||||
t.Fatalf("metaDescription=%s", meta.MetaDescription)
|
||||
}
|
||||
if strings.Contains(meta.MetaDescription, "meta_title:") {
|
||||
t.Fatal("title rule leaked into description")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSEOUpgradeHasPreviousVersionAndDifferentHashSource(t *testing.T) {
|
||||
for _, name := range []string{"Televisions", "Grohe mixers", "High chairs"} {
|
||||
old := PriorDefaultCategoryFormula("", name)
|
||||
now := DefaultCategoryFormula("", name)
|
||||
if old.Overlay == "" || now.Overlay == "" || old.Overlay == now.Overlay {
|
||||
t.Fatalf("%s migration source missing", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user