This commit is contained in:
2026-08-16 19:21:49 +02:00
parent d6fe7c38d5
commit 106f602232
8 changed files with 212 additions and 15 deletions
@@ -38,6 +38,9 @@ func TestFormatDescriptionFormulaConstraint(t *testing.T) {
map[string]any{"type": "ul", "instructions": "3 bullets of specs"},
},
})
if !strings.Contains(got, "REQUIRED") || !strings.Contains(got, "<hN>") {
t.Fatalf("missing required HTML guidance: %s", got)
}
if !strings.Contains(got, "- h1: Main product heading") {
t.Fatalf("missing h1: %s", got)
}
@@ -49,6 +52,30 @@ func TestFormatDescriptionFormulaConstraint(t *testing.T) {
}
}
func TestAppendDescriptionFormulaSystemOverride(t *testing.T) {
t.Parallel()
desc := map[string]any{
"sections": []any{
map[string]any{"type": "h1", "instructions": "Heading"},
map[string]any{"type": "p", "instructions": "Body"},
},
}
sys, user := resolveProductPromptTemplates(ProductInput{
EnhanceSystemTemplate: "Retail product copywriter.\n- description: 1-2 factual sentences",
EnhanceUserTemplate: "Name: {{name}}",
DescriptionTemplate: desc,
})
if !strings.Contains(user, "Description formula") {
t.Fatalf("missing user formula: %s", user)
}
if !strings.Contains(sys, "Description formula") || !strings.Contains(sys, "1-2 sentences") {
t.Fatalf("system should keep company text and append formula override: %s", sys)
}
if AppendDescriptionFormulaSystemOverride("plain", nil) != "plain" {
t.Fatal("empty formula must be no-op")
}
}
func TestAppendFormulaConstraints_injectedIntoResolve(t *testing.T) {
t.Parallel()
title := map[string]any{