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

module QA
  module Page
    module Project
      class New < Page::Base
        include Page::Component::Project::Templates
        include Page::Component::VisibilitySetting

        include Layout::Flash
        include Page::Component::Import::Selection
        include Page::Component::Import::Gitlab

        view 'app/views/projects/_new_project_fields.html.haml' do
          element :initialize_with_readme_checkbox
          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/_new_project_initialize_with_sast.html.haml' do
          element :initialize_with_sast_checkbox
        end

        view 'app/views/projects/project_templates/_template.html.haml' do
          element :use_template_button
          element :template_option_row
        end

        view 'app/assets/javascripts/projects/new/components/new_project_url_select.vue' do
          element :select_namespace_dropdown
          element :select_namespace_dropdown_search_field
        end

        view 'app/assets/javascripts/vue_shared/new_namespace/components/welcome.vue' do
          element :panel_link
        end

        def click_blank_project_link
          click_element(:panel_link, panel_name: 'blank_project')
        end

        def click_create_from_template_link
          click_element(:panel_link, panel_name: 'create_from_template')
        end

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

        def choose_namespace(namespace)
          retry_on_exception do
            click_element :select_namespace_dropdown
            fill_element :select_namespace_dropdown_search_field, namespace
            click_button 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

        # Disable experiment for SAST at project creation https://gitlab.com/gitlab-org/gitlab/-/issues/333196
        def disable_initialize_with_sast
          return unless has_element?(:initialize_with_sast_checkbox)

          uncheck_element(:initialize_with_sast_checkbox)
        end

        def click_github_link
          click_link 'GitHub'
        end

        def click_repo_by_url_link
          click_button 'Repo by URL'
        end

        def disable_initialize_with_readme
          uncheck_element(:initialize_with_readme_checkbox)
        end
      end
    end
  end
end

QA::Page::Project::New.prepend_mod_with('Page::Project::New', namespace: QA)