2026-06-26 08:37:04 +00:00
|
|
|
package knowledge
|
|
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
2026-07-01 08:42:51 +00:00
|
|
|
func TestResolveScanPatrolKeywordsIncludesExplicitHint(t *testing.T) {
|
2026-06-26 08:37:04 +00:00
|
|
|
got := ResolveScanPatrolKeywords(
|
|
|
|
|
[]string{"手動 關鍵字"},
|
|
|
|
|
[]string{"已儲存"},
|
|
|
|
|
PatrolTagInput{Questions: []string{"敏感肌 怎麼辦"}},
|
|
|
|
|
nil,
|
|
|
|
|
)
|
2026-07-01 08:42:51 +00:00
|
|
|
if len(got) == 0 {
|
|
|
|
|
t.Fatal("expected ranked keywords")
|
|
|
|
|
}
|
|
|
|
|
found := false
|
|
|
|
|
for _, kw := range got {
|
|
|
|
|
if kw == "手動 關鍵字" {
|
|
|
|
|
found = true
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if !found {
|
|
|
|
|
t.Fatalf("ResolveScanPatrolKeywords() = %#v, want explicit hint included", got)
|
2026-06-26 08:37:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestResolveScanPatrolKeywordsFromResearchMapWithoutGraph(t *testing.T) {
|
|
|
|
|
got := ResolveScanPatrolKeywords(nil, nil, PatrolTagInput{
|
|
|
|
|
Questions: []string{"化療後 皮膚乾 怎麼辦"},
|
|
|
|
|
}, nil)
|
|
|
|
|
if len(got) == 0 {
|
|
|
|
|
t.Fatal("expected research map questions to produce patrol keywords without graph nodes")
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-07-01 08:42:51 +00:00
|
|
|
|
|
|
|
|
func TestResolveScanPatrolKeywordsPrefersSelectedNodes(t *testing.T) {
|
|
|
|
|
nodes := []Node{
|
|
|
|
|
{ID: "pain", Label: "化療後 皮膚乾", SelectedForScan: true, ProductFitScore: 88, NodeKind: "pain", DerivedTags: DerivedTags{Relevance: []string{"化療後 皮膚乾 沐浴乳"}}},
|
|
|
|
|
{ID: "skip", Label: "無關節點", SelectedForScan: false, ProductFitScore: 90, DerivedTags: DerivedTags{Relevance: []string{"不該出現"}}},
|
|
|
|
|
}
|
|
|
|
|
got := ResolveScanPatrolKeywords(nil, nil, PatrolTagInput{}, nodes)
|
|
|
|
|
if len(got) == 0 {
|
|
|
|
|
t.Fatal("expected selected node to produce patrol keywords")
|
|
|
|
|
}
|
|
|
|
|
found := false
|
|
|
|
|
for _, kw := range got {
|
|
|
|
|
if kw == "化療後 皮膚乾 沐浴乳" || kw == "化療後 皮膚乾" {
|
|
|
|
|
found = true
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if !found {
|
|
|
|
|
t.Fatalf("expected selected node keyword, got %#v", got)
|
|
|
|
|
}
|
|
|
|
|
for _, kw := range got {
|
|
|
|
|
if kw == "不該出現" {
|
|
|
|
|
t.Fatalf("unselected node leaked into keywords: %#v", got)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|