Skip to content

Commit cfb4730

Browse files
authored
fix:(loo-5931): decode appliesDownstream on AudienceFilter workflow nodes (#21)
1 parent b744184 commit cfb4730

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

‎workflows.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ type AudienceFilterWorkflowNode struct {
466466
NextNodeIDs []string `json:"nextNodeIds"`
467467
AudienceFilter *AudienceFilter `json:"audienceFilter,omitempty"`
468468
AudienceSegmentID string `json:"audienceSegmentId,omitempty"`
469+
AppliesDownstream bool `json:"appliesDownstream"`
469470
}
470471

471472
// TimerActionWorkflowNode is the TimerAction variant of [WorkflowNode].

‎workflows_test.go‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,8 @@ func TestGetWorkflowNode_AudienceFilter(t *testing.T) {
423423
{"type": "property", "key": "plan", "operator": "equals", "value": "pro"}
424424
]
425425
},
426-
"audienceSegmentId": "seg_abc"
426+
"audienceSegmentId": "seg_abc",
427+
"appliesDownstream": true
427428
}`
428429
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
429430
w.WriteHeader(http.StatusOK)
@@ -452,6 +453,30 @@ func TestGetWorkflowNode_AudienceFilter(t *testing.T) {
452453
if af.Conditions[0].Property == nil || af.Conditions[0].Property.Key != "plan" {
453454
t.Errorf("audienceFilter.Conditions[0] = %+v", af.Conditions[0])
454455
}
456+
if !node.AudienceFilter.AppliesDownstream {
457+
t.Error("AppliesDownstream = false, want true")
458+
}
459+
raw, err := json.Marshal(node)
460+
if err != nil {
461+
t.Fatalf("Marshal: %v", err)
462+
}
463+
if !strings.Contains(string(raw), `"appliesDownstream":true`) {
464+
t.Errorf("marshal dropped appliesDownstream: %s", raw)
465+
}
466+
}
467+
468+
func TestAudienceFilterWorkflowNode_MarshalKeepsFalseAppliesDownstream(t *testing.T) {
469+
n := WorkflowNode{
470+
TypeName: WorkflowNodeTypeAudienceFilter,
471+
AudienceFilter: &AudienceFilterWorkflowNode{ID: "n7", WorkflowID: "wf_1", NextNodeIDs: []string{"n9"}},
472+
}
473+
raw, err := json.Marshal(n)
474+
if err != nil {
475+
t.Fatalf("Marshal: %v", err)
476+
}
477+
if !strings.Contains(string(raw), `"appliesDownstream":false`) {
478+
t.Errorf("marshal dropped appliesDownstream: %s", raw)
479+
}
455480
}
456481

457482
func TestWorkflowNode_MarshalRoundTrip(t *testing.T) {

0 commit comments

Comments
 (0)