From cc70f738f4134d89f6f179d6c96808d9e29ec66d Mon Sep 17 00:00:00 2001 From: Nick Sutterer Date: Mon, 19 Feb 2024 11:09:24 +0100 Subject: [PATCH] better rendering of test plan comment header. --- lib/trailblazer/workflow/test/plan.rb | 44 +++++++++++---------------- test/discovery_test.rb | 38 +++++++++++------------ 2 files changed, 37 insertions(+), 45 deletions(-) diff --git a/lib/trailblazer/workflow/test/plan.rb b/lib/trailblazer/workflow/test/plan.rb index 7ab15cb..2dd6218 100644 --- a/lib/trailblazer/workflow/test/plan.rb +++ b/lib/trailblazer/workflow/test/plan.rb @@ -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] @@ -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", @@ -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. diff --git a/test/discovery_test.rb b/test/discovery_test.rb index f1a1cbb..cd32f37 100644 --- a/test/discovery_test.rb +++ b/test/discovery_test.rb @@ -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