Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tab selection in sidebar navigation #2918

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
</ul>
35 changes: 35 additions & 0 deletions backend/spec/features/admin/taxons_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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