summaryrefslogtreecommitdiff
path: root/qa/qa/page/sub_menus/common.rb
blob: 2efeeb062e84529c032d915785de291b0cfb7d97 (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
# frozen_string_literal: true

module QA
  module Page
    module SubMenus
      module Common
        def hover_element(element)
          within_sidebar do
            find_element(element).hover
            yield
          end
        end

        def within_sidebar
          wait_for_requests

          within_element(sidebar_element) do
            yield
          end
        end

        def within_submenu(element = nil)
          if element
            within_element(element) do
              yield
            end
          else
            within_submenu_without_element do
              yield
            end
          end
        end

        private

        def within_submenu_without_element
          if has_css?('.fly-out-list')
            within('.fly-out-list') do
              yield
            end
          else
            yield
          end
        end

        def sidebar_element
          raise NotImplementedError
        end
      end
    end
  end
end