This commit is contained in:
@@ -3,6 +3,7 @@ package services
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -114,3 +115,27 @@ func TestGeminiExpansionCacheRoundTrip(t *testing.T) {
|
||||
t.Fatalf("unexpected expansion cache value: %#v", value)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecorateRecommendationMediaUsesEmbedForGoogleVideo(t *testing.T) {
|
||||
item := DecorateRecommendationMedia(AIRecommendation{
|
||||
Source: "Google Video",
|
||||
Link: "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
|
||||
})
|
||||
if item.MediaMode != "embed" {
|
||||
t.Fatalf("expected embed media mode, got %q", item.MediaMode)
|
||||
}
|
||||
if item.EmbedURL == "" || !strings.Contains(item.EmbedURL, "youtube-nocookie.com/embed/") {
|
||||
t.Fatalf("unexpected embed url: %q", item.EmbedURL)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRankSearchResultsPrefersUsableVisuals(t *testing.T) {
|
||||
results := []SearchResult{
|
||||
{Title: "cyberpunk city", Link: "https://example.com/a", ThumbnailURL: "https://example.com/favicon.ico"},
|
||||
{Title: "cyberpunk city", Link: "https://example.com/b", ThumbnailURL: "https://example.com/frame.jpg"},
|
||||
}
|
||||
ranked := RankSearchResults("cyberpunk city", results)
|
||||
if ranked[0].Link != "https://example.com/b" {
|
||||
t.Fatalf("expected usable thumbnail result first, got %#v", ranked)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user