package aiprompts import ( "strings" "testing" ) func TestCategoryEnhanceUserTemplateHasRequiredVars(t *testing.T) { t.Parallel() vars := ExtractVariables(CategoryEnhanceUserTemplate) want := []string{"language", "category", "name", "description", "attrs"} got := map[string]struct{}{} for _, v := range vars { got[v] = struct{}{} } for _, w := range want { if _, ok := got[w]; !ok { t.Fatalf("CategoryEnhanceUserTemplate missing {{%s}}; vars=%v", w, vars) } } lower := strings.ToLower(CategoryEnhanceUserTemplate) if strings.Contains(lower, "100 besed") || strings.Contains(lower, "gpt predloga") { t.Fatal("template must not demand legacy long HTML marketing docs") } if !strings.Contains(CategoryEnhanceUserTemplate, `{"name":"string","description":"string"}`) { t.Fatal("template should reference JSON schema shape") } if !strings.Contains(lower, "{{language}}") { t.Fatal("language must come from {{language}}") } } func TestCategoryEnhancePromptNeedsRepair(t *testing.T) { t.Parallel() if CategoryEnhancePromptNeedsRepair("") { t.Fatal("empty should not need repair") } if CategoryEnhancePromptNeedsRepair(CategoryEnhanceUserTemplate) { t.Fatal("canonical template should be idempotent") } if CategoryEnhancePromptNeedsRepair(" " + CategoryEnhanceUserTemplate + "\n") { t.Fatal("whitespace-trimmed canonical should be idempotent") } legacy := `Ustvari nov opis\n

foo

\nAttrs missing` if !CategoryEnhancePromptNeedsRepair(legacy) { t.Fatal("legacy HTML prompt should need repair") } } func TestBuiltInProductEnhanceUsesSharedUserTemplate(t *testing.T) { t.Parallel() def, ok := DefaultFor(KeyProductEnhance) if !ok { t.Fatal("missing product_enhance default") } if def.UserTemplate != CategoryEnhanceUserTemplate { t.Fatalf("UserTemplate must be CategoryEnhanceUserTemplate") } }