@@ -1176,6 +1176,39 @@ func TestWorkflowMutator_SetActivityProperty_Page_MissingKey(t *testing.T) {
11761176 }
11771177}
11781178
1179+ func TestWorkflowMutator_SetActivityProperty_Page_MissingKey_NestedSubFlow (t * testing.T ) {
1180+ // Exercises the recursive replaceActivity path: the target activity lives
1181+ // inside an outcome's sub-flow, not at the top level.
1182+ nestedAct := makeWfActivity ("Workflows$UserTask" , "NestedReview" , "nested1" )
1183+ // No TaskPage field at all on the nested activity.
1184+
1185+ outcome := bson.D {
1186+ {Key : "$ID" , Value : primitive.Binary {Subtype : 0x04 , Data : make ([]byte , 16 )}},
1187+ {Key : "$Type" , Value : "Workflows$BooleanOutcome" },
1188+ {Key : "Flow" , Value : bson.D {
1189+ {Key : "$ID" , Value : primitive.Binary {Subtype : 0x04 , Data : make ([]byte , 16 )}},
1190+ {Key : "$Type" , Value : "Workflows$Flow" },
1191+ {Key : "Activities" , Value : bson.A {int32 (3 ), nestedAct }},
1192+ }},
1193+ }
1194+ parentAct := makeWfActivity ("Workflows$Decision" , "Check" , "decision1" )
1195+ parentAct = append (parentAct , bson.E {Key : "Outcomes" , Value : bson.A {int32 (3 ), outcome }})
1196+ m := newMutator (makeWorkflowDoc (parentAct ))
1197+
1198+ if err := m .SetActivityProperty ("NestedReview" , 0 , "PAGE" , "MyModule.NestedPage" ); err != nil {
1199+ t .Fatalf ("SetActivityProperty PAGE on nested activity failed: %v" , err )
1200+ }
1201+
1202+ actDoc , _ := m .findActivityByCaption ("NestedReview" , 0 )
1203+ taskPage := dGetDoc (actDoc , "TaskPage" )
1204+ if taskPage == nil {
1205+ t .Fatal ("TaskPage should be set on nested activity even when key was absent" )
1206+ }
1207+ if got := dGetString (taskPage , "Page" ); got != "MyModule.NestedPage" {
1208+ t .Errorf ("Page = %q, want MyModule.NestedPage" , got )
1209+ }
1210+ }
1211+
11791212func TestWorkflowMutator_SetActivityProperty_Page_Existing (t * testing.T ) {
11801213 act := makeWfActivity ("Workflows$UserTask" , "Review" , "task1" )
11811214 act = append (act , bson.E {Key : "TaskPage" , Value : bson.D {
0 commit comments