2026-04-12 13:32:07 +08:00
|
|
|
package graphs
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
2026-05-30 21:19:36 +08:00
|
|
|
"cs-ai-agent/internal/models"
|
|
|
|
|
"cs-ai-agent/internal/pkg/enums"
|
2026-04-12 13:32:07 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestBuildPrepareTicketDraftResult_UsesConversationFallbacks(t *testing.T) {
|
2026-04-17 18:48:45 +08:00
|
|
|
conversation := models.Conversation{
|
2026-04-12 13:32:07 +08:00
|
|
|
LastMessageSummary: "用户反馈企业微信扫码后页面空白,无法进入工作台",
|
|
|
|
|
}
|
|
|
|
|
messages := []models.Message{
|
|
|
|
|
{SenderType: enums.IMSenderTypeCustomer, Content: "扫码登录后一直白屏"},
|
|
|
|
|
{SenderType: enums.IMSenderTypeAI, Content: "请问是否有报错提示"},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
got := buildPrepareTicketDraftResult(conversation, messages, PrepareTicketDraftInput{
|
|
|
|
|
Impact: "无法进入后台处理客户消息",
|
|
|
|
|
ExpectedOutcome: "恢复正常登录",
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if got.Title == "" {
|
|
|
|
|
t.Fatalf("expected draft title to be generated")
|
|
|
|
|
}
|
|
|
|
|
if got.Description == "" {
|
|
|
|
|
t.Fatalf("expected draft description to be generated")
|
|
|
|
|
}
|
|
|
|
|
if !got.Ready {
|
|
|
|
|
t.Fatalf("expected conversation summary and recent messages to be enough, got %#v", got)
|
|
|
|
|
}
|
|
|
|
|
if len(got.ConversationFacts) == 0 {
|
|
|
|
|
t.Fatalf("expected conversation facts to be populated")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestBuildPrepareTicketDraftResult_ReadyWithExplicitIssue(t *testing.T) {
|
2026-04-17 18:48:45 +08:00
|
|
|
conversation := models.Conversation{
|
2026-04-12 13:32:07 +08:00
|
|
|
LastMessageSummary: "用户反馈连续支付失败",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
got := buildPrepareTicketDraftResult(conversation, nil, PrepareTicketDraftInput{
|
|
|
|
|
Issue: "用户连续三次支付订单失败,页面提示网络异常。",
|
|
|
|
|
ExpectedOutcome: "希望尽快恢复支付并完成下单。",
|
|
|
|
|
CurrentAttempt: "已尝试切换网络和刷新页面,问题仍存在。",
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if !got.Ready {
|
|
|
|
|
t.Fatalf("expected draft to be ready, got %#v", got)
|
|
|
|
|
}
|
|
|
|
|
if got.Title == "" || got.Description == "" {
|
|
|
|
|
t.Fatalf("expected title and description to be populated, got %#v", got)
|
|
|
|
|
}
|
|
|
|
|
}
|