Harden preview enrichment and recommendation metadata
build-push / docker (push) Has been cancelled

This commit is contained in:
AI Assistant
2026-03-16 16:39:09 +09:00
parent 93b9f571ab
commit 2064825d29
7 changed files with 433 additions and 106 deletions
+25
View File
@@ -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)
}
}