Cover public auth config, catalog policy, official main workflow activation on Postgres, and conn-busy metadata writeback fixes. Co-authored-by: Cursor <cursoragent@cursor.com>
68 lines
2.1 KiB
Go
68 lines
2.1 KiB
Go
package projectinstance
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"chat-agent-system/internal/workflowdef"
|
|
)
|
|
|
|
func TestValidateActivationPlan_EmptyWorkflowBlocked(t *testing.T) {
|
|
plan := WorkflowPlan{
|
|
WorkflowDefinitionKey: workflowdef.OfficialKeyProductManager,
|
|
WorkflowVersion: 2,
|
|
Stages: []StagePlan{{
|
|
StageKey: "requirements_baseline",
|
|
Enabled: true,
|
|
DocTasks: []DocTaskPlan{{
|
|
TaskKey: "system_reqs",
|
|
Enabled: false,
|
|
}},
|
|
}},
|
|
}
|
|
version := &workflowdef.Version{
|
|
Status: workflowdef.StatusPublished,
|
|
WorkflowKey: workflowdef.OfficialKeyProductManager,
|
|
Version: 2,
|
|
Definition: workflowdef.VersionDefinition{
|
|
SchemaVersion: 2,
|
|
Stages: []workflowdef.StageDef{{
|
|
Key: "requirements_baseline", Position: 10,
|
|
DocTasks: []workflowdef.DocTaskDef{{
|
|
Key: "system_reqs", CreatorConfigurable: true, DefaultEnabled: true,
|
|
OutputDocType: "system_reqs",
|
|
}},
|
|
}},
|
|
},
|
|
}
|
|
res := validatePlan(plan, version)
|
|
if !res.Valid {
|
|
t.Fatalf("save plan should allow all docs disabled: %+v", res.Issues)
|
|
}
|
|
act := validateActivationPlan(plan, version)
|
|
if act.Valid {
|
|
t.Fatal("activation should reject empty enabled doc set")
|
|
}
|
|
}
|
|
|
|
func TestBuildDefaultPlan_IncludesDisplayNames(t *testing.T) {
|
|
version := testResolver().versions[workflowdef.OfficialKeyMain]
|
|
plan := buildDefaultPlan(version)
|
|
if len(plan.Stages) != 1 || plan.Stages[0].StageName != "V0.1 需求摸底" {
|
|
t.Fatalf("expected stage display name, got %+v", plan.Stages)
|
|
}
|
|
if len(plan.Stages[0].DocTasks) != 1 || plan.Stages[0].DocTasks[0].TaskTitle != "用户初始需求收集表" {
|
|
t.Fatalf("expected task display title, got %+v", plan.Stages[0].DocTasks)
|
|
}
|
|
}
|
|
|
|
func TestApplyDefinitionLabels_OverridesClientText(t *testing.T) {
|
|
version := testResolver().versions[workflowdef.OfficialKeyMain]
|
|
plan := validPlan()
|
|
plan.Stages[0].StageName = "客户端伪造阶段"
|
|
plan.Stages[0].DocTasks[0].TaskTitle = "客户端伪造文档"
|
|
applyDefinitionLabels(&plan, version)
|
|
if plan.Stages[0].StageName != "V0.1 需求摸底" || plan.Stages[0].DocTasks[0].TaskTitle != "用户初始需求收集表" {
|
|
t.Fatalf("definition labels must win, got %+v", plan.Stages[0])
|
|
}
|
|
}
|