Stop hardcoding V0.5_feasibility when creating docgov records; prefer frozen-instance StageKey from TaskRunRequest with main-task fallback. Co-authored-by: Cursor <cursoragent@cursor.com>
66 lines
1.8 KiB
Go
66 lines
1.8 KiB
Go
package server
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"chat-agent-system/internal/bizdev"
|
|
)
|
|
|
|
func TestBuildBizdevStageRequest_PreservesIdentityAndRoles(t *testing.T) {
|
|
s := &Server{}
|
|
dto := TaskRunRequestDTO{
|
|
Stage: "v0.5_feasibility",
|
|
ProjectName: "P",
|
|
CustomerName: "C",
|
|
DeviceType: "D",
|
|
IntendedUse: "U",
|
|
TargetMarket: "M",
|
|
Backend: "stub",
|
|
AutoRepair: false,
|
|
UserID: 107,
|
|
ProjectID: 6098,
|
|
DocID: "doc_proj6098_intake",
|
|
AuthorID: 1,
|
|
AuthorName: "编制人",
|
|
ReviewerID: 2,
|
|
ReviewerName: "审核人",
|
|
ApproverID: 3,
|
|
ApproverName: "批准人",
|
|
ForceDirectEdit: true,
|
|
}
|
|
got := s.buildBizdevStageRequest(dto, "sess-p6098-u107", "turn_x", "run_y")
|
|
if !got.AutoRepair {
|
|
t.Fatal("product contract: AutoRepair must be forced true")
|
|
}
|
|
if got.SessionID != "sess-p6098-u107" || got.ClientTurnID != "turn_x" || got.RunID != "run_y" {
|
|
t.Fatalf("session/turn/run dropped: %+v", got)
|
|
}
|
|
if got.UserID != 107 || got.ProjectID != 6098 || got.DocID != "doc_proj6098_intake" {
|
|
t.Fatalf("identity fields dropped: %+v", got)
|
|
}
|
|
if got.AuthorID != 1 || got.ReviewerID != 2 || got.ApproverID != 3 || !got.ForceDirectEdit {
|
|
t.Fatalf("role fields dropped: %+v", got)
|
|
}
|
|
if got.Stage != bizdev.MaturityStage("v0.5_feasibility") {
|
|
t.Fatalf("stage=%q", got.Stage)
|
|
}
|
|
}
|
|
|
|
func TestBuildBizdevTaskRequest_PassesStageKey(t *testing.T) {
|
|
s := &Server{}
|
|
dto := TaskRunRequestDTO{
|
|
TaskKey: "rd_proposal",
|
|
Backend: "stub",
|
|
UserID: 1,
|
|
ProjectID: 100,
|
|
StageKey: "RD01_planning",
|
|
}
|
|
got := s.buildBizdevTaskRequest(dto, "sess", "turn", "run")
|
|
if got.StageKey != "RD01_planning" {
|
|
t.Fatalf("StageKey=%q, want RD01_planning", got.StageKey)
|
|
}
|
|
if got.TaskKey != "rd_proposal" {
|
|
t.Fatalf("TaskKey=%q", got.TaskKey)
|
|
}
|
|
}
|