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

module QA
  module Page
    module Project
      class New < Page::Base
        include Page::Component::Select2

        view 'app/views/projects/new.html.haml' do
          element :project_create_from_template_tab
          element :import_project_tab, "Import project" # rubocop:disable QA/ElementWithPattern
        end

        view 'app/views/projects/_new_project_fields.html.haml' do
          element :initialize_with_readme_checkbox
          element :project_namespace_select
          element :project_namespace_field, 'namespaces_options' # rubocop:disable QA/ElementWithPattern
          element :project_name, 'text_field :name' # rubocop:disable QA/ElementWithPattern
          element :project_path, 'text_field :path' # rubocop:disable QA/ElementWithPattern
          element :project_description, 'text_area :description' # rubocop:disable QA/ElementWithPattern
          element :project_create_button, "submit _('Create project')" # rubocop:disable QA/ElementWithPattern
          element :visibility_radios, 'visibility_level:' # rubocop:disable QA/ElementWithPattern
        end

        view 'app/views/projects/_import_project_pane.html.haml' do
          element :import_github, "icon('github', text: 'GitHub')" # rubocop:disable QA/ElementWithPattern
        end

        def choose_test_namespace
          choose_namespace(Runtime::Namespace.path)
        end

        def choose_namespace(namespace)
          retry_on_exception do
            click_body
            click_element :project_namespace_select
            search_and_select(namespace)
          end
        end

        def click_import_project
          click_on 'Import project'
        end

        def choose_name(name)
          fill_in 'project_name', with: name
        end

        def add_description(description)
          fill_in 'project_description', with: description
        end

        def create_new_project
          click_on 'Create project'
        end

        def click_create_from_template_tab
          click_element(:project_create_from_template_tab)
        end

        def set_visibility(visibility)
          choose visibility.capitalize
        end

        def click_github_link
          click_link 'GitHub'
        end

        def enable_initialize_with_readme
          check_element :initialize_with_readme_checkbox
        end
      end
    end
  end
end