Prove A can run the full action chain and outsiders stay denied; assert audit Details carry duty_policy on all five transitions. Co-authored-by: Cursor <cursoragent@cursor.com>
75 lines
1.9 KiB
Go
75 lines
1.9 KiB
Go
package docgov
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestTransitionAuditDetailsIncludeDutyPolicy(t *testing.T) {
|
|
sm := NewStateMachine()
|
|
doc := &DocumentRecord{
|
|
DocID: "doc_audit_policy",
|
|
CurrentState: StateDrafting,
|
|
AuthorID: 7,
|
|
ReviewerID: 7,
|
|
ApproverID: 7,
|
|
DutyPolicy: "author_only",
|
|
DutyLocked: true,
|
|
Config: DefaultDocumentConfig(),
|
|
}
|
|
|
|
audit, err := sm.TransitionSubmitForReview(doc, 7, RoleAuthor, "A")
|
|
if err != nil {
|
|
t.Fatalf("submit: %v", err)
|
|
}
|
|
if audit.Details["duty_policy"] != "author_only" {
|
|
t.Fatalf("submit details: %+v", audit.Details)
|
|
}
|
|
|
|
audit, err = sm.TransitionReviewApprove(doc, 7, RoleReviewer, "A", "ok")
|
|
if err != nil {
|
|
t.Fatalf("review: %v", err)
|
|
}
|
|
if audit.Details["duty_policy"] != "author_only" {
|
|
t.Fatalf("review details: %+v", audit.Details)
|
|
}
|
|
|
|
audit, err = sm.TransitionApproverApprove(doc, 7, RoleApprover, "A", "ok")
|
|
if err != nil {
|
|
t.Fatalf("approve: %v", err)
|
|
}
|
|
if audit.Details["duty_policy"] != "author_only" {
|
|
t.Fatalf("approve details: %+v", audit.Details)
|
|
}
|
|
}
|
|
|
|
func TestTransitionRejectAuditDetailsIncludeDutyPolicy(t *testing.T) {
|
|
sm := NewStateMachine()
|
|
doc := &DocumentRecord{
|
|
DocID: "doc_audit_reject",
|
|
CurrentState: StateReviewing,
|
|
IsLocked: true,
|
|
AuthorID: 7,
|
|
ReviewerID: 7,
|
|
ApproverID: 7,
|
|
DutyPolicy: "author_only",
|
|
Config: DefaultDocumentConfig(),
|
|
}
|
|
audit, err := sm.TransitionReviewReject(doc, 7, RoleReviewer, "A", "need fix")
|
|
if err != nil {
|
|
t.Fatalf("review reject: %v", err)
|
|
}
|
|
if audit.Details["duty_policy"] != "author_only" {
|
|
t.Fatalf("review reject details: %+v", audit.Details)
|
|
}
|
|
|
|
doc.CurrentState = StateApproving
|
|
doc.IsLocked = true
|
|
audit, err = sm.TransitionApproverReject(doc, 7, RoleApprover, "A", "need rework", StateDrafting)
|
|
if err != nil {
|
|
t.Fatalf("approver reject: %v", err)
|
|
}
|
|
if audit.Details["duty_policy"] != "author_only" {
|
|
t.Fatalf("approver reject details: %+v", audit.Details)
|
|
}
|
|
}
|