Skip to content

Commit 7047e58

Browse files
committed
test: add nested sub-flow test for replaceActivity recursive path
1 parent a640309 commit 7047e58

6 files changed

Lines changed: 51 additions & 13 deletions

File tree

mdl/backend/mpr/backend.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ func (b *MprBackend) Path() string { return b.path }
8585
// for new code.
8686
func (b *MprBackend) MprReader() *mpr.Reader { return b.reader }
8787

88-
func (b *MprBackend) Version() types.MPRVersion { return convertMPRVersion(b.reader.Version()) }
89-
func (b *MprBackend) ProjectVersion() *types.ProjectVersion { return convertProjectVersion(b.reader.ProjectVersion()) }
90-
func (b *MprBackend) GetMendixVersion() (string, error) { return b.reader.GetMendixVersion() }
88+
func (b *MprBackend) Version() types.MPRVersion { return convertMPRVersion(b.reader.Version()) }
89+
func (b *MprBackend) ProjectVersion() *types.ProjectVersion {
90+
return convertProjectVersion(b.reader.ProjectVersion())
91+
}
92+
func (b *MprBackend) GetMendixVersion() (string, error) { return b.reader.GetMendixVersion() }
9193

9294
// Commit is a no-op — the MPR writer auto-commits on each write operation.
9395
func (b *MprBackend) Commit() error { return nil }
@@ -112,7 +114,9 @@ func (b *MprBackend) DeleteModuleWithCleanup(id model.ID, moduleName string) err
112114
// FolderBackend
113115
// ---------------------------------------------------------------------------
114116

115-
func (b *MprBackend) ListFolders() ([]*types.FolderInfo, error) { return convertFolderInfoSlice(b.reader.ListFolders()) }
117+
func (b *MprBackend) ListFolders() ([]*types.FolderInfo, error) {
118+
return convertFolderInfoSlice(b.reader.ListFolders())
119+
}
116120
func (b *MprBackend) CreateFolder(folder *model.Folder) error { return b.writer.CreateFolder(folder) }
117121
func (b *MprBackend) DeleteFolder(id model.ID) error { return b.writer.DeleteFolder(id) }
118122
func (b *MprBackend) MoveFolder(id model.ID, newContainerID model.ID) error {
@@ -678,8 +682,10 @@ func (b *MprBackend) UpdateRawUnit(unitID string, contents []byte) error {
678682
// MetadataBackend
679683
// ---------------------------------------------------------------------------
680684

681-
func (b *MprBackend) ListAllUnitIDs() ([]string, error) { return b.reader.ListAllUnitIDs() }
682-
func (b *MprBackend) ListUnits() ([]*types.UnitInfo, error) { return convertUnitInfoSlice(b.reader.ListUnits()) }
685+
func (b *MprBackend) ListAllUnitIDs() ([]string, error) { return b.reader.ListAllUnitIDs() }
686+
func (b *MprBackend) ListUnits() ([]*types.UnitInfo, error) {
687+
return convertUnitInfoSlice(b.reader.ListUnits())
688+
}
683689
func (b *MprBackend) GetUnitTypes() (map[string]int, error) { return b.reader.GetUnitTypes() }
684690
func (b *MprBackend) GetProjectRootID() (string, error) { return b.reader.GetProjectRootID() }
685691
func (b *MprBackend) ContentsDir() string { return b.reader.ContentsDir() }

mdl/backend/mpr/convert_roundtrip_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,4 +648,3 @@ func TestFieldCountDrift(t *testing.T) {
648648
assertFieldCount(t, "mpr.EntityAccessRevocation", mpr.EntityAccessRevocation{}, 6)
649649
assertFieldCount(t, "types.EntityAccessRevocation", types.EntityAccessRevocation{}, 6)
650650
}
651-

mdl/backend/mpr/workflow_mutator_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
11791212
func 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{

mdl/executor/widget_registry.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import (
1616

1717
// WidgetRegistry holds loaded widget definitions keyed by uppercase MDL name.
1818
type WidgetRegistry struct {
19-
byMDLName map[string]*WidgetDefinition // keyed by uppercase MDLName
20-
byWidgetID map[string]*WidgetDefinition // keyed by widgetId
19+
byMDLName map[string]*WidgetDefinition // keyed by uppercase MDLName
20+
byWidgetID map[string]*WidgetDefinition // keyed by widgetId
2121
knownOperations map[string]bool // operations accepted during validation
2222
}
2323

mdl/types/edmx_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ func TestFindEntityType(t *testing.T) {
217217

218218
func TestResolveNavType(t *testing.T) {
219219
tests := []struct {
220-
input string
221-
typeName string
222-
isMany bool
220+
input string
221+
typeName string
222+
isMany bool
223223
}{
224224
{"Collection(NS.Order)", "Order", true},
225225
{"NS.Customer", "Customer", false},

mdl/types/id_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func TestValidateID(t *testing.T) {
156156
{"AABBCCDD-EEFF-1122-3344-556677889900", true},
157157
{"", false},
158158
{"too-short", false},
159-
{"a1b2c3d4-e5f6-7890-abcd-ef123456789", false}, // 35 chars
159+
{"a1b2c3d4-e5f6-7890-abcd-ef123456789", false}, // 35 chars
160160
{"a1b2c3d4-e5f6-7890-abcd-ef12345678901", false}, // 37 chars
161161
{"a1b2c3d4xe5f6-7890-abcd-ef1234567890", false}, // wrong separator
162162
{"g1b2c3d4-e5f6-7890-abcd-ef1234567890", false}, // invalid hex

0 commit comments

Comments
 (0)