package bizdev import ( "context" "testing" "chat-agent-system/internal/ctxmgr" "chat-agent-system/internal/projectcontext" "chat-agent-system/internal/replyexport" ) func TestCollectSnapshotDialogueInputs_FeedsBuildSnapshot(t *testing.T) { ctx := context.Background() mgr := ctxmgr.NewContextManager(nil, nil, ctxmgr.DefaultTimeDecayConfig()) projectID := int64(601) meta := map[string]any{"project_id": projectID} _, _ = mgr.RecordUserMessageWithID(ctx, "sess-601", 1, "user", "测试经理需要覆盖注册分类路径", "", "", meta) _, _ = mgr.RecordUserMessageWithID(ctx, "sess-601", 1, "assistant", "我会整理测试验证范围与风险点。", "", "", map[string]any{ "project_id": projectID, "export_policy": string(replyexport.PolicyFull), "content_kind": string(replyexport.KindDocumentText), }) _, _ = mgr.RecordActivity(ctx, projectID, 1, "张工", "decision", "确认先做注册分类调研", map[string]any{}, 1, true) svc := &Service{ctxMgr: mgr} inputs := svc.collectSnapshotDialogueInputs(ctx, projectID, 1) if len(inputs.Dialogue) == 0 { t.Fatalf("expected dialogue lines, got none") } if len(inputs.Decisions) != 1 { t.Fatalf("expected 1 decision, got %d", len(inputs.Decisions)) } ctxSvc := projectcontext.NewService(nil) snap, err := ctxSvc.BuildSnapshot(ctx, projectcontext.BuildInput{ ProjectID: projectID, TaskKey: "test_manager", Dialogue: inputs.Dialogue, Decisions: inputs.Decisions, }) if err != nil { t.Fatalf("BuildSnapshot: %v", err) } if snap.SourceCount < 2 { t.Fatalf("expected dialogue + decision sources, got %d", snap.SourceCount) } }