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: 28b4cb37333db7e67d33167d5a25977ec4bce6a3 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
# frozen_string_literal: true

module QA
  module Page
    module SubMenus
      module Common
        prepend Mobile::Page::SubMenus::Common if QA::Runtime::Env.mobile_layout?

        def hover_element(element)
          within_sidebar do
            find_element(element).hover
            yield
          end
        end

        def within_sidebar(&block)
          wait_for_requests

          within_element(sidebar_element, &block)
        end

        def within_submenu(element = nil, &block)
          if element
            within_element(element, &block)
          else
            within_submenu_without_element(&block)
          end
        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

        # Implementation for super-sidebar, will replace within_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

        def within_submenu_without_element(&block)
          has_css?('.fly-out-list') ? within('.fly-out-list', &block) : yield
        end

        def sidebar_element
          raise NotImplementedError
        end
      end
    end
  end
end