Files
Agent-System/internal/projectinstance/approval_test.go
T
weichenandCursor 32b88beee0 feat(projectinstance): refresh stage readiness after document approval.
Sync doc task status on approve and evaluate whether to emit stage advance readiness; chain docgov hooks.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-13 02:50:23 +00:00

45 lines
1.3 KiB
Go

package projectinstance
import (
"context"
"testing"
)
func TestHandleDocumentApproved_StageReady(t *testing.T) {
ctx := context.Background()
store := newMemStore()
_ = SeedProjectMeta(store, 1, LifecycleActive, "medical_device_development", 1, 1)
svc := NewService(store, testResolver(), nil, &stubDocChecker{states: map[string]string{"intake": "approved"}})
plan := WorkflowPlan{
WorkflowDefinitionKey: "medical_device_development",
WorkflowVersion: 1,
Stages: []StagePlan{{
StageKey: "biz_intake", Enabled: true,
DocTasks: []DocTaskPlan{{
TaskKey: "intake", Enabled: true,
Duties: DocDuty{AuthorUserID: 2, ReviewerUserID: 3, ApproverUserID: 4},
}},
}},
}
inst := &WorkflowInstance{
ID: 1, ProjectID: 1, WorkflowVersionID: 10, Status: InstanceActive,
ConfigRevision: 1, PlanHash: "h", ConfigSnapshot: plan, InstanceNo: 1,
}
activated, err := store.ActivateInstance(ctx, 1, inst, "medical_device_development", 1, 2)
if err != nil {
t.Fatalf("activate: %v", err)
}
result, err := svc.HandleDocumentApproved(ctx, 1, "intake")
if err != nil {
t.Fatalf("handle approved: %v", err)
}
if result == nil || !result.StageReady {
t.Fatalf("expected stage ready, got %+v", result)
}
if result.InstanceID != activated.ID || result.StageKey != "biz_intake" {
t.Fatalf("unexpected result: %+v", result)
}
}