package processing import ( "strings" "testing" ) func TestIsWeakPriorEnhanceDescription_fillerPhrases(t *testing.T) { title := "Vogel's WALL 3245 TV Wall Mount" cases := []struct { desc string want bool }{ {"Ready for retail listing with extra padding text here.", true}, {title + " in the Mounts category. Ready for retail listing.", true}, {"Product description placeholder text that is long enough to pass length.", true}, {"A product in the Mounts category based on available specifications.", true}, {"Product with available specifications ready for retail listing.", true}, {"Generic one-liner without product tokens and enough length!!!!!", true}, { "Vogel's WALL 3245 is a TV Mounts product from Vogel's. Key specs: width 45 cm, max_load 40 kg.", false, }, { "This durable retail mount includes mounting hardware, load ratings, and install guidance for wall displays.", false, }, } for _, tc := range cases { got := isWeakPriorEnhanceDescription(tc.desc, title) if got != tc.want { t.Fatalf("desc=%q got weak=%v want %v", tc.desc, got, tc.want) } } // Long non-filler copy that does not share tokens with this title is still usable // once past the short-boilerplate window (hash-skip quality floor). longUnrelated := strings.Repeat("Detailed retail copy covering materials finishes warranty and care. ", 3) if isWeakPriorEnhanceDescription(longUnrelated, title) { t.Fatalf("long non-filler unrelated copy should not be weak solely for token miss: %q", longUnrelated) } if !isWeakPriorEnhanceDescription("ok", title) { t.Fatal("too-short must be weak") } if !isWeakPriorEnhanceDescription(title, title) { t.Fatal("title-echo must be weak") } } func TestSynthesizeProductDescription_formulaHTML(t *testing.T) { t.Parallel() title := "GIGABYTE GS27QC" attrs := map[string]any{"brand": "GIGABYTE", "width": "61 cm"} tpl := map[string]any{ "sections": []any{ map[string]any{"type": "h1", "instructions": "Main heading"}, map[string]any{"type": "p", "instructions": "Intro"}, map[string]any{"type": "ul", "instructions": "Specs"}, }, } got := synthesizeProductDescription(title, "Gaming monitorji", "sl", attrs, tpl) if !strings.Contains(got, "

") || !strings.Contains(got, "

") || !strings.Contains(got, "