feat: add FAQ uncovered workflow
This commit is contained in:
@@ -2,68 +2,58 @@
|
||||
package coverage
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"gitea.zheromiku.top/Weknora/dobotai-platform/internal/core"
|
||||
)
|
||||
|
||||
func TestSupportNotificationFields(t *testing.T) {
|
||||
// Verify that SupportNotification is a plain data struct with only the
|
||||
// safe fields listed in the spec. Token, webhook, raw IDs, raw responses,
|
||||
// and reference bodies must NOT be present.
|
||||
func TestSupportNotificationCarriesCustomerQuestionContext(t *testing.T) {
|
||||
askedAt := time.Date(2026, 7, 24, 10, 16, 35, 0, time.FixedZone("CST", 8*60*60))
|
||||
notif := SupportNotification{
|
||||
CaseID: "case-001",
|
||||
Question: "怎么配置钉钉机器人?",
|
||||
Answer: "进入钉钉开放平台...",
|
||||
Question: "Nova5I具体支持哪些通信协议?",
|
||||
SenderName: "张三",
|
||||
Channel: "dingtalk",
|
||||
ConversationType: core.ConversationGroup,
|
||||
ReferenceCount: 3,
|
||||
TopScore: 0.95,
|
||||
AskedAt: askedAt,
|
||||
PreviousQuestions: []string{
|
||||
"Nova5I如何配置Modbus TCP?",
|
||||
"Nova5I是否支持EtherCAT?",
|
||||
},
|
||||
FAQRecordID: "record-001",
|
||||
}
|
||||
|
||||
if notif.CaseID != "case-001" {
|
||||
t.Fatalf("CaseID = %q, want case-001", notif.CaseID)
|
||||
if notif.Question != "Nova5I具体支持哪些通信协议?" || notif.SenderName != "张三" {
|
||||
t.Fatalf("current question context mismatch: %+v", notif)
|
||||
}
|
||||
if notif.Question != "怎么配置钉钉机器人?" {
|
||||
t.Fatalf("Question = %q", notif.Question)
|
||||
if !notif.AskedAt.Equal(askedAt) {
|
||||
t.Fatalf("AskedAt = %v, want %v", notif.AskedAt, askedAt)
|
||||
}
|
||||
if notif.Answer != "进入钉钉开放平台..." {
|
||||
t.Fatalf("Answer = %q", notif.Answer)
|
||||
if len(notif.PreviousQuestions) != 2 || notif.PreviousQuestions[0] != "Nova5I如何配置Modbus TCP?" {
|
||||
t.Fatalf("PreviousQuestions = %#v", notif.PreviousQuestions)
|
||||
}
|
||||
if notif.SenderName != "张三" {
|
||||
t.Fatalf("SenderName = %q", notif.SenderName)
|
||||
if notif.FAQRecordID != "record-001" {
|
||||
t.Fatalf("FAQRecordID = %q", notif.FAQRecordID)
|
||||
}
|
||||
if notif.Channel != "dingtalk" {
|
||||
t.Fatalf("Channel = %q", notif.Channel)
|
||||
}
|
||||
if notif.ConversationType != core.ConversationGroup {
|
||||
t.Fatalf("ConversationType = %q", notif.ConversationType)
|
||||
}
|
||||
if notif.ReferenceCount != 3 {
|
||||
t.Fatalf("ReferenceCount = %d", notif.ReferenceCount)
|
||||
}
|
||||
if notif.TopScore != 0.95 {
|
||||
t.Fatalf("TopScore = %f", notif.TopScore)
|
||||
}
|
||||
|
||||
func TestSupportNotificationExcludesAnswerAndRetrievalDiagnostics(t *testing.T) {
|
||||
typ := reflect.TypeOf(SupportNotification{})
|
||||
for _, forbidden := range []string{"Answer", "ReferenceCount", "TopScore", "References", "Confidence"} {
|
||||
if _, ok := typ.FieldByName(forbidden); ok {
|
||||
t.Errorf("SupportNotification must not expose %s", forbidden)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSupportNotificationEmptyValues(t *testing.T) {
|
||||
// Zero-value notification should be safe to render (no panic).
|
||||
notif := SupportNotification{}
|
||||
if notif.CaseID != "" {
|
||||
t.Fatalf("expected empty CaseID")
|
||||
if notif.CaseID != "" || notif.Question != "" || notif.FAQRecordID != "" {
|
||||
t.Fatalf("expected safe zero value: %+v", notif)
|
||||
}
|
||||
if notif.Question != "" {
|
||||
t.Fatalf("expected empty Question")
|
||||
}
|
||||
if notif.Answer != "" {
|
||||
t.Fatalf("expected empty Answer")
|
||||
}
|
||||
if notif.ReferenceCount != 0 {
|
||||
t.Fatalf("expected zero ReferenceCount")
|
||||
}
|
||||
if notif.TopScore != 0 {
|
||||
t.Fatalf("expected zero TopScore")
|
||||
if len(notif.PreviousQuestions) != 0 || !notif.AskedAt.IsZero() {
|
||||
t.Fatalf("expected empty history and time: %+v", notif)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user