summaryrefslogtreecommitdiff
path: root/qa/qa/page/project/menu.rb
blob: bc125d1af8893c077dea282971b47f6de17df520 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# frozen_string_literal: true

module QA
  module Page
    module Project
      class Menu < Page::Base
        view 'app/views/layouts/nav/sidebar/_project.html.haml' do
          element :settings_item
          element :settings_link, 'link_to edit_project_path' # rubocop:disable QA/ElementWithPattern
          element :repository_link, "title: _('Repository')" # rubocop:disable QA/ElementWithPattern
          element :link_pipelines
          element :link_members_settings
          element :pipelines_settings_link, "title: _('CI / CD')" # rubocop:disable QA/ElementWithPattern
          element :operations_kubernetes_link, "title: _('Kubernetes')" # rubocop:disable QA/ElementWithPattern
          element :operations_environments_link
          element :issues_link, /link_to.*shortcuts-issues/ # rubocop:disable QA/ElementWithPattern
          element :issues_link_text, "Issues" # rubocop:disable QA/ElementWithPattern
          element :merge_requests_link, /link_to.*shortcuts-merge_requests/ # rubocop:disable QA/ElementWithPattern
          element :merge_requests_link_text, "Merge Requests" # rubocop:disable QA/ElementWithPattern
          element :top_level_items, '.sidebar-top-level-items' # rubocop:disable QA/ElementWithPattern
          element :operations_section, "class: 'shortcuts-operations'" # rubocop:disable QA/ElementWithPattern
          element :activity_link, "title: _('Activity')" # rubocop:disable QA/ElementWithPattern
          element :wiki_link_text, "Wiki" # rubocop:disable QA/ElementWithPattern
          element :milestones_link
          element :labels_link
        end

        view 'app/assets/javascripts/fly_out_nav.js' do
          element :fly_out, "classList.add('fly-out-list')" # rubocop:disable QA/ElementWithPattern
        end

        def click_repository_settings
          hover_settings do
            within_submenu do
              click_link('Repository')
            end
          end
        end

        def click_ci_cd_settings
          hover_settings do
            within_submenu do
              click_link('CI / CD')
            end
          end
        end

        def click_operations_environments
          hover_operations do
            within_submenu do
              click_element(:operations_environments_link)
            end
          end
        end

        def click_members_settings
          hover_settings do
            within_submenu do
              click_element :link_members_settings
            end
          end
        end

        def click_operations_kubernetes
          hover_operations do
            within_submenu do
              click_link('Kubernetes')
            end
          end
        end

        def click_ci_cd_pipelines
          within_sidebar do
            click_element :link_pipelines
          end
        end

        def go_to_settings
          within_sidebar do
            click_on 'Settings'
          end
        end

        def click_issues
          within_sidebar do
            click_link('Issues')
          end
        end

        def click_merge_requests
          within_sidebar do
            click_link('Merge Requests')
          end
        end

        def click_milestones
          within_sidebar do
            click_element :milestones_link
          end
        end

        def click_wiki
          within_sidebar do
            click_link('Wiki')
          end
        end

        def go_to_labels
          hover_issues { click_element :labels_link }
        end

        private

        def hover_issues
          within_sidebar do
            find_element(:issues_item).hover

            yield
          end
        end

        def hover_settings
          within_sidebar do
            find('.qa-settings-item').hover

            yield
          end
        end

        def hover_operations
          within_sidebar do
            find('.shortcuts-operations').hover

            yield
          end
        end

        def within_sidebar
          page.within('.sidebar-top-level-items') do
            yield
          end
        end

        def go_to_activity
          within_sidebar do
            click_on 'Activity'
          end
        end

        def within_submenu
          page.within('.fly-out-list') do
            yield
          end
        end
      end
    end
  end
end