Welcome to mirror list, hosted at ThFree Co, Russian Federation.

navbar_shared_examples.rb « features « shared_examples « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c768e95c45ab8d801cfda1b65449923dc127edb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

RSpec.shared_examples 'verified navigation bar' do
  let(:expected_structure) do
    structure.compact!
    structure.each { |s| s[:nav_sub_items]&.compact! }
    structure
  end

  it 'renders correctly' do
    current_structure = page.all('.sidebar-top-level-items > li', class: ['!hidden']).map do |item|
      next if item.find_all('a').empty?

      nav_item = item.find_all('a').first.text.gsub(/\s+\d+$/, '') # remove counts at the end

      nav_sub_items = item.all('.sidebar-sub-level-items > li', class: ['!fly-out-top-item']).map do |list_item|
        list_item.all('a').first.text
      end

      { nav_item: nav_item, nav_sub_items: nav_sub_items }
    end.compact

    expect(current_structure).to eq(expected_structure)
  end
end