From c60ea3c4a98bff0b9a49f38d61cab6d26afacaae Mon Sep 17 00:00:00 2001 From: Nick Sutterer Date: Fri, 12 Jan 2024 17:39:52 +0100 Subject: [PATCH] show `comment` for start event, too. --- .../workflow/state/discovery/testing.rb | 19 +- test/collaboration_test.rb | 424 +----------------- 2 files changed, 15 insertions(+), 428 deletions(-) diff --git a/lib/trailblazer/workflow/state/discovery/testing.rb b/lib/trailblazer/workflow/state/discovery/testing.rb index 767308f..e1750a9 100644 --- a/lib/trailblazer/workflow/state/discovery/testing.rb +++ b/lib/trailblazer/workflow/state/discovery/testing.rb @@ -45,9 +45,7 @@ def self.render_json(states, lanes:, additional_state_data:, initial_lane_positi resumes = Discovery.resumes_from_suspend(activity, suspend) resumes_label = resumes.collect do |catch_event| - task_after_catch = activity.to_h[:circuit].to_h[:map][catch_event][Trailblazer::Activity::Right] - - Trailblazer::Activity::Introspect.Nodes(activity, task: task_after_catch).data[:label] || task_after_catch + find_next_task_label(activity, catch_event) end @@ -66,15 +64,24 @@ def self.render_json(states, lanes:, additional_state_data:, initial_lane_positi end - { - start_position: [activity_id, triggered_catch_event_id], + start_position: { + tuple: [activity_id, triggered_catch_event_id], + comment: find_next_task_label(start_position.activity, start_position.task) + }, expected_lane_positions: expected_lane_positions, } end end - end + + # Find the next connected task, usually outgoing from a catch event. + def self.find_next_task_label(activity, catch_event) + task_after_catch = activity.to_h[:circuit].to_h[:map][catch_event][Trailblazer::Activity::Right] + + Trailblazer::Activity::Introspect.Nodes(activity, task: task_after_catch).data[:label] || task_after_catch + end + end # Testing end end end diff --git a/test/collaboration_test.rb b/test/collaboration_test.rb index 1760ed0..2d9cb08 100644 --- a/test/collaboration_test.rb +++ b/test/collaboration_test.rb @@ -367,428 +367,8 @@ def render_states(states, lanes:, additional_state_data:, task_map:) testing_json = JSON.pretty_generate(testing_json) - # puts testing_json - assert_equal testing_json, %([ - { - "start_position": [ - "UI", - "catch-before-Activity_0wc2mcq" - ], - "expected_lane_positions": [ - { - "tuple": [ - "lifecycle", - null - ] - }, - { - "tuple": [ - "UI", - "suspend-Gateway_14h0q7a" - ], - "comment": [ - "Create" - ] - }, - { - "tuple": [ - "approver", - null - ] - } - ] - }, - { - "start_position": [ - "UI", - "catch-before-Activity_1psp91r" - ], - "expected_lane_positions": [ - { - "tuple": [ - "lifecycle", - "suspend-Gateway_0fnbg3r" - ], - "comment": [ - "Update", - "Notify approver" - ] - }, - { - "tuple": [ - "UI", - "suspend-Gateway_0kknfje" - ], - "comment": [ - "Update form", - "Notify approver" - ] - }, - { - "tuple": [ - "approver", - null - ] - } - ] - }, - { - "start_position": [ - "UI", - "catch-before-Activity_1psp91r" - ], - "expected_lane_positions": [ - { - "tuple": [ - "lifecycle", - "suspend-gw-to-catch-before-Activity_0wwfenp" - ], - "comment": [ - "Create" - ] - }, - { - "tuple": [ - "UI", - "suspend-Gateway_14h0q7a" - ], - "comment": [ - "Create" - ] - }, - { - "tuple": [ - "approver", - null - ] - } - ] - }, - { - "start_position": [ - "UI", - "catch-before-Activity_1165bw9" - ], - "expected_lane_positions": [ - { - "tuple": [ - "lifecycle", - "suspend-Gateway_0fnbg3r" - ], - "comment": [ - "Update", - "Notify approver" - ] - }, - { - "tuple": [ - "UI", - "suspend-Gateway_0nxerxv" - ], - "comment": [ - "Update" - ] - }, - { - "tuple": [ - "approver", - null - ] - } - ] - }, - { - "start_position": [ - "UI", - "catch-before-Activity_1dt5di5" - ], - "expected_lane_positions": [ - { - "tuple": [ - "lifecycle", - "suspend-Gateway_1hp2ssj" - ], - "comment": [ - "Publish", - "Delete", - "Update" - ] - }, - { - "tuple": [ - "UI", - "suspend-Gateway_1sq41iq" - ], - "comment": [ - "Update form", - "Delete? form", - "Publish" - ] - }, - null - ] - }, - { - "start_position": [ - "UI", - "catch-before-Activity_0j78uzd" - ], - "expected_lane_positions": [ - { - "tuple": [ - "lifecycle", - "suspend-Gateway_1wzosup" - ], - "comment": [ - "Notify approver", - "Update" - ] - }, - { - "tuple": [ - "UI", - "suspend-Gateway_1g3fhu2" - ], - "comment": [ - "Update form", - "Notify approver" - ] - }, - { - "tuple": [ - "approver", - null - ] - } - ] - }, - { - "start_position": [ - "UI", - "catch-before-Activity_1dt5di5" - ], - "expected_lane_positions": [ - { - "tuple": [ - "lifecycle", - "suspend-Gateway_01p7uj7" - ], - "comment": [ - "Revise" - ] - }, - { - "tuple": [ - "UI", - "suspend-gw-to-catch-before-Activity_0zsock2" - ], - "comment": [ - "Revise form" - ] - }, - null - ] - }, - { - "start_position": [ - "UI", - "catch-before-Activity_0ha7224" - ], - "expected_lane_positions": [ - { - "tuple": [ - "lifecycle", - "suspend-Gateway_1hp2ssj" - ], - "comment": [ - "Publish", - "Delete", - "Update" - ] - }, - { - "tuple": [ - "UI", - "suspend-Gateway_100g9dn" - ], - "comment": [ - "Delete", - "Cancel" - ] - }, - null - ] - }, - { - "start_position": [ - "UI", - "catch-before-Activity_0bsjggk" - ], - "expected_lane_positions": [ - { - "tuple": [ - "lifecycle", - "suspend-gw-to-catch-before-Activity_1hgscu3" - ], - "comment": [ - "Archive" - ] - }, - { - "tuple": [ - "UI", - "suspend-gw-to-catch-before-Activity_0fy41qq" - ], - "comment": [ - "Archive" - ] - }, - null - ] - }, - { - "start_position": [ - "UI", - "catch-before-Activity_0j78uzd" - ], - "expected_lane_positions": [ - { - "tuple": [ - "lifecycle", - "suspend-Gateway_0fnbg3r" - ], - "comment": [ - "Update", - "Notify approver" - ] - }, - { - "tuple": [ - "UI", - "suspend-Gateway_0nxerxv" - ], - "comment": [ - "Update" - ] - }, - { - "tuple": [ - "approver", - null - ] - } - ] - }, - { - "start_position": [ - "UI", - "catch-before-Activity_0zsock2" - ], - "expected_lane_positions": [ - { - "tuple": [ - "lifecycle", - "suspend-Gateway_01p7uj7" - ], - "comment": [ - "Revise" - ] - }, - { - "tuple": [ - "UI", - "suspend-Gateway_1xs96ik" - ], - "comment": [ - "Revise" - ] - }, - null - ] - }, - { - "start_position": [ - "UI", - "catch-before-Activity_15nnysv" - ], - "expected_lane_positions": [ - null, - null, - null - ] - }, - { - "start_position": [ - "UI", - "catch-before-Activity_1uhozy1" - ], - "expected_lane_positions": [ - { - "tuple": [ - "lifecycle", - "suspend-Gateway_1hp2ssj" - ], - "comment": [ - "Publish", - "Delete", - "Update" - ] - }, - { - "tuple": [ - "UI", - "suspend-Gateway_1sq41iq" - ], - "comment": [ - "Update form", - "Delete? form", - "Publish" - ] - }, - null - ] - }, - { - "start_position": [ - "UI", - "catch-before-Activity_0fy41qq" - ], - "expected_lane_positions": [ - null, - null, - null - ] - }, - { - "start_position": [ - "UI", - "catch-before-Activity_1wiumzv" - ], - "expected_lane_positions": [ - { - "tuple": [ - "lifecycle", - "suspend-Gateway_1kl7pnm" - ], - "comment": [ - "Revise", - "Notify approver" - ] - }, - { - "tuple": [ - "UI", - "suspend-Gateway_1g3fhu2" - ], - "comment": [ - "Update form", - "Notify approver" - ] - }, - null - ] - } -]) + puts testing_json + assert_equal testing_json, %()