Files
im_server/server/kafka_workbench_events_test.go
T

46 lines
1.1 KiB
Go

package main
import (
"testing"
"github.com/tinode/chat/server/store"
)
func TestExecuteKafkaWorkbenchAITaskEventSkipsNotification(t *testing.T) {
oldSecurity := store.Security
security := &testUserSecurityStore{}
store.Security = security
t.Cleanup(func() {
store.Security = oldSecurity
})
event := kafkaWorkbenchEvent{
EventID: "wbe_ai_1",
TenantID: 7,
ActorUserID: 1,
Module: "ai",
Action: "workbench.ai.task.updated",
ResourceID: "aitask_1",
TargetUserIDs: []int64{2},
Title: "AI 任务完成",
Summary: "表格分析已完成",
Data: map[string]any{
"task_id": "aitask_1",
"feature": "smart_table",
"status": "succeeded",
"result_type": "record",
"record_id": "airec_1",
},
}
if event.shouldCreateNotification() {
t.Fatal("ai task event must be realtime-only")
}
err := executeKafkaWorkbenchEvent(event)
if err != nil {
t.Fatalf("executeKafkaWorkbenchEvent returned error: %v", err)
}
if len(security.notifications) != 0 {
t.Fatalf("ai task event should not create offline notification: %#v", security.notifications)
}
}