summaryrefslogtreecommitdiff
path: root/qa/qa/page/project/fork/new.rb
blob: cd743b648d81f05dd43ef3d8732ca327a61b9106 (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
# frozen_string_literal: true

module QA
  module Page
    module Project
      module Fork
        class New < Page::Base
          view 'app/views/projects/forks/_fork_button.html.haml' do
            element :fork_namespace_button
          end

          view 'app/assets/javascripts/pages/projects/forks/new/components/fork_form.vue' do
            element :fork_namespace_dropdown
            element :fork_project_button
            element :fork_privacy_button
          end

          def fork_project(namespace = Runtime::Namespace.path)
            if has_element?(:fork_namespace_button, wait: 0)
              click_element(:fork_namespace_button, name: namespace)
            else
              select_element(:fork_namespace_dropdown, namespace)
              click_element(:fork_privacy_button, privacy_level: 'public')
              click_element(:fork_project_button)
            end
          end

          def fork_namespace_dropdown_values
            find_element(:fork_namespace_dropdown).all(:option).map { |option| option.text.tr("\n", '').strip }
          end
        end
      end
    end
  end
end