Skip to content

Commit 4b116bc

Browse files
committed
with test
1 parent c71ba01 commit 4b116bc

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

tests/sentry/workflow_engine/processors/test_delayed_workflow.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,58 @@ def test_fire_actions_for_groups__workflow_fire_history(self, mock_process: Magi
10371037
event_id=self.event1.event_id,
10381038
).exists()
10391039

1040+
@with_feature("organizations:workflow-engine-single-process-workflows")
1041+
@patch("sentry.workflow_engine.tasks.actions.trigger_action.apply_async")
1042+
@patch("sentry.workflow_engine.processors.workflow.process_data_condition_group")
1043+
@override_options({"workflow_engine.issue_alert.group.type_id.ga": [1]})
1044+
def test_fire_actions_notification_uuid_propagation(
1045+
self, mock_process: MagicMock, mock_trigger: MagicMock
1046+
) -> None:
1047+
"""Verify notification_uuid from WorkflowFireHistory is passed to triggered actions."""
1048+
mock_process.return_value = (
1049+
ProcessedDataConditionGroup(logic_result=TriggerResult.TRUE, condition_results=[]),
1050+
[],
1051+
)
1052+
1053+
self.groups_to_dcgs = {
1054+
self.group1.id: {self.workflow1_if_dcgs[0]},
1055+
self.group2.id: {self.workflow2_if_dcgs[0]},
1056+
}
1057+
1058+
fire_actions_for_groups(
1059+
self.project.organization,
1060+
self.groups_to_dcgs,
1061+
self.group_to_groupevent,
1062+
)
1063+
1064+
# Verify WorkflowFireHistory records were created
1065+
history1 = WorkflowFireHistory.objects.get(
1066+
workflow=self.workflow1,
1067+
group_id=self.group1.id,
1068+
event_id=self.event1.event_id,
1069+
)
1070+
history2 = WorkflowFireHistory.objects.get(
1071+
workflow=self.workflow2,
1072+
group_id=self.group2.id,
1073+
event_id=self.event2.event_id,
1074+
)
1075+
1076+
# Verify trigger_action was called for both workflows
1077+
assert mock_trigger.call_count == 2
1078+
1079+
# Extract notification_uuids from task calls
1080+
call_1_notification_uuid = mock_trigger.call_args_list[0].kwargs["kwargs"][
1081+
"notification_uuid"
1082+
]
1083+
call_2_notification_uuid = mock_trigger.call_args_list[1].kwargs["kwargs"][
1084+
"notification_uuid"
1085+
]
1086+
1087+
# Verify the notification_uuids match the WorkflowFireHistory records
1088+
fire_history_uuids = {str(history1.notification_uuid), str(history2.notification_uuid)}
1089+
task_uuids = {call_1_notification_uuid, call_2_notification_uuid}
1090+
assert fire_history_uuids == task_uuids
1091+
10401092

10411093
class TestCleanupRedisBuffer(TestDelayedWorkflowBase):
10421094
def test_cleanup_redis(self) -> None:

0 commit comments

Comments
 (0)