Skip to content

Commit

Permalink
add the resume labels as comment to testing JSON.
Browse files Browse the repository at this point in the history
  • Loading branch information
apotonick committed Jan 11, 2024
1 parent 9f77546 commit 6fa7de4
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 36 deletions.
38 changes: 29 additions & 9 deletions lib/trailblazer/workflow/state/discovery/testing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,37 @@ def self.render_json(states, lanes:, additional_state_data:, initial_lane_positi
tuple: [lanes[lane_position[:activity]], nil], # FIXME: to indicate this is a virtual "task".
}
else
position_tuple = id_tuple_for(lanes, lane_position[:activity], lane_position[:suspend])
_, task_id = position_tuple

comment = nil
task_map.invert.each do |id, label|
if task_id =~ /#{id}$/
comment = "--> #{label}" and break
end
position_tuple = id_tuple_for(lanes, lane_position[:activity], lane_position[:suspend]) # usually, this is a suspend.

# Compute the task name that follows a particular catch event.
activity = lane_position[:activity]
resumes = lane_position[:resumes]#.to_h["resumes"]

resumes_label = resumes.collect do |catch_event|
puts "@@@@@ #{catch_event.inspect}"

task_after_catch = activity.to_h[:circuit].to_h[:map][catch_event][Trailblazer::Activity::Right]
# raise task_after_catch.inspect

Trailblazer::Activity::Introspect.Nodes(activity, task: task_after_catch).data[:label] || task_after_catch
end

{tuple: position_tuple, comment: comment}


# _, task_id = position_tuple


comment = resumes_label
# task_map.invert.each do |id, label|
# if task_id =~ /#{id}$/
# comment = "--> #{label}" and break
# end
# end

{
tuple: position_tuple,
comment: comment
}
end

end
Expand Down
129 changes: 102 additions & 27 deletions test/collaboration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ def render_states(states, lanes:, additional_state_data:, task_map:)
# next if suspend.to_h["resumes"].nil?

# Compute the task name that follows a particular catch event.
# TODO: use Testing's code here.
resumes_labels = resumes.collect do |catch_event|

task_after_catch = activity.to_h[:circuit].to_h[:map][catch_event][Trailblazer::Activity::Right]
Expand Down Expand Up @@ -361,7 +362,7 @@ def render_states(states, lanes:, additional_state_data:, task_map:)


