Commit 4110e5bd authored by Dan Davison's avatar Dan Davison

Refactor CiBadgeLink and project show page

Define methods for each status
Spec should wait for each pipeline
parent 8bb85704
...@@ -5,7 +5,22 @@ module QA ...@@ -5,7 +5,22 @@ module QA
module Component module Component
module CiBadgeLink module CiBadgeLink
COMPLETED_STATUSES = %w[passed failed canceled blocked skipped manual].freeze # excludes created, pending, running COMPLETED_STATUSES = %w[passed failed canceled blocked skipped manual].freeze # excludes created, pending, running
PASSED_STATUS = 'passed'.freeze INCOMPLETE_STATUSES = %w[pending created running].freeze
# e.g. def passed?(timeout: nil); status_badge == 'passed'; end
COMPLETED_STATUSES.map do |status|
define_method "#{status}?" do |timeout: nil|
timeout ? completed?(timeout: timeout) : completed?
status_badge == status
end
end
# e.g. def pending?; status_badge == 'pending'; end
INCOMPLETE_STATUSES.map do |status|
define_method "#{status}?" do
status_badge == status
end
end
def self.included(base) def self.included(base)
base.view 'app/assets/javascripts/vue_shared/components/ci_badge_link.vue' do base.view 'app/assets/javascripts/vue_shared/components/ci_badge_link.vue' do
...@@ -17,12 +32,6 @@ module QA ...@@ -17,12 +32,6 @@ module QA
find_element(:status_badge).text find_element(:status_badge).text
end end
def successful?(timeout: 60)
raise "Timed out waiting for the status to be a valid completed state" unless completed?(timeout: timeout)
status_badge == PASSED_STATUS
end
private private
def completed?(timeout: 60) def completed?(timeout: 60)
......
...@@ -21,7 +21,7 @@ module QA::Page ...@@ -21,7 +21,7 @@ module QA::Page
raise "Timed out waiting for the build trace to load" unless loaded? raise "Timed out waiting for the build trace to load" unless loaded?
raise "Timed out waiting for the status to be a valid completed state" unless completed?(timeout: timeout) raise "Timed out waiting for the status to be a valid completed state" unless completed?(timeout: timeout)
status_badge == PASSED_STATUS passed?
end end
# Reminder: You may wish to wait for a particular job status before checking output # Reminder: You may wish to wait for a particular job status before checking output
......
...@@ -68,12 +68,20 @@ module QA ...@@ -68,12 +68,20 @@ module QA
Page::Project::Menu.perform(&:click_ci_cd_pipelines) Page::Project::Menu.perform(&:click_ci_cd_pipelines)
Page::Project::Pipeline::Index.perform(&:click_on_latest_pipeline) Page::Project::Pipeline::Index.perform(&:click_on_latest_pipeline)
Page::Project::Pipeline::Show.perform do |pipeline| {
expect(pipeline).to be_running(wait: max_wait) 'test-success': :passed,
expect(pipeline).to have_build('test-success', status: :success, wait: max_wait) 'test-failure': :failed,
expect(pipeline).to have_build('test-failure', status: :failed, wait: max_wait) 'test-tags': :pending,
expect(pipeline).to have_build('test-tags', status: :pending, wait: max_wait) 'test-artifacts': :passed
expect(pipeline).to have_build('test-artifacts', status: :success, wait: max_wait) }.each do |job, status|
Page::Project::Pipeline::Show.perform do |pipeline|
pipeline.click_job(job)
end
Page::Project::Job::Show.perform do |show|
expect(show).to public_send("be_#{status}")
show.click_element(:pipeline_path, Page::Project::Pipeline::Show)
end
end end
end end
end end
......
...@@ -85,7 +85,7 @@ module QA ...@@ -85,7 +85,7 @@ module QA
end end
Page::Project::Pipeline::Show.perform do |show| Page::Project::Pipeline::Show.perform do |show|
expect(show).to be_successful expect(show).to be_passed
expect(show).to have_no_job("downstream_job") expect(show).to have_no_job("downstream_job")
show.click_linked_job(downstream_project_name) show.click_linked_job(downstream_project_name)
......
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