package catalog
import (
"strings"
"testing"
"github.com/descrybe/descrybe-v2/apps/api/internal/aiprompts"
"github.com/descrybe/descrybe-v2/apps/api/internal/company"
)
func TestRepairedCategoryEnhancePromptMap(t *testing.T) {
t.Parallel()
want, err := repairedCategoryEnhancePromptMap()
if err != nil {
t.Fatal(err)
}
tpl := strings.TrimSpace(aiprompts.CategoryEnhanceUserTemplate)
if want["sl"] != tpl {
t.Fatalf("want prompt->>'sl' = shared template")
}
if want[company.LangPromptAny] != tpl {
t.Fatalf("want * = shared template")
}
if !categoryEnhancePromptMapOK(want, want) {
t.Fatal("canonical map should be OK")
}
legacy := company.LangPromptMap{"sl": "
legacy HTML marketing
"}
if categoryEnhancePromptMapOK(legacy, want) {
t.Fatal("legacy HTML must need repair")
}
slOnly := company.LangPromptMap{"sl": tpl}
if !categoryEnhancePromptMapOK(slOnly, want) {
t.Fatal("sl-only repaired map should be OK (idempotent)")
}
starOnly := company.LangPromptMap{company.LangPromptAny: tpl}
if !categoryEnhancePromptMapOK(starOnly, want) {
t.Fatal("*-only repaired map should be OK (idempotent)")
}
}
func TestRepairTargetsUseSharedTemplate(t *testing.T) {
t.Parallel()
tpl := strings.TrimSpace(aiprompts.CategoryEnhanceUserTemplate)
for _, v := range []string{"name", "description", "attrs", "category", "language"} {
if !strings.Contains(tpl, "{{"+v+"}}") {
t.Fatalf("shared template missing {{%s}}", v)
}
}
if a1CompanyID == "" || platformDemoCompanyName == "" {
t.Fatal("missing company target constants")
}
}