Skip to content

Commit

Permalink
better rendering of test plan comment header.
Browse files Browse the repository at this point in the history
  • Loading branch information
apotonick committed Feb 19, 2024
1 parent 8d0735a commit cc70f73
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 45 deletions.
44 changes: 18 additions & 26 deletions lib/trailblazer/workflow/test/plan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,31 +99,8 @@ module CommentHeader
module_function

def call(discovered_states, **options)

all_start_position_labels = discovered_states.collect do |row|
row[:positions_before][0].collect do |activity, task|
[
activity,
Discovery::Present.readable_name_for_suspend_or_terminus(activity, task, **options)
]
end
end

start_position_combined_column = format_positions_column(all_start_position_labels, **options)


all_expected_positions_labels = discovered_states.collect do |row|
row[:suspend_configuration].lane_positions.collect do |activity, task|
[
activity,
Discovery::Present.readable_name_for_suspend_or_terminus(activity, task, **options)
]
end
end

expected_position_combined_column = format_positions_column(all_expected_positions_labels, **options)


start_position_combined_column = render_combined_column_labels(discovered_states.collect { |row| row[:positions_before][0] }, **options)
expected_position_combined_column = render_combined_column_labels(discovered_states.collect { |row| row[:suspend_configuration].lane_positions }, **options)

rows = discovered_states.collect.with_index do |row, index|
positions_before, start_position = row[:positions_before]
Expand All @@ -133,7 +110,6 @@ def call(discovered_states, **options)
start_position_label(start_position, row, **options),

"start configuration",
# start_configuration(positions_before, **options)
start_position_combined_column[index],

"expected reached configuration",
Expand All @@ -158,6 +134,22 @@ def start_position_label_for(position, expected_outcome:, **options)
event_label
end

# Render the content of a combined column (usually used for positions, such as {}).
# Note that this renders for the entire table/all rows.
#
# ⛾ ⏵︎Update ⏵︎Notify approver ☝ ⏵︎Update form ⏵︎Notify approver ☑ ⏵︎xxx
def render_combined_column_labels(positions_rows, **options)
all_position_labels = positions_rows.collect do |positions|
positions.collect do |activity, task|
[
activity,
Discovery::Present.readable_name_for_suspend_or_terminus(activity, task, **options)
]
end
end

position_combined_column = format_positions_column(all_position_labels, **options)
end

