package websearch import ( "strings" "testing" ) func TestParseDuckDuckGoResults(t *testing.T) { body := ` Fashion Website Design A fashion ecommerce homepage reference. Hoodie Brand System Brand and hoodie visual language.` results := parseDuckDuckGoResults(body, 5) if len(results) != 2 { t.Fatalf("expected 2 results, got %d", len(results)) } if results[0].Title != "Fashion Website Design" { t.Fatalf("unexpected title: %s", results[0].Title) } if results[0].URL != "https://example.com/fashion" { t.Fatalf("unexpected url: %s", results[0].URL) } if results[0].Snippet != "A fashion ecommerce homepage reference." { t.Fatalf("unexpected snippet: %s", results[0].Snippet) } } func TestBuildVisualSearchQueryForLogoReferencesAvoidsMakerTools(t *testing.T) { query := BuildVisualSearchQuery("Moteva 让设计变简单懂你的设计 Agent,帮我搞定一切设计需求,制作一个 logo") for _, want := range []string{"AI design agent", "logo 设计稿", "设计思路", "brand identity", "-maker", "-generator", "-template"} { if !strings.Contains(query, want) { t.Fatalf("expected query to contain %q, got %q", want, query) } } if strings.Contains(query, "制作一个 logo") { t.Fatalf("expected query to avoid raw prompt wording, got %q", query) } }