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

module QA
  module Page
    module Project
      module Pipeline
        class New < QA::Page::Base
          view 'app/assets/javascripts/pipeline_new/components/pipeline_new_form.vue' do
            element :run_pipeline_button, required: true
            element :ci_variable_row_container
            element :ci_variable_key_field
            element :ci_variable_value_field
            element :ci_variable_value_dropdown
            element :ci_variable_value_dropdown_item
          end

          def click_run_pipeline_button
            click_element(:run_pipeline_button, Page::Project::Pipeline::Show)
          end

          def click_variable_dropdown
            return unless has_variable_dropdown?

            click_element(:ci_variable_value_dropdown)
          end

          def configure_variable(key: nil, value: 'foo', row_index: 0)
            within_element_by_index(:ci_variable_row_container, row_index) do
              fill_element(:ci_variable_key_field, key) unless key.nil?
              fill_element(:ci_variable_value_field, value)
            end
          end

          def has_variable_dropdown?
            has_element?(:ci_variable_value_dropdown)
          end

          def variable_dropdown
            return unless has_variable_dropdown?

            find_element(:ci_variable_value_dropdown)
          end

          def variable_dropdown_item_with_index(index)
            return unless has_variable_dropdown?

            within_element_by_index(:ci_variable_value_dropdown_item, index) do
              find('p')
            end
          end
        end
      end
    end
  end
end