fix
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
package aiprompts
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSplitLegacyCombinedEnhancePrompt(t *testing.T) {
|
||||
t.Parallel()
|
||||
legacy := `Ustvari nov opis izdelka v Slovenščini z naslednjimi spremenljivkami:
|
||||
|
||||
Star_opis_izdelka: {""OPIS IZDELKA""};
|
||||
Staro_ime_izdelka: {""STARO IME IZDELKA""};
|
||||
|
||||
Uporabi spodnjo GPT predlogo.
|
||||
|
||||
Sledi tej GPT predlogi stavek po stavek in sestavi nov opis izdelka:
|
||||
|
||||
GPT predloga:
|
||||
|
||||
|
||||
<name>{Napiši novo ime izdelka po formuli: ""tip izdelka sentence case"", ""znamka s pravilno kapitalizacijo"". Ne uporabljaj vejic.}</name>
|
||||
<metaDescription>{Najprej napiši Novo_ime_izdelka in potem nadaljuj dokler nisi zapisal 140 znakov vključno s presledki}</metaDescription>
|
||||
|
||||
<H2>{Napiši Novo ime izdelka in izpostavi en benefit}</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>`
|
||||
|
||||
got := SplitLegacyCombinedEnhancePrompt(legacy)
|
||||
if !CategoryEnhanceHasRoleSections(got) {
|
||||
t.Fatal("split output must be role-sectioned")
|
||||
}
|
||||
if CategoryEnhancePromptNeedsRepair(got) {
|
||||
t.Fatal("split output should not need further repair")
|
||||
}
|
||||
if reLegacyNameTag.MatchString(got) || reLegacyMetaTag.MatchString(got) {
|
||||
t.Fatal("split must not keep legacy <name>/<metaDescription> wrapper tags")
|
||||
}
|
||||
if !strings.Contains(got, "tip izdelka sentence case") {
|
||||
t.Fatal("title section must preserve Slovenian naming formula intent")
|
||||
}
|
||||
if !strings.Contains(got, "140 znakov") {
|
||||
t.Fatal("meta section must preserve Slovenian SEO intent")
|
||||
}
|
||||
if !strings.Contains(got, "Tehnične specifikacije") && !strings.Contains(got, "tehničnih specifikacij") {
|
||||
t.Fatal("description section must preserve HTML body intent")
|
||||
}
|
||||
if !strings.Contains(got, "{{attrs}}") || !strings.Contains(got, "{{language}}") {
|
||||
t.Fatal("overlay must keep {{attrs}} and {{language}}")
|
||||
}
|
||||
if strings.Contains(got, "OPIS IZDELKA") || strings.Contains(got, "STARO IME IZDELKA") {
|
||||
t.Fatal("legacy placeholders must be modernized")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSplitLegacyNonLegacyFallsBackToTemplate(t *testing.T) {
|
||||
t.Parallel()
|
||||
got := SplitLegacyCombinedEnhancePrompt("short retail overlay")
|
||||
if strings.TrimSpace(got) != strings.TrimSpace(CategoryEnhanceUserTemplate) {
|
||||
t.Fatalf("non-legacy should fall back to canonical template")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsLegacyCombinedEnhancePrompt(t *testing.T) {
|
||||
t.Parallel()
|
||||
if IsLegacyCombinedEnhancePrompt(CategoryEnhanceUserTemplate) {
|
||||
t.Fatal("canonical template is not legacy combined")
|
||||
}
|
||||
if !IsLegacyCombinedEnhancePrompt("GPT predloga:\n<name>{x}</name><metaDescription>{y}</metaDescription>") {
|
||||
t.Fatal("expected legacy detection")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user