From 39bddd386c65d1c594ed231bff75c0b79fd6cd3f Mon Sep 17 00:00:00 2001 From: Michael Kozono Date: Tue, 8 May 2018 11:56:35 -0700 Subject: Succeed or fail fast based on job status first Also, move wait block into the correct page block. --- qa/qa/page/project/job/show.rb | 22 ++++++++++++++++------ .../features/project/deploy_key_clone_spec.rb | 12 ++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) (limited to 'qa') diff --git a/qa/qa/page/project/job/show.rb b/qa/qa/page/project/job/show.rb index 21bda74efb2..83bb224b5c3 100644 --- a/qa/qa/page/project/job/show.rb +++ b/qa/qa/page/project/job/show.rb @@ -1,18 +1,28 @@ module QA::Page module Project::Job class Show < QA::Page::Base + COMPLETED_STATUSES = %w[passed failed canceled blocked skipped manual].freeze # excludes created, pending, running + PASSED_STATUS = 'passed'.freeze + view 'app/views/projects/jobs/show.html.haml' do element :build_output, '.js-build-output' end - def output - css = '.js-build-output' + view 'app/assets/javascripts/vue_shared/components/ci_badge_link.vue' do + element :status_badge, 'ci-status' + end - wait(reload: false) do - has_css?(css) - end + def completed? + COMPLETED_STATUSES.include? find('.ci-status').text + end - find(css).text + def passed? + find('.ci-status').text == PASSED_STATUS + end + + # Reminder: You may wish to wait for a particular job status before checking output + def output + find('.js-build-output').text end end end diff --git a/qa/qa/specs/features/project/deploy_key_clone_spec.rb b/qa/qa/specs/features/project/deploy_key_clone_spec.rb index 98ea86bf75e..bf8fa230244 100644 --- a/qa/qa/specs/features/project/deploy_key_clone_spec.rb +++ b/qa/qa/specs/features/project/deploy_key_clone_spec.rb @@ -87,16 +87,12 @@ module QA Page::Project::Show.act { wait_for_push } Page::Menu::Side.act { click_ci_cd_pipelines } Page::Project::Pipeline::Index.act { go_to_latest_pipeline } - - Page::Project::Pipeline::Show.act do - go_to_first_job - - wait do - !has_content?('running') - end - end + Page::Project::Pipeline::Show.act { go_to_first_job } Page::Project::Job::Show.perform do |job| + job.wait(reload: false) { job.completed? } + + expect(job.passed?).to be_truthy, "Job status did not become \"passed\"." expect(job.output).to include(sha1sum) end end -- cgit v1.2.1