summaryrefslogtreecommitdiff
path: root/qa/qa/page/component/legacy_clone_panel.rb
blob: 99132190f3faee978cc7c4bc8206bdc6640fe094 (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 Component
      module LegacyClonePanel
        def self.included(base)
          base.view 'app/views/shared/_clone_panel.html.haml' do
            element :clone_dropdown
            element :clone_options_dropdown, '.clone-options-dropdown' # rubocop:disable QA/ElementWithPattern
            element :project_repository_location, 'text_field_tag :project_clone' # rubocop:disable QA/ElementWithPattern
          end
        end

        def choose_repository_clone_http
          choose_repository_clone('HTTP', 'http')
        end

        def choose_repository_clone_ssh
          # It's not always beginning with ssh:// so detecting with @
          # would be more reliable because ssh would always contain it.
          # We can't use .git because HTTP also contain that part.
          choose_repository_clone('SSH', '@')
        end

        def repository_location
          Git::Location.new(find('#project_clone').value)
        end

        def wait_for_push
          sleep 5
          refresh
        end

        private

        def choose_repository_clone(kind, detect_text)
          wait(reload: false) do
            click_element :clone_dropdown

            page.within('.clone-options-dropdown') do
              click_link(kind)
            end

            # Ensure git clone textbox was updated
            repository_location.git_uri.include?(detect_text)
          end
        end
      end
    end
  end
end