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

common.rb « sub_menus « page « qa « qa - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: dc8786748773caeac31982dd18f9184f3ffc8c0a (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# frozen_string_literal: true

module QA
  module Page
    module SubMenus
      module Common
        def self.included(base)
          super

          base.class_eval do
            prepend Mobile::Page::SubMenus::Common if QA::Runtime::Env.mobile_layout?

            view 'app/assets/javascripts/super_sidebar/components/super_sidebar.vue' do
              element :navbar
            end
          end
        end

        def within_sidebar(&block)
          wait_for_requests

          within_element(:navbar, &block)
        end

        private

        # Opens the new item menu and yields to the block
        #
        # @return [void]
        def within_new_item_menu
          click_element('new-menu-toggle')

          yield
        end

        # Open sidebar navigation submenu
        #
        # @param [String] parent_menu_name
        # @param [String] parent_section_id
        # @param [String] sub_menu
        # @return [void]
        def open_submenu(parent_menu_name, sub_menu)
          # prevent closing sub-menu if it was already open
          unless has_element?(:menu_section, section_name: parent_menu_name, wait: 0)
            click_element(:menu_section_button, section_name: parent_menu_name)
          end

          within_element(:menu_section, section_name: parent_menu_name) do
            click_element(:nav_item_link, submenu_item: sub_menu)
          end
        end
      end
    end
  end
end