debian-mirror-gitlab/spec/support/shared_examples/features/navbar_shared_examples.rb

27 lines
885 B
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
RSpec.shared_examples 'verified navigation bar' do
let(:expected_structure) do
structure.compact!
2021-01-03 14:25:43 +05:30
structure.each { |s| s[:nav_sub_items]&.compact! }
2020-03-13 15:44:24 +05:30
structure
end
it 'renders correctly' do
2021-03-11 19:13:27 +05:30
# we are using * here in the selectors to prevent a regression where we added a non 'li' inside an 'ul'
current_structure = page.all('.sidebar-top-level-items > *', class: ['!hidden']).map do |item|
2021-01-03 14:25:43 +05:30
next if item.find_all('a').empty?
2020-03-13 15:44:24 +05:30
nav_item = item.find_all('a').first.text.gsub(/\s+\d+$/, '') # remove counts at the end
2021-03-11 19:13:27 +05:30
nav_sub_items = item.all('.sidebar-sub-level-items > *', class: ['!fly-out-top-item']).map do |list_item|
2020-03-13 15:44:24 +05:30
list_item.all('a').first.text
end
{ nav_item: nav_item, nav_sub_items: nav_sub_items }
2021-01-03 14:25:43 +05:30
end.compact
2020-03-13 15:44:24 +05:30
expect(current_structure).to eq(expected_structure)
end
end