package knowledge

import "testing"

func TestSupplementGraphFromResearchMap(t *testing.T) {
	graph := Graph{Seed: "化療 沐浴乳", Nodes: []Node{}}
	pillars := []string{
		"化療皮膚敏感無香沐浴乳",
		"乳癌病友沐浴用品挑選",
		"荷爾蒙治療對香味敏感",
		"癌症康復後換清潔品牌",
		"抗敏無香沐浴乳推薦",
		"化療期間皮膚照護",
	}
	questions := []string{
		"化療後皮膚敏感要換什麼沐浴乳",
		"乳癌治療中不能用有香味的沐浴乳嗎",
		"癌症病人適合用的無香沐浴乳推薦",
		"荷爾蒙治療皮膚乾癢怎麼挑沐浴乳",
		"打標靶後對香味很敏感怎麼辦",
		"康復後不想再用有香精的清潔用品",
		"癌症病友都用什麼牌子沐浴乳",
		"化療期間沐浴乳挑選經驗分享",
	}
	SupplementGraphFromResearchMap(&graph, "化療 沐浴乳", pillars, questions)
	if len(graph.Nodes) < 12 {
		t.Fatalf("expected >=12 nodes, got %d", len(graph.Nodes))
	}
	DeriveSearchTagsFromGraph(&graph, PatrolTagInput{
		ProductName: "抗敏無香沐浴乳",
		Questions:   questions,
		Pillars:     pillars,
	})
	if graph.PainTagCount < 8 {
		t.Fatalf("expected pain tags, got %d", graph.PainTagCount)
	}
	for _, node := range graph.Nodes {
		if len(node.DerivedTags.Relevance)+len(node.DerivedTags.Recency) == 0 {
			continue
		}
		for _, tag := range append(node.DerivedTags.Relevance, node.DerivedTags.Recency...) {
			if len([]rune(tag)) < 6 {
				t.Fatalf("tag too short %q", tag)
			}
		}
	}
}
