This commit is contained in:
2026-08-23 16:34:50 +02:00
parent 815e26d359
commit a30b78c3b6
8 changed files with 178 additions and 33 deletions
@@ -93,6 +93,40 @@ func TestEffectiveDescriptionFormula_fromPromptDescriptionSection(t *testing.T)
}
}
func TestEffectiveDescriptionFormula_prefersRicherPromptHTML(t *testing.T) {
t.Parallel()
stored := map[string]any{
"sections": []any{
map[string]any{"type": "p", "instructions": "Short"},
},
"metaTitle": "Stored meta title rule",
}
prompt := SectionDescriptionStart + "\n" +
`<H2>{One}</H2><p>{Two}</p><H2>{Three}</H2><p>{Four}</p>` +
`<b>{Specs}</b><ul><li>{Bullets}</li></ul>` + "\n" +
SectionDescriptionEnd + "\n" +
SectionMetaStart + "\nIgnored because stored meta exists\n" + SectionMetaEnd
f := EffectiveDescriptionFormula(stored, prompt)
if len(f.Sections) < 4 {
t.Fatalf("want prompt HTML sections to win over thin stored, got %#v", f.Sections)
}
if f.MetaTitle != "Stored meta title rule" {
t.Fatalf("stored metaTitle should win, got %q", f.MetaTitle)
}
}
func TestEffectiveDescriptionFormula_metaSectionWhenStoredEmpty(t *testing.T) {
t.Parallel()
prompt := SectionMetaStart + "\nWrite meta_description to 140 chars.\n" + SectionMetaEnd
f := EffectiveDescriptionFormula(nil, prompt)
if !strings.Contains(f.MetaDescription, "140") {
t.Fatalf("metaDescription=%q", f.MetaDescription)
}
if strings.TrimSpace(f.MetaTitle) == "" {
t.Fatal("expected default metaTitle when Meta section present")
}
}
func TestExtractEnhanceSectionBody(t *testing.T) {
t.Parallel()
prompt := SectionTitleStart + "\nHello\n" + SectionTitleEnd + "\n" +