Commit dfa83dcc authored by Tiffany Rea's avatar Tiffany Rea Committed by Mark Lapierre

Refactor pipeline index page

parent 67b5ee8e
......@@ -127,6 +127,10 @@ export default {
eventHub.$emit('refreshPipelinesTable');
},
},
TBODY_TR_ATTR: {
'data-testid': 'pipeline-table-row',
'data-qa-selector': 'pipeline_row_container',
},
};
</script>
<template>
......@@ -135,7 +139,7 @@ export default {
:fields="$options.tableFields"
:items="pipelines"
tbody-tr-class="commit"
:tbody-tr-attr="{ 'data-testid': 'pipeline-table-row' }"
:tbody-tr-attr="$options.TBODY_TR_ATTR"
stacked="lg"
fixed
>
......
# frozen_string_literal: true
module QA
module EE
module Page
module Project
module Pipeline
module Index
extend QA::Page::PageConcern
def wait_for_latest_pipeline_replicated
QA::Runtime::Logger.debug(%Q[#{self.class.name} - wait_for_latest_pipeline_replication])
wait_until(max_duration: Runtime::Geo.max_file_replication_time) do
within_element_by_index(:pipeline_commit_status, 0) { has_text?('passed') || has_text?('failed') }
end
end
end
end
end
end
end
end
......@@ -5,17 +5,24 @@ module QA
module Pipeline
module_function
# In some cases we don't need to wait for anything, blocked, running or pending is acceptable
# Some cases only we do need pipeline to finish with expected condition (completed, succeeded or replicated)
def visit_latest_pipeline(pipeline_condition: nil)
# Acceptable statuses:
# canceled, created, failed, manual, passed
# pending, running, skipped
def visit_latest_pipeline(status: nil, wait: nil, skip_wait: true)
Page::Project::Menu.perform(&:click_ci_cd_pipelines)
Page::Project::Pipeline::Index.perform(&:"wait_for_latest_pipeline_#{pipeline_condition}") if pipeline_condition
Page::Project::Pipeline::Index.perform(&:click_on_latest_pipeline)
Page::Project::Pipeline::Index.perform do |index|
index.has_any_pipeline?(wait: wait)
index.wait_for_latest_pipeline(status: status, wait: wait) if status || !skip_wait
index.click_on_latest_pipeline
end
end
def wait_for_latest_pipeline(pipeline_condition:)
def wait_for_latest_pipeline(status: nil, wait: nil)
Page::Project::Menu.perform(&:click_ci_cd_pipelines)
Page::Project::Pipeline::Index.perform(&:"wait_for_latest_pipeline_#{pipeline_condition}")
Page::Project::Pipeline::Index.perform do |index|
index.has_any_pipeline?(wait: wait)
index.wait_for_latest_pipeline(status: status, wait: wait)
end
end
end
end
......
......@@ -21,54 +21,46 @@ module QA
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_selector?(".ci-status-icon-success") }
view 'app/assets/javascripts/pipelines/components/pipelines_list/pipelines_table.vue' do
element :pipeline_row_container
end
def wait_for_latest_pipeline_completed
wait_for_latest_pipeline_status { has_selector?(".ci-status-icon-success") || has_selector?(".ci-status-icon-failed") }
def latest_pipeline
all_elements(:pipeline_row_container, minimum: 1).first
end
def wait_for_latest_pipeline_skipped
wait_for_latest_pipeline_status { has_text?('skipped') }
def latest_pipeline_status
latest_pipeline.find(element_selector_css(:pipeline_commit_status)).text
end
def wait_for_latest_pipeline_status
wait_until(max_duration: 90, reload: true, sleep_interval: 5) { has_pipeline? }
# If no status provided, wait for pipeline to complete
def wait_for_latest_pipeline(status: nil, wait: nil, reload: false)
wait ||= Support::Repeater::DEFAULT_MAX_WAIT_TIME
finished_status = %w[passed failed canceled skipped manual]
wait_until(reload: false, max_duration: 360) do
within_element_by_index(:pipeline_commit_status, 0) { yield }
wait_until(max_duration: wait, reload: reload, sleep_interval: 1) do
status ? latest_pipeline_status == status : finished_status.include?(latest_pipeline_status)
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
def has_any_pipeline?(wait: nil)
wait ||= Support::Repeater::DEFAULT_MAX_WAIT_TIME
wait_until(max_duration: wait) { has_element?(:pipeline_row_container) }
end
def has_no_pipeline?
has_no_element? :pipeline_url_link
has_no_element?(:pipeline_row_container)
end
def click_run_pipeline_button
click_element :run_pipeline_button, Page::Project::Pipeline::New
click_element(:run_pipeline_button, Page::Project::Pipeline::New)
end
def click_on_latest_pipeline
latest_pipeline.find(element_selector_css(:pipeline_url_link)).click
end
end
end
end
end
end
QA::Page::Project::Pipeline::Index.prepend_mod_with('Page::Project::Pipeline::Index', namespace: QA)
......@@ -135,7 +135,7 @@ module QA
def go_to_pipeline_job(user)
Flow::Login.sign_in(as: user)
project.visit!
Flow::Pipeline.visit_latest_pipeline(pipeline_condition: 'completed')
Flow::Pipeline.visit_latest_pipeline
Page::Project::Pipeline::Show.perform do |pipeline|
pipeline.click_job('job')
......
......@@ -32,7 +32,7 @@ module QA
add_included_files
add_main_ci_file
project.visit!
Flow::Pipeline.visit_latest_pipeline(pipeline_condition: 'succeeded')
Flow::Pipeline.visit_latest_pipeline(status: 'passed')
end
after do
......
......@@ -56,7 +56,7 @@ module QA
)
end.project.visit!
Flow::Pipeline.visit_latest_pipeline(pipeline_condition: 'completed')
Flow::Pipeline.visit_latest_pipeline
Page::Project::Pipeline::Show.perform do |pipeline|
pipeline.click_job('test-artifacts')
......
......@@ -34,7 +34,7 @@ module QA
add_ci_file(downstream_project, downstream_ci_file)
add_ci_file(upstream_project, upstream_ci_file)
upstream_project.visit!
Flow::Pipeline.visit_latest_pipeline(pipeline_condition: 'succeeded')
Flow::Pipeline.visit_latest_pipeline(status: 'passed')
end
after do
......
......@@ -42,7 +42,7 @@ module QA
it 'can trigger pipeline', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348011' do
Page::Project::Pipeline::Index.perform do |index|
expect(index).not_to have_pipeline # should not auto trigger pipeline
expect(index).to have_no_pipeline # should not auto trigger pipeline
index.click_run_pipeline_button
end
......
......@@ -65,7 +65,7 @@ module QA
before do
Flow::Login.sign_in
project.visit!
Flow::Pipeline.visit_latest_pipeline(pipeline_condition: 'skipped')
Flow::Pipeline.visit_latest_pipeline(status: 'skipped')
end
after do
......
......@@ -23,7 +23,7 @@ module QA
Flow::Login.sign_in
add_ci_files
project.visit!
Flow::Pipeline.visit_latest_pipeline(pipeline_condition: 'succeeded')
Flow::Pipeline.visit_latest_pipeline(status: 'passed')
end
after do
......
......@@ -23,7 +23,7 @@ module QA
Flow::Login.sign_in
add_ci_files
project.visit!
Flow::Pipeline.visit_latest_pipeline(pipeline_condition: 'succeeded')
Flow::Pipeline.visit_latest_pipeline(status: 'passed')
end
after do
......
......@@ -35,7 +35,7 @@ module QA
Flow::Login.sign_in
upstream_project.visit!
Flow::Pipeline.visit_latest_pipeline(pipeline_condition: 'succeeded')
Flow::Pipeline.visit_latest_pipeline(status: 'passed')
end
after do
......
......@@ -27,21 +27,21 @@ module QA
it 'parent pipelines passes if child passes', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348092' do
add_ci_files(success_child_ci_file)
Flow::Pipeline.visit_latest_pipeline(pipeline_condition: 'completed')
Flow::Pipeline.visit_latest_pipeline
Page::Project::Pipeline::Show.perform do |parent_pipeline|
expect(parent_pipeline).to have_child_pipeline
expect(parent_pipeline).to have_passed
expect { parent_pipeline.has_passed? }.to eventually_be_truthy
end
end
it 'parent pipeline fails if child fails', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348091' do
add_ci_files(fail_child_ci_file)
Flow::Pipeline.visit_latest_pipeline(pipeline_condition: 'completed')
Flow::Pipeline.visit_latest_pipeline
Page::Project::Pipeline::Show.perform do |parent_pipeline|
expect(parent_pipeline).to have_child_pipeline
expect(parent_pipeline).to have_failed
expect { parent_pipeline.has_failed? }.to eventually_be_truthy
end
end
......
......@@ -27,21 +27,21 @@ module QA
it 'parent pipelines passes if child passes', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348093' do
add_ci_files(success_child_ci_file)
Flow::Pipeline.visit_latest_pipeline(pipeline_condition: 'completed')
Flow::Pipeline.visit_latest_pipeline
Page::Project::Pipeline::Show.perform do |parent_pipeline|
expect(parent_pipeline).to have_child_pipeline
expect(parent_pipeline).to have_passed
expect { parent_pipeline.has_passed? }.to eventually_be_truthy
end
end
it 'parent pipeline passes even if child fails', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348094' do
add_ci_files(fail_child_ci_file)
Flow::Pipeline.visit_latest_pipeline(pipeline_condition: 'completed')
Flow::Pipeline.visit_latest_pipeline
Page::Project::Pipeline::Show.perform do |parent_pipeline|
expect(parent_pipeline).to have_child_pipeline
expect(parent_pipeline).to have_passed
expect { parent_pipeline.has_passed? }.to eventually_be_truthy
end
end
......
......@@ -91,11 +91,7 @@ module QA
end
Page::Project::Menu.perform(&:click_ci_cd_pipelines)
Page::Project::Pipeline::Index.perform do |index|
index.wait_for_latest_pipeline_completed
end
Page::Project::Pipeline::Index.perform(&:wait_for_latest_pipeline)
cluster.add_sample_policy(project, policy_name: policy_name)
Page::Project::Menu.perform(&:click_on_policies)
......
......@@ -65,7 +65,7 @@ module QA
dashboard.go_to_project(@project.name)
end
Flow::Pipeline.visit_latest_pipeline(pipeline_condition: 'replicated')
Flow::Pipeline.visit_latest_pipeline(wait: Runtime::Geo.max_file_replication_time)
Page::Project::Pipeline::Show.perform do |pipeline|
pipeline.wait_for_pipeline_job_replication(@pipeline_job_name)
......@@ -96,7 +96,7 @@ module QA
dashboard.go_to_project(@project.name)
end
Flow::Pipeline.visit_latest_pipeline(pipeline_condition: 'replicated')
Flow::Pipeline.visit_latest_pipeline(wait: Runtime::Geo.max_file_replication_time)
Page::Project::Pipeline::Show.perform do |pipeline|
pipeline.wait_for_pipeline_job_replication(@pipeline_job_name)
......
......@@ -51,7 +51,7 @@ module QA
end
@project.visit!
Flow::Pipeline.wait_for_latest_pipeline(pipeline_condition: 'succeeded')
Flow::Pipeline.wait_for_latest_pipeline(status: 'passed')
merge_request.visit!
end
......
......@@ -55,7 +55,7 @@ module QA
Flow::Login.sign_in_unless_signed_in
@project.visit!
Flow::Pipeline.wait_for_latest_pipeline(pipeline_condition: 'succeeded')
Flow::Pipeline.wait_for_latest_pipeline(status: 'passed')
@project.visit!
Page::Project::Menu.perform(&:click_on_license_compliance)
EE::Page::Project::Secure::LicenseCompliance.perform do |license_compliance|
......
......@@ -38,7 +38,7 @@ module QA
end
@project.visit!
Flow::Pipeline.wait_for_latest_pipeline(pipeline_condition: 'succeeded')
Flow::Pipeline.wait_for_latest_pipeline(status: 'passed')
@merge_request = Resource::MergeRequest.fabricate_via_api! do |mr|
mr.project = @project
......@@ -96,7 +96,7 @@ module QA
end
@project.visit!
Flow::Pipeline.wait_for_latest_pipeline(pipeline_condition: 'succeeded')
Flow::Pipeline.wait_for_latest_pipeline(status: 'passed')
end
it 'manage licenses from the merge request', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348039' do
......
......@@ -50,7 +50,7 @@ module QA
merge_request.has_pipeline_status?('passed')
merge_request.merge!
end
Flow::Pipeline.wait_for_latest_pipeline(pipeline_condition: 'succeeded')
Flow::Pipeline.wait_for_latest_pipeline(status: 'passed')
@label = Resource::ProjectLabel.fabricate_via_api! do |new_label|
new_label.project = @project
......
......@@ -52,7 +52,7 @@ module QA
project_push.commit_message = 'Create Secure compatible application to serve premade reports'
end.project.visit!
Flow::Pipeline.wait_for_latest_pipeline(pipeline_condition: 'succeeded')
Flow::Pipeline.wait_for_latest_pipeline(status: 'passed')
end
after(:context) do
......
......@@ -50,7 +50,7 @@ module QA
end
@project.visit!
Flow::Pipeline.wait_for_latest_pipeline(pipeline_condition: 'succeeded')
Flow::Pipeline.wait_for_latest_pipeline(status: 'passed')
end
before do
......
......@@ -68,7 +68,7 @@ module QA
edit_github_file
imported_project.trigger_project_mirror
index.wait_until(reload: false) { index.has_pipeline? }
index.has_any_pipeline?
expect(index).to have_content(commit_message), 'Expect new pipeline to have latest commit message from Github'
end
......
......@@ -81,7 +81,7 @@ module QA
# expect new downstream pipeline to also succeed
Page::Project::Pipeline::Index.perform do |index|
expect(index.wait_for_latest_pipeline_succeeded).to be_truthy, 'Downstream pipeline did not succeed as expected.'
expect(index.wait_for_latest_pipeline(status: 'passed')).to be_truthy, 'Downstream pipeline did not succeed as expected.'
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment