Improve modal fit and Gemini search refinement
build-push / docker (push) Successful in 4m8s

This commit is contained in:
AI Assistant
2026-03-17 12:30:50 +09:00
parent 0b68feff80
commit 556d4d6c1b
8 changed files with 353 additions and 77 deletions
+41
View File
@@ -77,6 +77,28 @@ func TestNormalizeKnownMediaPhrases(t *testing.T) {
}
}
func TestBuildSupplementalQueriesReturnsGeneratedLines(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
_, _ = w.Write([]byte(`{"candidates":[{"content":{"parts":[{"text":"authentic couple city walk\ncandid couple park footage\nnatural lifestyle b-roll"}]}}]}`))
}))
defer server.Close()
service := NewGeminiService("dummy-key")
service.Client = &http.Client{Timeout: 2 * time.Second}
service.GenerateEndpoint = server.URL
queries, err := service.BuildSupplementalQueries("다정한 커플", []string{"friendly couple"}, []AIRecommendation{
{Assessment: "irrelevant", SearchHint: "authentic lifestyle couple"},
})
if err != nil {
t.Fatalf("expected supplemental query generation to succeed, got %v", err)
}
if len(queries) < 3 || queries[0] != "authentic couple city walk" {
t.Fatalf("unexpected supplemental queries: %#v", queries)
}
}
func TestSelectUnevaluatedCandidatesSkipsReviewedLinks(t *testing.T) {
ranked := []SearchResult{
{Link: "https://a.example"},
@@ -172,3 +194,22 @@ func TestRankSearchResultsPrefersUsableVisuals(t *testing.T) {
t.Fatalf("expected usable thumbnail result first, got %#v", ranked)
}
}
func TestMergeRecommendationsExcludesIrrelevantAndPendingFiller(t *testing.T) {
recommended := []AIRecommendation{
{Title: "keep", Link: "https://a.example", Recommended: true, Assessment: "positive", ThumbnailURL: "https://example.com/a.jpg"},
{Title: "drop", Link: "https://b.example", Recommended: false, Assessment: "irrelevant", ThumbnailURL: "https://example.com/b.jpg", Reason: "관련이 없습니다."},
}
ranked := []SearchResult{
{Title: "keep", Link: "https://a.example", ThumbnailURL: "https://example.com/a.jpg"},
{Title: "extra", Link: "https://c.example", ThumbnailURL: "https://example.com/c.jpg"},
}
merged := MergeRecommendations(recommended, ranked, 16)
if len(merged) != 1 {
t.Fatalf("expected only the positive recommendation without pending filler, got %#v", merged)
}
if merged[0].Link != "https://a.example" {
t.Fatalf("unexpected merged result: %#v", merged)
}
}