Files
Agent-System/internal/docgov/reopen_test.go
T
weichenandCursor 4a7b8cc26f feat(workflow): reopen a completed stage without pausing the later one
Selected documents return to drafting, and advance asks the creator to acknowledge an open recheck mark.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-20 15:35:07 +00:00

25 lines
780 B
Go

package docgov
import (
"errors"
"testing"
)
func TestTransitionReopenForRevision_IsNotARejection(t *testing.T) {
sm := NewStateMachine()
doc := &DocumentRecord{DocID: "doc_reopen", CurrentState: StateApproved, IsLocked: true, Config: DefaultDocumentConfig()}
audit, err := sm.TransitionReopenForRevision(doc, 4, "creator", "新材料")
if err != nil {
t.Fatal(err)
}
if doc.CurrentState != StateDrafting || doc.IsLocked {
t.Fatalf("state %s locked %v", doc.CurrentState, doc.IsLocked)
}
if audit.Action != "reopen_for_revision" || audit.ActorRole != RoleSystem {
t.Fatalf("audit %+v", audit)
}
if _, err := sm.TransitionReopenForRevision(doc, 4, "creator", "again"); !errors.Is(err, ErrInvalidStateTransition) {
t.Fatalf("drafting reopen err %v", err)
}
}