testing_json = JSON.pretty_generate(testing_json)
# puts testing_json
puts testing_json
assert_equal testing_json, %([
{
"start_position": [
Expand Down Expand Up @@ -406,7 +407,9 @@ def render_states(states, lanes:, additional_state_data:, task_map:)
"UI",
"suspend-Gateway_14h0q7a"
],
"comment": null
"comment": [
"Create"
]
},
{
"tuple": [
Expand All @@ -433,7 +436,9 @@ def render_states(states, lanes:, additional_state_data:, task_map:)
"UI",
"suspend-Gateway_14h0q7a"
],
"comment": null
"comment": [
"Create"
]
},
{
"tuple": [
Expand All @@ -454,14 +459,20 @@ def render_states(states, lanes:, additional_state_data:, task_map:)
"lifecycle",
"suspend-Gateway_0fnbg3r"
],
"comment": null
"comment": [
"Update",
"Notify approver"
]
},
{
"tuple": [
"UI",
"suspend-Gateway_0kknfje"
],
"comment": null
"comment": [
"Update form",
"Notify approver"
]
},
{
"tuple": [
Expand All @@ -482,14 +493,20 @@ def render_states(states, lanes:, additional_state_data:, task_map:)
"lifecycle",
"suspend-Gateway_0fnbg3r"
],
"comment": null
"comment": [
"Update",
"Notify approver"
]
},
{
"tuple": [
"UI",
"suspend-Gateway_0kknfje"
],
"comment": null
"comment": [
"Update form",
"Notify approver"
]
},
{
"tuple": [
Expand All @@ -510,14 +527,19 @@ def render_states(states, lanes:, additional_state_data:, task_map:)
"lifecycle",
"suspend-Gateway_0fnbg3r"
],
"comment": null
"comment": [
"Update",
"Notify approver"
]
},
{
"tuple": [
"UI",
"suspend-Gateway_0nxerxv"
],
"comment": null
"comment": [
"Update"
]
},
{
"tuple": [
Expand All @@ -538,14 +560,20 @@ def render_states(states, lanes:, additional_state_data:, task_map:)
"lifecycle",
"suspend-Gateway_0fnbg3r"
],
"comment": null
"comment": [
"Update",
"Notify approver"
]
},
{
"tuple": [
"UI",
"suspend-Gateway_0kknfje"
],
"comment": null
"comment": [
"Update form",
"Notify approver"
]
},
{
"tuple": [
Expand All @@ -566,14 +594,22 @@ def render_states(states, lanes:, additional_state_data:, task_map:)
"lifecycle",
"suspend-Gateway_1hp2ssj"
],
"comment": null
"comment": [
"Publish",
"Delete",
"Update"
]
},
{
"tuple": [
"UI",
"suspend-Gateway_1sq41iq"
],
"comment": null
"comment": [
"Update form",
"Delete? form",
"Publish"
]
},
null
]
Expand All @@ -589,14 +625,22 @@ def render_states(states, lanes:, additional_state_data:, task_map:)
"lifecycle",
"suspend-Gateway_1hp2ssj"
],
"comment": null
"comment": [
"Publish",
"Delete",
"Update"
]
},
{
"tuple": [
"UI",
"suspend-Gateway_1sq41iq"
],
"comment": null
"comment": [
"Update form",
"Delete? form",
"Publish"
]
},
null
]
Expand All @@ -612,14 +656,19 @@ def render_states(states, lanes:, additional_state_data:, task_map:)
"lifecycle",
"suspend-Gateway_0fnbg3r"
],
"comment": null
"comment": [
"Update",
"Notify approver"
]
},
{
"tuple": [
"UI",
"suspend-Gateway_0nxerxv"
],
"comment": null
"comment": [
"Update"
]
},
{
"tuple": [
Expand All @@ -640,14 +689,18 @@ def render_states(states, lanes:, additional_state_data:, task_map:)
"lifecycle",
"suspend-Gateway_01p7uj7"
],
"comment": null
"comment": [
"Revise"
]
},
{
"tuple": [
"UI",
"suspend-gw-to-catch-before-Activity_0zsock2"
],
"comment": "--> ui_revise_form"
"comment": [
"Revise form"
]
},
null
]
Expand All @@ -663,14 +716,21 @@ def render_states(states, lanes:, additional_state_data:, task_map:)
"lifecycle",
"suspend-Gateway_1hp2ssj"
],
"comment": null
"comment": [
"Publish",
"Delete",
"Update"
]
},
{
"tuple": [
"UI",
"suspend-Gateway_100g9dn"
],
"comment": null
"comment": [
"Delete",
"Cancel"
]
},
null
]
Expand All @@ -686,14 +746,21 @@ def render_states(states, lanes:, additional_state_data:, task_map:)
"lifecycle",
"suspend-Gateway_1hp2ssj"
],
"comment": null
"comment": [
"Publish",
"Delete",
"Update"
]
},
{
"tuple": [
"UI",
"suspend-Gateway_100g9dn"
],
"comment": null
"comment": [
"Delete",
"Cancel"
]
},
null
]
Expand All @@ -709,14 +776,18 @@ def render_states(states, lanes:, additional_state_data:, task_map:)
"lifecycle",
"suspend-gw-to-catch-before-Activity_1hgscu3"
],
"comment": null
"comment": [
"Archive"
]
},
{
"tuple": [
"UI",
"suspend-gw-to-catch-before-Activity_0fy41qq"
],
"comment": "--> ui_archive"
"comment": [
"Archive"
]
},
null
]
Expand All @@ -732,14 +803,18 @@ def render_states(states, lanes:, additional_state_data:, task_map:)
"lifecycle",
"suspend-Gateway_01p7uj7"
],
"comment": null
"comment": [
"Revise"
]
},
{
"tuple": [
"UI",
"suspend-Gateway_1xs96ik"
],
"comment": null
"comment": [
"Revise"
]
},
null
]
Expand Down

0 comments on commit 6fa7de4

Please sign in to comment.