diff options
Diffstat (limited to 'spec/features/projects/pipelines/pipelines_spec.rb')
-rw-r--r-- | spec/features/projects/pipelines/pipelines_spec.rb | 156 |
1 files changed, 117 insertions, 39 deletions
diff --git a/spec/features/projects/pipelines/pipelines_spec.rb b/spec/features/projects/pipelines/pipelines_spec.rb index 22bf1bfbdf0..d776fbc2b12 100644 --- a/spec/features/projects/pipelines/pipelines_spec.rb +++ b/spec/features/projects/pipelines/pipelines_spec.rb @@ -1,15 +1,13 @@ require 'spec_helper' describe 'Pipelines', :feature, :js do - include WaitForVueResource - let(:project) { create(:empty_project) } context 'when user is logged in' do let(:user) { create(:user) } before do - login_as(user) + sign_in(user) project.team << [user, :developer] end @@ -22,7 +20,7 @@ describe 'Pipelines', :feature, :js do project: project, ref: 'master', status: 'running', - sha: project.commit.id, + sha: project.commit.id ) end @@ -53,8 +51,8 @@ describe 'Pipelines', :feature, :js do context 'header tabs' do before do - visit namespace_project_pipelines_path(project.namespace, project) - wait_for_vue_resource + visit project_pipelines_path(project) + wait_for_requests end it 'shows a tab for All pipelines and count' do @@ -99,15 +97,18 @@ describe 'Pipelines', :feature, :js do end it 'indicates that pipeline can be canceled' do - expect(page).to have_link('Cancel') + expect(page).to have_selector('.js-pipelines-cancel-button') expect(page).to have_selector('.ci-running') end context 'when canceling' do - before { click_link('Cancel') } + before do + find('.js-pipelines-cancel-button').click + wait_for_requests + end it 'indicated that pipelines was canceled' do - expect(page).not_to have_link('Cancel') + expect(page).not_to have_selector('.js-pipelines-cancel-button') expect(page).to have_selector('.ci-canceled') end end @@ -126,15 +127,18 @@ describe 'Pipelines', :feature, :js do end it 'indicates that pipeline can be retried' do - expect(page).to have_link('Retry') + expect(page).to have_selector('.js-pipelines-retry-button') expect(page).to have_selector('.ci-failed') end context 'when retrying' do - before { click_link('Retry') } + before do + find('.js-pipelines-retry-button').click + wait_for_requests + end it 'shows running pipeline that is not retryable' do - expect(page).not_to have_link('Retry') + expect(page).not_to have_selector('.js-pipelines-retry-button') expect(page).to have_selector('.ci-running') end end @@ -145,7 +149,9 @@ describe 'Pipelines', :feature, :js do create(:ci_pipeline, :invalid, project: project) end - before { visit_project_pipelines } + before do + visit_project_pipelines + end it 'contains badge that indicates errors' do expect(page).to have_content 'yaml invalid' @@ -167,26 +173,28 @@ describe 'Pipelines', :feature, :js do commands: 'test') end - before { visit_project_pipelines } + before do + visit_project_pipelines + end it 'has a dropdown with play button' do - expect(page).to have_selector('.dropdown-toggle.btn.btn-default .icon-play') + expect(page).to have_selector('.dropdown-new.btn.btn-default .icon-play') end it 'has link to the manual action' do find('.js-pipeline-dropdown-manual-actions').click - expect(page).to have_link('manual build') + expect(page).to have_button('manual build') end context 'when manual action was played' do before do find('.js-pipeline-dropdown-manual-actions').click - click_link('manual build') + click_button('manual build') end it 'enqueues manual action job' do - expect(manual.reload).to be_pending + expect(page).to have_selector('.js-pipeline-dropdown-manual-actions:disabled') end end end @@ -200,10 +208,12 @@ describe 'Pipelines', :feature, :js do stage: 'test') end - before { visit_project_pipelines } + before do + visit_project_pipelines + end it 'is cancelable' do - expect(page).to have_link('Cancel') + expect(page).to have_selector('.js-pipelines-cancel-button') end it 'has pipeline running' do @@ -211,10 +221,12 @@ describe 'Pipelines', :feature, :js do end context 'when canceling' do - before { click_link('Cancel') } + before do + find('.js-pipelines-cancel-button').trigger('click') + end it 'indicates that pipeline was canceled' do - expect(page).not_to have_link('Cancel') + expect(page).not_to have_selector('.js-pipelines-cancel-button') expect(page).to have_selector('.ci-canceled') end end @@ -233,7 +245,7 @@ describe 'Pipelines', :feature, :js do end it 'is not retryable' do - expect(page).not_to have_link('Retry') + expect(page).not_to have_selector('.js-pipelines-retry-button') end it 'has failed pipeline' do @@ -251,7 +263,9 @@ describe 'Pipelines', :feature, :js do stage: 'test') end - before { visit_project_pipelines } + before do + visit_project_pipelines + end it 'has artifats' do expect(page).to have_selector('.build-artifacts') @@ -280,7 +294,9 @@ describe 'Pipelines', :feature, :js do stage: 'test') end - before { visit_project_pipelines } + before do + visit_project_pipelines + end it { expect(page).not_to have_selector('.build-artifacts') } end @@ -293,7 +309,9 @@ describe 'Pipelines', :feature, :js do stage: 'test') end - before { visit_project_pipelines } + before do + visit_project_pipelines + end it { expect(page).not_to have_selector('.build-artifacts') } end @@ -306,7 +324,9 @@ describe 'Pipelines', :feature, :js do name: 'build') end - before { visit_project_pipelines } + before do + visit_project_pipelines + end it 'should render a mini pipeline graph' do expect(page).to have_selector('.js-mini-pipeline-graph') @@ -349,26 +369,78 @@ describe 'Pipelines', :feature, :js do end it 'should render pagination' do - visit namespace_project_pipelines_path(project.namespace, project) - wait_for_vue_resource + visit project_pipelines_path(project) + wait_for_requests expect(page).to have_selector('.gl-pagination') end it 'should render second page of pipelines' do - visit namespace_project_pipelines_path(project.namespace, project, page: '2') - wait_for_vue_resource + visit project_pipelines_path(project, page: '2') + wait_for_requests expect(page).to have_selector('.gl-pagination .page', count: 2) end end end + describe 'GET /:project/pipelines/show' do + let(:project) { create(:project) } + + let(:pipeline) do + create(:ci_empty_pipeline, + project: project, + sha: project.commit.id, + user: user) + end + + before do + create_build('build', 0, 'build', :success) + create_build('test', 1, 'rspec 0:2', :pending) + create_build('test', 1, 'rspec 1:2', :running) + create_build('test', 1, 'spinach 0:2', :created) + create_build('test', 1, 'spinach 1:2', :created) + create_build('test', 1, 'audit', :created) + create_build('deploy', 2, 'production', :created) + + create(:generic_commit_status, pipeline: pipeline, stage: 'external', name: 'jenkins', stage_idx: 3) + + visit project_pipeline_path(project, pipeline) + wait_for_requests + end + + it 'shows a graph with grouped stages' do + expect(page).to have_css('.js-pipeline-graph') + + # header + expect(page).to have_text("##{pipeline.id}") + expect(page).to have_selector(%Q(img[alt$="#{pipeline.user.name}'s avatar"])) + expect(page).to have_link(pipeline.user.name, href: user_path(pipeline.user)) + + # stages + expect(page).to have_text('Build') + expect(page).to have_text('Test') + expect(page).to have_text('Deploy') + expect(page).to have_text('External') + + # builds + expect(page).to have_text('rspec') + expect(page).to have_text('spinach') + expect(page).to have_text('rspec') + expect(page).to have_text('production') + expect(page).to have_text('jenkins') + end + + def create_build(stage, stage_idx, name, status) + create(:ci_build, pipeline: pipeline, stage: stage, stage_idx: stage_idx, name: name, status: status) + end + end + describe 'POST /:project/pipelines' do let(:project) { create(:project) } before do - visit new_namespace_project_pipeline_path(project.namespace, project) + visit new_project_pipeline_path(project) end context 'for valid commit', js: true do @@ -381,16 +453,22 @@ describe 'Pipelines', :feature, :js do end context 'with gitlab-ci.yml' do - before { stub_ci_pipeline_to_return_yaml_file } + before do + stub_ci_pipeline_to_return_yaml_file + end it 'creates a new pipeline' do expect { click_on 'Create pipeline' } .to change { Ci::Pipeline.count }.by(1) + + expect(Ci::Pipeline.last).to be_web end end context 'without gitlab-ci.yml' do - before { click_on 'Create pipeline' } + before do + click_on 'Create pipeline' + end it { expect(page).to have_content('Missing .gitlab-ci.yml file') } end @@ -401,7 +479,7 @@ describe 'Pipelines', :feature, :js do let(:project) { create(:project) } before do - visit new_namespace_project_pipeline_path(project.namespace, project) + visit new_project_pipeline_path(project) end describe 'new pipeline page' do @@ -430,13 +508,13 @@ describe 'Pipelines', :feature, :js do context 'when user is not logged in' do before do - visit namespace_project_pipelines_path(project.namespace, project) + visit project_pipelines_path(project) end context 'when project is public' do let(:project) { create(:project, :public) } - it { expect(page).to have_content 'No pipelines to show' } + it { expect(page).to have_content 'Build with confidence' } it { expect(page).to have_http_status(:success) } end @@ -448,7 +526,7 @@ describe 'Pipelines', :feature, :js do end def visit_project_pipelines(**query) - visit namespace_project_pipelines_path(project.namespace, project, query) - wait_for_vue_resource + visit project_pipelines_path(project, query) + wait_for_requests end end |