A new recheck mark is posted into the actor's existing project session, and a downstream-impact event does the same. Asking about what a change affects still resolves to impact analysis. Co-authored-by: Cursor <cursoragent@cursor.com>
52 lines
1.5 KiB
Go
52 lines
1.5 KiB
Go
package docnotify
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"chat-agent-system/internal/ctxmgr"
|
|
)
|
|
|
|
func TestPostProjectNoticeSkipsWithoutSession(t *testing.T) {
|
|
chat := ctxmgr.NewContextManager(nil, nil, ctxmgr.TimeDecayConfig{})
|
|
if err := PostProjectNotice(t.Context(), chat, 7, 3, "上游有变更", nil); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
history, err := chat.GetChatHistory(t.Context(), "sess-missing", 10, 0)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(history) != 0 {
|
|
t.Fatalf("must not create a session, history=%d", len(history))
|
|
}
|
|
}
|
|
|
|
func TestPostProjectNoticeWritesActorSession(t *testing.T) {
|
|
chat := ctxmgr.NewContextManager(nil, nil, ctxmgr.TimeDecayConfig{})
|
|
if _, err := chat.EnsureChatSession(t.Context(), "sess-p7-u3", 3, 7, "项目对话"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := PostProjectNotice(t.Context(), chat, 7, 3, "文档 d 的变更可能影响 down。", map[string]any{
|
|
"interactive_card": map[string]any{"cardType": "RECHECK_NOTICE"},
|
|
}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
history, err := chat.GetChatHistory(t.Context(), "sess-p7-u3", 10, 0)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(history) != 1 || history[0].Role != "assistant" {
|
|
t.Fatalf("history=%+v", history)
|
|
}
|
|
if history[0].Metadata["interactive_card"] == nil {
|
|
t.Fatalf("metadata=%+v", history[0].Metadata)
|
|
}
|
|
}
|
|
|
|
func TestDownstreamChatBody(t *testing.T) {
|
|
got := downstreamChatBody("doc-a", "doc-b")
|
|
if !strings.Contains(got, "doc-a") || !strings.Contains(got, "doc-b") || !strings.Contains(got, "分析影响") {
|
|
t.Fatalf("body=%q", got)
|
|
}
|
|
}
|