package viral

import (
	"strings"
	"testing"
)

func TestParseMissionInspireOutput(t *testing.T) {
	raw := `{"label":"轉職焦慮語錄","seedQuery":"轉職 被裁 焦慮","brief":"想找最近 Threads 上互動高的轉職心情貼文。","trendReason":"Google 熱搜近期職場話題升溫","trendKeywords":["轉職","裁員","面試"]}`
	out, err := ParseMissionInspireOutput(raw)
	if err != nil {
		t.Fatalf("parse: %v", err)
	}
	if out.Label != "轉職焦慮語錄" || out.SeedQuery == "" || out.Brief == "" {
		t.Fatalf("unexpected output: %+v", out)
	}
	if len(out.TrendKeywords) != 3 {
		t.Fatalf("expected 3 trend keywords, got %d", len(out.TrendKeywords))
	}
}

func TestBuildMissionInspireUserPromptLLMOnly(t *testing.T) {
	prompt := BuildMissionInspireUserPrompt(MissionInspireInput{
		PersonaDisplayName: "測試人設",
		PersonaBrief:       "職場焦慮",
		LLMOnly:            true,
	})
	if !strings.Contains(prompt, "未設定 Web Search API key") {
		t.Fatalf("expected llm-only hint in prompt: %s", prompt)
	}
	if !strings.Contains(prompt, "無外部趨勢結果") {
		t.Fatalf("expected empty trend fallback in prompt: %s", prompt)
	}
}
