fix
This commit is contained in:
@@ -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" +
|
||||
|
||||
Reference in New Issue
Block a user