diff --git a/backend/app/views/spree/admin/shared/_product_sub_menu.html.erb b/backend/app/views/spree/admin/shared/_product_sub_menu.html.erb index f57fa71aeaa..dd44c97eeda 100644 --- a/backend/app/views/spree/admin/shared/_product_sub_menu.html.erb +++ b/backend/app/views/spree/admin/shared/_product_sub_menu.html.erb @@ -12,6 +12,6 @@ <%= tab :taxonomies %> <% end %> <% if can? :admin, Spree::Taxon %> - <%= tab :taxons, label: :display_order %> + <%= tab :taxons, label: :display_order, match_path: '/taxons' %> <% end %> diff --git a/backend/spec/features/admin/taxons_spec.rb b/backend/spec/features/admin/taxons_spec.rb index 01a0b740bce..76a240a9bd9 100644 --- a/backend/spec/features/admin/taxons_spec.rb +++ b/backend/spec/features/admin/taxons_spec.rb @@ -40,4 +40,39 @@ expect(page).to have_current_path %r{/admin/taxonomies/\d+/taxons/\d+/edit} end + + context "inside sidebar menu" do + def only_one_selected_tab_inside?(sub_tab_selector, tab_name, tab_path) + within(sub_tab_selector) do + expect(page).to have_selector('.selected', count: 1) + + within('.selected') { expect(page).to have_link(tab_name, href: tab_path) } + end + end + + context "on display taxonomies page", js: true do + it "should be selected only one tab 'Taxonomies' in product sub tabs" do + visit spree.admin_taxonomies_path + only_one_selected_tab_inside?('[data-hook=admin_product_sub_tabs]', 'Taxonomies', spree.admin_taxonomies_path) + end + end + + context "on edit taxonomy page", js: true do + it "should be selected only one tab 'Taxonomies' in product sub tabs" do + taxonomy = create :taxonomy + + visit spree.edit_admin_taxonomy_path(taxonomy) + only_one_selected_tab_inside?('[data-hook=admin_product_sub_tabs]', 'Taxonomies', spree.admin_taxonomies_path) + end + end + + context "on edit taxonomy's taxon page", js: true do + it "should be selected only one tab 'Taxonomies' in product sub tabs" do + taxonomy = create :taxonomy + + visit spree.edit_admin_taxonomy_taxon_path(taxonomy, taxonomy.root.id) + only_one_selected_tab_inside?('[data-hook=admin_product_sub_tabs]', 'Taxonomies', spree.admin_taxonomies_path) + end + end + end end