fix
This commit is contained in:
@@ -105,6 +105,39 @@ func TestResolveProductPromptTemplates_categoryWithTitleFormula(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveProductPromptTemplates_derivesFormulaFromPromptHTML(t *testing.T) {
|
||||
t.Parallel()
|
||||
prompt := aiprompts.SectionTitleStart + "\n" +
|
||||
`Napiši novo ime izdelka po formuli: "tip izdelka sentence case", "znamka", "model". Ne uporabljaj vejic.` + "\n" +
|
||||
aiprompts.SectionTitleEnd + "\n\n" +
|
||||
aiprompts.SectionDescriptionStart + "\n" +
|
||||
`<H2>{Napiši Novo ime izdelka in izpostavi en benefit}</H2>` +
|
||||
`<p>{Napiši odstavek, ki je dolg 100 besed.}</p>` +
|
||||
`<b>{Tehnične specifikacije}</b><ul><li>{Napiši 3-10 tehničnih specifikacij}</li></ul>` + "\n" +
|
||||
aiprompts.SectionDescriptionEnd
|
||||
sys, user := resolveProductPromptTemplates(ProductInput{
|
||||
EnhanceSystemTemplate: "Retail copywriter.\n- description: 1-2 sentences",
|
||||
CategoryEnhancePrompt: prompt,
|
||||
// Empty structured template — production A1 path often only has prompt HTML.
|
||||
DescriptionTemplate: nil,
|
||||
})
|
||||
if !strings.Contains(user, "Description formula") {
|
||||
t.Fatalf("expected Description formula derived from prompt HTML:\n%s", user)
|
||||
}
|
||||
if !strings.Contains(user, "- h2:") || !strings.Contains(user, "- p:") || !strings.Contains(user, "- ul:") {
|
||||
t.Fatalf("expected h2/p/ul sections in formula:\n%s", user)
|
||||
}
|
||||
if !strings.Contains(sys, "Description formula") {
|
||||
t.Fatalf("missing description system override:\n%s", sys)
|
||||
}
|
||||
if !strings.Contains(sys, `"name" MUST be rewritten`) {
|
||||
t.Fatalf("missing title rewrite system override:\n%s", sys)
|
||||
}
|
||||
if descriptionSatisfiesFormula("plain Slovenian prose without tags", aiprompts.EffectiveDescriptionTemplateAny(nil, prompt)) {
|
||||
t.Fatal("plain prose must fail derived formula gate")
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveProductPromptTemplates_fallsBackToCompany(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, user := resolveProductPromptTemplates(ProductInput{
|
||||
|
||||
Reference in New Issue
Block a user