package session import ( "testing" "gitea.zheromiku.top/Weknora/dobotai-platform/internal/core" ) func TestBuildDisplayTitle(t *testing.T) { t.Parallel() tests := []struct { name string in TitleIdentity want string }{ { name: "direct uses employee name only", in: TitleIdentity{ ConversationType: core.ConversationDirect, ExternalUserID: "staff-123456", SenderName: " 张三 ", }, want: "张三", }, { name: "direct masks stable id when name unavailable", in: TitleIdentity{ ConversationType: core.ConversationDirect, ExternalUserID: "staff-123456", }, want: "钉钉用户-3456", }, { name: "group uses conversation title", in: TitleIdentity{ ConversationType: core.ConversationGroup, ExternalChatID: "cid-987654", ConversationTitle: " NOVA项目群 ", }, want: "NOVA项目群", }, { name: "group masks stable id when title unavailable", in: TitleIdentity{ ConversationType: core.ConversationGroup, ExternalChatID: "cid-987654", }, want: "钉钉群聊-7654", }, { name: "short id remains usable", in: TitleIdentity{ ConversationType: core.ConversationDirect, ExternalUserID: "u7", }, want: "钉钉用户-u7", }, } for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() if got := BuildDisplayTitle(tt.in); got != tt.want { t.Fatalf("BuildDisplayTitle() = %q, want %q", got, tt.want) } }) } }