feat(im): push escalations to configured support group

This commit is contained in:
姚章浩
2026-07-15 14:37:27 +08:00
parent 0eb13a022e
commit 6a598c4317
7 changed files with 71 additions and 0 deletions
+35
View File
@@ -4,6 +4,7 @@ import (
"context"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"github.com/gin-gonic/gin"
)
@@ -56,3 +57,37 @@ func TestSendReplyToSourceRejectsUnavailableChannel(t *testing.T) {
t.Fatal("expected missing channel error")
}
}
func TestSendSupportNotificationUsesConfiguredGroup(t *testing.T) {
adapter := &recordingReplyAdapter{}
service := &Service{channels: map[string]*channelState{
"channel-1": {
Adapter: adapter,
Channel: &IMChannel{
ID: "channel-1",
Platform: "dingtalk",
Enabled: true,
Credentials: types.JSON(`{"support_group_open_conversation_id":"support-group-1"}`),
},
},
}}
if err := service.SendSupportNotification(context.Background(), "channel-1", "新工单:客户未解决"); err != nil {
t.Fatalf("SendSupportNotification: %v", err)
}
if adapter.incoming == nil || adapter.incoming.ChatType != ChatTypeGroup || adapter.incoming.ChatID != "support-group-1" {
t.Fatalf("support target = %#v", adapter.incoming)
}
if adapter.reply == nil || adapter.reply.Content != "新工单:客户未解决" {
t.Fatalf("support reply = %#v", adapter.reply)
}
}
func TestSendSupportNotificationRequiresConfiguredGroup(t *testing.T) {
service := &Service{channels: map[string]*channelState{
"channel-1": {Adapter: &recordingReplyAdapter{}, Channel: &IMChannel{ID: "channel-1", Platform: "dingtalk", Enabled: true}},
}}
if err := service.SendSupportNotification(context.Background(), "channel-1", "ticket"); err == nil {
t.Fatal("expected missing support group configuration error")
}
}