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

module QA
  module Page
    module Project
      module Pipeline
        class Index < QA::Page::Base
          view 'app/assets/javascripts/pipelines/components/pipelines_list/pipeline_url.vue' do
            element :pipeline_url_link
          end

          view 'app/assets/javascripts/pipelines/components/pipelines_list/pipelines_table_row.vue' do
            element :pipeline_commit_status
            element :pipeline_retry_button
          end

          view 'app/assets/javascripts/pipelines/components/pipelines_list/nav_controls.vue' do
            element :run_pipeline_button
          end

          def click_on_latest_pipeline
            all_elements(:pipeline_url_link, minimum: 1, wait: QA::Support::Repeater::DEFAULT_MAX_WAIT_TIME).first.click
          end

          def wait_for_latest_pipeline_succeeded
            wait_for_latest_pipeline_status { has_text?('passed') }
          end

          def wait_for_latest_pipeline_completed
            wait_for_latest_pipeline_status { has_text?('passed') || has_text?('failed') }
          end

          def wait_for_latest_pipeline_status
            wait_until(max_duration: 30, reload: true, sleep_interval: 5) { has_pipeline? }

            wait_until(reload: false, max_duration: 360) do
              within_element_by_index(:pipeline_commit_status, 0) { yield }
            end
          end

          def wait_for_latest_pipeline_success_or_retry
            wait_for_latest_pipeline_completion

            if has_text?('failed')
              click_element :pipeline_retry_button
              wait_for_latest_pipeline_success
            end
          end

          def has_pipeline?
            has_element? :pipeline_url_link
          end

          def has_no_pipeline?
            has_no_element? :pipeline_url_link
          end

          def click_run_pipeline_button
            click_element :run_pipeline_button, Page::Project::Pipeline::New
          end
        end
      end
    end
  end
end

QA::Page::Project::Pipeline::Index.prepend_if_ee('QA::EE::Page::Project::Pipeline::Index')