def compute_combined_column_widths(position_rows, lanes_cfg:, **)
chars_to_filter = Discovery::Present::ICONS.values + lanes_cfg.collect { |_, cfg| cfg[:icon] } # TODO: do this way up in the code path.
Expand Down
38 changes: 19 additions & 19 deletions test/discovery_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -306,24 +306,24 @@ class DiscoveryTestPlanTest < Minitest::Spec
test_plan_comment_header = Trailblazer::Workflow::Test::Plan.render_comment_header(states, lanes_cfg: lanes_cfg)
puts test_plan_comment_header
assert_equal test_plan_comment_header,
%(+----------------------+---------------------------------------------------------------------------------+
| triggered catch | start configuration |
+----------------------+---------------------------------------------------------------------------------+
| ☝ ⏵︎Create form | ⛾ ⏵︎Create ☝ ⏵︎Create form ☑ ⏵︎xxx |
| ☝ ⏵︎Create | ⛾ ⏵︎Create ☝ ⏵︎Create ☑ ⏵︎xxx |
| ☝ ⏵︎Create ⛞ | ⛾ ⏵︎Create ☝ ⏵︎Create ☑ ⏵︎xxx |
| ☝ ⏵︎Update form | ⛾ ⏵︎Update ⏵︎Notify approver ☝ ⏵︎Update form ⏵︎Notify approver ☑ ⏵︎xxx |
| ☝ ⏵︎Notify approver | ⛾ ⏵︎Update ⏵︎Notify approver ☝ ⏵︎Update form ⏵︎Notify approver ☑ ⏵︎xxx |
| ☝ ⏵︎Update | ⛾ ⏵︎Update ⏵︎Notify approver ☝ ⏵︎Update ☑ ⏵︎xxx |
| ☝ ⏵︎Notify approver ⛞ | ⛾ ⏵︎Update ⏵︎Notify approver ☝ ⏵︎Update form ⏵︎Notify approver ☑ ⏵︎xxx |
| ☝ ⏵︎Delete? form | ⛾ ⏵︎Publish ⏵︎Delete ⏵︎Update ☝ ⏵︎Update form ⏵︎Delete? form ⏵︎Publish ☑ ◉End.failure |
| ☝ ⏵︎Publish | ⛾ ⏵︎Publish ⏵︎Delete ⏵︎Update ☝ ⏵︎Update form ⏵︎Delete? form ⏵︎Publish ☑ ◉End.failure |
| ☝ ⏵︎Update ⛞ | ⛾ ⏵︎Update ⏵︎Notify approver ☝ ⏵︎Update ☑ ⏵︎xxx |
| ☝ ⏵︎Revise form | ⛾ ⏵︎Revise ☝ ⏵︎Revise form ☑ ◉End.success |
| ☝ ⏵︎Delete | ⛾ ⏵︎Publish ⏵︎Delete ⏵︎Update ☝ ⏵︎Delete ⏵︎Cancel ☑ ◉End.failure |
| ☝ ⏵︎Cancel | ⛾ ⏵︎Publish ⏵︎Delete ⏵︎Update ☝ ⏵︎Delete ⏵︎Cancel ☑ ◉End.failure |
| ☝ ⏵︎Archive | ⛾ ⏵︎Archive ☝ ⏵︎Archive ☑ ◉End.failure |
| ☝ ⏵︎Revise | ⛾ ⏵︎Revise ☝ ⏵︎Revise ☑ ◉End.success |
+----------------------+---------------------------------------------------------------------------------+)
%(+----------------------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------------+
| triggered catch | start configuration | expected reached configuration |
+----------------------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------------+
| ☝ ⏵︎Create form | ⛾ ⏵︎Create ☝ ⏵︎Create form ☑ ⏵︎xxx | ⛾ ⏵︎Create ☝ ⏵︎Create ☑ ⏵︎xxx |
| ☝ ⏵︎Create | ⛾ ⏵︎Create ☝ ⏵︎Create ☑ ⏵︎xxx | ⛾ ⏵︎Update ⏵︎Notify approver ☝ ⏵︎Update form ⏵︎Notify approver ☑ ⏵︎xxx |
| ☝ ⏵︎Create ⛞ | ⛾ ⏵︎Create ☝ ⏵︎Create ☑ ⏵︎xxx | ⛾ ⏵︎Create ☝ ⏵︎Create ☑ ⏵︎xxx |
| ☝ ⏵︎Update form | ⛾ ⏵︎Update ⏵︎Notify approver ☝ ⏵︎Update form ⏵︎Notify approver ☑ ⏵︎xxx | ⛾ ⏵︎Update ⏵︎Notify approver ☝ ⏵︎Update ☑ ⏵︎xxx |
| ☝ ⏵︎Notify approver | ⛾ ⏵︎Update ⏵︎Notify approver ☝ ⏵︎Update form ⏵︎Notify approver ☑ ⏵︎xxx | ⛾ ⏵︎Publish ⏵︎Delete ⏵︎Update ☝ ⏵︎Update form ⏵︎Delete? form ⏵︎Publish ☑ ◉End.failure |
| ☝ ⏵︎Update | ⛾ ⏵︎Update ⏵︎Notify approver ☝ ⏵︎Update ☑ ⏵︎xxx | ⛾ ⏵︎Notify approver ⏵︎Update ☝ ⏵︎Update form ⏵︎Notify approver ☑ ⏵︎xxx |
| ☝ ⏵︎Notify approver ⛞ | ⛾ ⏵︎Update ⏵︎Notify approver ☝ ⏵︎Update form ⏵︎Notify approver ☑ ⏵︎xxx | ⛾ ⏵︎Revise ☝ ⏵︎Revise form ☑ ◉End.success |
| ☝ ⏵︎Delete? form | ⛾ ⏵︎Publish ⏵︎Delete ⏵︎Update ☝ ⏵︎Update form ⏵︎Delete? form ⏵︎Publish ☑ ◉End.failure | ⛾ ⏵︎Publish ⏵︎Delete ⏵︎Update ☝ ⏵︎Delete ⏵︎Cancel ☑ ◉End.failure |
| ☝ ⏵︎Publish | ⛾ ⏵︎Publish ⏵︎Delete ⏵︎Update ☝ ⏵︎Update form ⏵︎Delete? form ⏵︎Publish ☑ ◉End.failure | ⛾ ⏵︎Archive ☝ ⏵︎Archive ☑ ◉End.failure |
| ☝ ⏵︎Update ⛞ | ⛾ ⏵︎Update ⏵︎Notify approver ☝ ⏵︎Update ☑ ⏵︎xxx | ⛾ ⏵︎Update ⏵︎Notify approver ☝ ⏵︎Update ☑ ⏵︎xxx |
| ☝ ⏵︎Revise form | ⛾ ⏵︎Revise ☝ ⏵︎Revise form ☑ ◉End.success | ⛾ ⏵︎Revise ☝ ⏵︎Revise ☑ ◉End.success |
| ☝ ⏵︎Delete | ⛾ ⏵︎Publish ⏵︎Delete ⏵︎Update ☝ ⏵︎Delete ⏵︎Cancel ☑ ◉End.failure | ⛾ ◉End.success ☝ ◉End.success ☑ ◉End.failure |
| ☝ ⏵︎Cancel | ⛾ ⏵︎Publish ⏵︎Delete ⏵︎Update ☝ ⏵︎Delete ⏵︎Cancel ☑ ◉End.failure | ⛾ ⏵︎Publish ⏵︎Delete ⏵︎Update ☝ ⏵︎Update form ⏵︎Delete? form ⏵︎Publish ☑ ◉End.failure |
| ☝ ⏵︎Archive | ⛾ ⏵︎Archive ☝ ⏵︎Archive ☑ ◉End.failure | ⛾ ◉End.success ☝ ◉End.success ☑ ◉End.failure |
| ☝ ⏵︎Revise | ⛾ ⏵︎Revise ☝ ⏵︎Revise ☑ ◉End.success | ⛾ ⏵︎Revise ⏵︎Notify approver ☝ ⏵︎Update form ⏵︎Notify approver ☑ ◉End.success |
+----------------------+---------------------------------------------------------------------------------+---------------------------------------------------------------------------------+)
end
end

0 comments on commit cc70f73

Please sign in to comment.