From 11f0b35c40c3c6ae5a575a070b7831b3d6590cae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominic=20Br=C3=A4unlein?= Date: Wed, 29 Nov 2023 18:01:09 +0300 Subject: [PATCH 1/2] [#51279] Fix breadcrumb for editing custom fields is missing https://community.openproject.org/work_packages/51279 --- app/helpers/breadcrumb_helper.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/helpers/breadcrumb_helper.rb b/app/helpers/breadcrumb_helper.rb index 5dc8dde4206..b519c9200be 100644 --- a/app/helpers/breadcrumb_helper.rb +++ b/app/helpers/breadcrumb_helper.rb @@ -28,9 +28,8 @@ module BreadcrumbHelper def full_breadcrumbs - items = breadcrumb_paths.compact - render(Primer::Beta::Breadcrumbs.new(test_selector: "op-breadcrumb" )) do |breadcrumbs| - items.each_with_index do |item, index| + render(Primer::Beta::Breadcrumbs.new(test_selector: "op-breadcrumb")) do |breadcrumbs| + breadcrumb_paths.each_with_index do |item, index| item = anchor_string_to_object(item) if item.is_a?(String) && item.start_with?("\u003c") if item.is_a?(Hash) @@ -47,7 +46,7 @@ module BreadcrumbHelper @breadcrumb_paths ||= [default_breadcrumb] else @breadcrumb_paths ||= [] - @breadcrumb_paths += args + @breadcrumb_paths += args.flatten.compact end end From f6f47009b1f6bdc465dc9090905a59a4c6a406bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominic=20Br=C3=A4unlein?= Date: Wed, 29 Nov 2023 23:31:24 +0300 Subject: [PATCH 2/2] chore[#51279] Add tests for breadcrumbs in new and edit custom fields --- .../custom_fields/custom_fields_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spec/features/custom_fields/custom_fields_spec.rb b/spec/features/custom_fields/custom_fields_spec.rb index 51e92971d18..337959d3e62 100644 --- a/spec/features/custom_fields/custom_fields_spec.rb +++ b/spec/features/custom_fields/custom_fields_spec.rb @@ -152,6 +152,18 @@ RSpec.describe 'custom fields', js: true, with_cuprite: true do label_min_length, label_max_length, label_regexp, label_possible_values, label_default_value) end + + it "shows the correct breadcrumbs" do + cf_page.visit_tab type + + click_on "Create a new custom field" + wait_for_reload + + page.within_test_selector('op-breadcrumb') do + expect(page).to have_selector('.breadcrumb-item', text: type) + expect(page).to have_selector('.breadcrumb-item.breadcrumb-item-selected', text: "New custom field") + end + end end describe 'projects' do @@ -247,6 +259,13 @@ RSpec.describe 'custom fields', js: true, with_cuprite: true do expect(page).to have_field("custom_field_custom_options_attributes_3_default_value", checked: true) end + it "shows the correct breadcrumbs" do + page.within_test_selector('op-breadcrumb') do + expect(page).to have_selector('.breadcrumb-item', text: "Work packages") + expect(page).to have_selector('.breadcrumb-item.breadcrumb-item-selected', text: "Platform") + end + end + context "with work packages using the options" do before do create_list(