2026-04-12 13:39:16 +08:00
|
|
|
package graphs
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
2026-08-21 00:41:07 +08:00
|
|
|
"code.tczkiot.com/wlw/ai-agent/internal/models"
|
|
|
|
|
"code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
|
2026-04-12 13:39:16 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestTriageServiceRequestResult_PrepareTicket(t *testing.T) {
|
2026-04-17 18:48:45 +08:00
|
|
|
conversation := models.Conversation{
|
2026-04-12 13:39:16 +08:00
|
|
|
LastMessageSummary: "用户要求建单跟进支付失败问题",
|
|
|
|
|
}
|
|
|
|
|
messages := []models.Message{
|
|
|
|
|
{SenderType: enums.IMSenderTypeCustomer, Content: "帮我建个工单,支付一直失败"},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
analysis := buildAnalyzeConversationResult(conversation, messages, AnalyzeConversationInput{
|
|
|
|
|
NeedTicket: true,
|
|
|
|
|
})
|
|
|
|
|
if analysis.RecommendedNextAction != "prepare_ticket" {
|
|
|
|
|
t.Fatalf("expected prepare_ticket, got %q", analysis.RecommendedNextAction)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
draft := buildPrepareTicketDraftResult(conversation, messages, PrepareTicketDraftInput{})
|
|
|
|
|
if draft.Title == "" || draft.Description == "" {
|
|
|
|
|
t.Fatalf("expected draft to be populated, got %#v", draft)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestTriageServiceRequestResult_Handoff(t *testing.T) {
|
2026-04-17 18:48:45 +08:00
|
|
|
conversation := models.Conversation{
|
2026-04-12 13:39:16 +08:00
|
|
|
LastMessageSummary: "用户要求人工处理扣费投诉",
|
|
|
|
|
}
|
|
|
|
|
messages := []models.Message{
|
|
|
|
|
{SenderType: enums.IMSenderTypeCustomer, Content: "我要投诉并转人工,你们重复扣费了"},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
analysis := buildAnalyzeConversationResult(conversation, messages, AnalyzeConversationInput{
|
|
|
|
|
NeedHumanHandoff: true,
|
|
|
|
|
})
|
|
|
|
|
if analysis.RecommendedNextAction != "handoff_to_human" {
|
|
|
|
|
t.Fatalf("expected handoff_to_human, got %q", analysis.RecommendedNextAction)
|
|
|
|
|
}
|
|
|
|
|
}
|