Files
Enterprise-Knowledge-Base/internal/im/feishu/adapter_test.go
T
ochan.kwon 2d5782992e [NELO-1102] feat(im): add thread-based session mode for IM channels
Add session_mode ("user" | "thread") to IM channel config. In thread
mode, each message thread gets its own session, enabling multi-user
collaboration within the same thread context.

Backend:
- Add SessionMode type constants and validation
- Add ThreadID field to IncomingMessage and ChannelSession
- Split resolveSession into resolveUserSession/resolveThreadSession
- Update makeUserKey to include threadID only in thread mode
- Extract ThreadID in Slack, Mattermost, Feishu, Telegram adapters
- Add message_thread_id to Telegram SendReply/StartStream for Forums
- DB migration 000028: session_mode column + thread_id column + index

Frontend:
- Add session_mode radio group to IMChannelPanel dialog
- Auto-reset session_mode when switching to non-thread platform
- Show thread badge on channel card for thread-mode channels
- Add i18n keys for en-US, ko-KR, zh-CN, ru-RU
2026-03-30 10:43:14 +08:00

54 lines
1.2 KiB
Go

package feishu
import "testing"
func TestFeishuThreadID_ThreadedReply(t *testing.T) {
// Simulate: message is a reply in a thread (root_id is set)
msg := &feishuMessage{
MessageID: "msg-reply-1",
RootID: "msg-root-1",
ParentID: "msg-parent-1",
}
threadID := msg.RootID
if threadID == "" {
threadID = msg.MessageID
}
if threadID != "msg-root-1" {
t.Errorf("threadID = %q, want %q", threadID, "msg-root-1")
}
}
func TestFeishuThreadID_TopLevelMessage(t *testing.T) {
// Simulate: top-level message (root_id is empty)
msg := &feishuMessage{
MessageID: "msg-top-1",
RootID: "",
ParentID: "",
}
threadID := msg.RootID
if threadID == "" {
threadID = msg.MessageID
}
if threadID != "msg-top-1" {
t.Errorf("threadID = %q, want %q (should use MessageID as fallback)", threadID, "msg-top-1")
}
}
func TestFeishuMessageStruct_JSONFields(t *testing.T) {
// Verify the struct fields exist and have correct zero values
msg := feishuMessage{}
if msg.RootID != "" {
t.Errorf("RootID zero value = %q, want empty", msg.RootID)
}
if msg.ParentID != "" {
t.Errorf("ParentID zero value = %q, want empty", msg.ParentID)
}
if msg.MessageID != "" {
t.Errorf("MessageID zero value = %q, want empty", msg.MessageID)
}
}