From cb9cee545a5952ed35ccd95e8cd4abe228f09a7b Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Fri, 25 Nov 2016 12:13:12 +0000 Subject: Adds .matches polyfill Moves matches poly to the correct file Divides pipelines index and show tests in order to be able to test with JS --- spec/features/projects/pipelines/pipeline_spec.rb | 170 ++++++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 spec/features/projects/pipelines/pipeline_spec.rb (limited to 'spec/features/projects/pipelines/pipeline_spec.rb') diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb new file mode 100644 index 00000000000..201caf3bbd3 --- /dev/null +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -0,0 +1,170 @@ +require 'spec_helper' + +describe "Pipelines", feature: true, js: true do + include GitlabRoutingHelper + + let(:project) { create(:empty_project) } + let(:user) { create(:user) } + + before do + login_as(user) + project.team << [user, :developer] + end + + describe 'GET /:project/pipelines/:id' do + let(:project) { create(:project) } + let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id) } + + before do + @success = create(:ci_build, :success, pipeline: pipeline, stage: 'build', name: 'build') + @failed = create(:ci_build, :failed, pipeline: pipeline, stage: 'test', name: 'test', commands: 'test') + @running = create(:ci_build, :running, pipeline: pipeline, stage: 'deploy', name: 'deploy') + @manual = create(:ci_build, :manual, pipeline: pipeline, stage: 'deploy', name: 'manual build') + @external = create(:generic_commit_status, status: 'success', pipeline: pipeline, name: 'jenkins', stage: 'external') + end + + before { visit namespace_project_pipeline_path(project.namespace, project, pipeline) } + + it 'shows a list of builds' do + expect(page).to have_content('Test') + expect(page).to have_content(@success.id) + expect(page).to have_content('Deploy') + expect(page).to have_content(@failed.id) + expect(page).to have_content(@running.id) + expect(page).to have_content(@external.id) + expect(page).to have_content('Retry failed') + expect(page).to have_content('Cancel running') + expect(page).to have_link('Play') + end + + it 'shows Pipeline tab pane as active' do + expect(page).to have_css('#js-tab-pipeline.active') + end + + context 'page tabs' do + it 'shows Pipeline and Builds tabs with link' do + expect(page).to have_link('Pipeline') + expect(page).to have_link('Builds') + end + + it 'shows counter in Builds tab' do + expect(page.find('.js-builds-counter').text).to eq(pipeline.statuses.count.to_s) + end + + it 'shows Pipeline tab as active' do + expect(page).to have_css('.js-pipeline-tab-link.active') + end + end + + context 'retrying builds' do + it { expect(page).not_to have_content('retried') } + + context 'when retrying' do + before { click_on 'Retry failed' } + + it { expect(page).not_to have_content('Retry failed') } + it { expect(page).to have_selector('.retried') } + end + end + + context 'canceling builds' do + it { expect(page).not_to have_selector('.ci-canceled') } + + context 'when canceling' do + before { click_on 'Cancel running' } + + it { expect(page).not_to have_content('Cancel running') } + it { expect(page).to have_selector('.ci-canceled') } + end + end + + context 'playing manual build' do + before do + within '.pipeline-holder' do + click_link('Play') + end + end + + it { expect(@manual.reload).to be_pending } + end + end + + describe 'GET /:project/pipelines/:id/builds' do + let(:project) { create(:project) } + let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id) } + + before do + @success = create(:ci_build, :success, pipeline: pipeline, stage: 'build', name: 'build') + @failed = create(:ci_build, :failed, pipeline: pipeline, stage: 'test', name: 'test', commands: 'test') + @running = create(:ci_build, :running, pipeline: pipeline, stage: 'deploy', name: 'deploy') + @manual = create(:ci_build, :manual, pipeline: pipeline, stage: 'deploy', name: 'manual build') + @external = create(:generic_commit_status, status: 'success', pipeline: pipeline, name: 'jenkins', stage: 'external') + end + + before { visit builds_namespace_project_pipeline_path(project.namespace, project, pipeline)} + + it 'shows a list of builds' do + expect(page).to have_content('Test') + expect(page).to have_content(@success.id) + expect(page).to have_content('Deploy') + expect(page).to have_content(@failed.id) + expect(page).to have_content(@running.id) + expect(page).to have_content(@external.id) + expect(page).to have_content('Retry failed') + expect(page).to have_content('Cancel running') + expect(page).to have_link('Play') + end + + it 'shows Builds tab pane as active' do + expect(page).to have_css('#js-tab-builds.active') + end + + context 'page tabs' do + it 'shows Pipeline and Builds tabs with link' do + expect(page).to have_link('Pipeline') + expect(page).to have_link('Builds') + end + + it 'shows counter in Builds tab' do + expect(page.find('.js-builds-counter').text).to eq(pipeline.statuses.count.to_s) + end + + it 'shows Builds tab as active' do + expect(page).to have_css('li.js-builds-tab-link.active') + end + end + + context 'retrying builds' do + it { expect(page).not_to have_content('retried') } + + context 'when retrying' do + before { click_on 'Retry failed' } + + it { expect(page).not_to have_content('Retry failed') } + it { expect(page).to have_selector('.retried') } + end + end + + context 'canceling builds' do + it { expect(page).not_to have_selector('.ci-canceled') } + + context 'when canceling' do + before { click_on 'Cancel running' } + + it { expect(page).not_to have_content('Cancel running') } + it { expect(page).to have_selector('.ci-canceled') } + end + end + + context 'playing manual build' do + before do + within '.pipeline-holder' do + click_link('Play') + end + end + + it { expect(@manual.reload).to be_pending } + end + end + +end -- cgit v1.2.1 From 6789befbf6b0578718b0e461c60326cd97dc8640 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Fri, 25 Nov 2016 14:21:50 +0000 Subject: Fixes after review Fix pipelines tests Fix rubocop --- spec/features/projects/pipelines/pipeline_spec.rb | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) (limited to 'spec/features/projects/pipelines/pipeline_spec.rb') diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb index 201caf3bbd3..3350a3aeefc 100644 --- a/spec/features/projects/pipelines/pipeline_spec.rb +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -25,16 +25,13 @@ describe "Pipelines", feature: true, js: true do before { visit namespace_project_pipeline_path(project.namespace, project, pipeline) } - it 'shows a list of builds' do + it 'shows the pipeline graph' do + expect(page).to have_selector('.pipeline-visualization') + expect(page).to have_content('Build') expect(page).to have_content('Test') - expect(page).to have_content(@success.id) expect(page).to have_content('Deploy') - expect(page).to have_content(@failed.id) - expect(page).to have_content(@running.id) - expect(page).to have_content(@external.id) expect(page).to have_content('Retry failed') expect(page).to have_content('Cancel running') - expect(page).to have_link('Play') end it 'shows Pipeline tab pane as active' do @@ -63,7 +60,6 @@ describe "Pipelines", feature: true, js: true do before { click_on 'Retry failed' } it { expect(page).not_to have_content('Retry failed') } - it { expect(page).to have_selector('.retried') } end end @@ -74,19 +70,8 @@ describe "Pipelines", feature: true, js: true do before { click_on 'Cancel running' } it { expect(page).not_to have_content('Cancel running') } - it { expect(page).to have_selector('.ci-canceled') } end end - - context 'playing manual build' do - before do - within '.pipeline-holder' do - click_link('Play') - end - end - - it { expect(@manual.reload).to be_pending } - end end describe 'GET /:project/pipelines/:id/builds' do @@ -166,5 +151,4 @@ describe "Pipelines", feature: true, js: true do it { expect(@manual.reload).to be_pending } end end - end -- cgit v1.2.1 From b4f18a30fb776e28fac405922cb5dfcfdc8ac5d7 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Wed, 7 Dec 2016 22:56:47 +0000 Subject: Adds tests for the status and actions icons rendered in the pipeline graph Fix padding in dropdown --- spec/features/projects/pipelines/pipeline_spec.rb | 41 +++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'spec/features/projects/pipelines/pipeline_spec.rb') diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb index 3350a3aeefc..e21de05ac64 100644 --- a/spec/features/projects/pipelines/pipeline_spec.rb +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -38,6 +38,47 @@ describe "Pipelines", feature: true, js: true do expect(page).to have_css('#js-tab-pipeline.active') end + context 'pipeline graph' do + it 'shows a running icon and a cancel action for the running build' do + page.within('.stage-column:first-child .build:first-child') do + expect(page).to have_selector('.ci-status-icon-running') + expect(page).to have_content('deploy') + expect(page).to have_selector('.ci-action-icon-container .fa-ban') + end + end + + it 'shows the success icon and a retry action for the successfull build' do + page.within('.stage-column:nth-child(3)') do + expect(page).to have_selector('.ci-status-icon-success') + expect(page).to have_content('build') + expect(page).to have_selector('.ci-action-icon-container .fa-refresh') + end + end + + it 'shows the failed icon and a retry action for the failed build' do + page.within('.stage-column:nth-child(2) .build') do + expect(page).to have_selector('.ci-status-icon-failed') + expect(page).to have_content('test') + expect(page).to have_selector('.ci-action-icon-container .fa-refresh') + end + end + + it 'shows the skipped icon and a play action for the manual build' do + page.within('.stage-column:first-child .build:nth-child(2)') do + expect(page).to have_selector('.ci-status-icon-skipped') + expect(page).to have_content('manual') + expect(page).to have_selector('.ci-action-icon-container .ci-play-icon') + end + end + + it 'shows the success icon for the generic comit status build' do + page.within('.stage-column:nth-child(4) .build') do + expect(page).to have_selector('.ci-status-icon-success') + expect(page).to have_content('jenkins') + end + end + end + context 'page tabs' do it 'shows Pipeline and Builds tabs with link' do expect(page).to have_link('Pipeline') -- cgit v1.2.1 From 1e8271b60bcd16b6fcc20d574c9583d593084eef Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Fri, 9 Dec 2016 17:24:21 +0000 Subject: Adds new partial for graph icons. Fix tests --- spec/features/projects/pipelines/pipeline_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'spec/features/projects/pipelines/pipeline_spec.rb') diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb index e21de05ac64..7358931b9f0 100644 --- a/spec/features/projects/pipelines/pipeline_spec.rb +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -40,7 +40,7 @@ describe "Pipelines", feature: true, js: true do context 'pipeline graph' do it 'shows a running icon and a cancel action for the running build' do - page.within('.stage-column:first-child .build:first-child') do + page.within('.stage-column:nth-child(2) .build:first-child') do expect(page).to have_selector('.ci-status-icon-running') expect(page).to have_content('deploy') expect(page).to have_selector('.ci-action-icon-container .fa-ban') @@ -56,7 +56,7 @@ describe "Pipelines", feature: true, js: true do end it 'shows the failed icon and a retry action for the failed build' do - page.within('.stage-column:nth-child(2) .build') do + page.within('.stage-column:first-child .build') do expect(page).to have_selector('.ci-status-icon-failed') expect(page).to have_content('test') expect(page).to have_selector('.ci-action-icon-container .fa-refresh') @@ -64,7 +64,7 @@ describe "Pipelines", feature: true, js: true do end it 'shows the skipped icon and a play action for the manual build' do - page.within('.stage-column:first-child .build:nth-child(2)') do + page.within('.stage-column:nth-child(2) .build:nth-child(2)') do expect(page).to have_selector('.ci-status-icon-skipped') expect(page).to have_content('manual') expect(page).to have_selector('.ci-action-icon-container .ci-play-icon') -- cgit v1.2.1 From e138646aad4a836459999a399cdd9eca1e09847d Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Wed, 14 Dec 2016 15:25:38 +0000 Subject: Fix broken tests --- spec/features/projects/pipelines/pipeline_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'spec/features/projects/pipelines/pipeline_spec.rb') diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb index 7358931b9f0..5094fcf33e8 100644 --- a/spec/features/projects/pipelines/pipeline_spec.rb +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -40,7 +40,7 @@ describe "Pipelines", feature: true, js: true do context 'pipeline graph' do it 'shows a running icon and a cancel action for the running build' do - page.within('.stage-column:nth-child(2) .build:first-child') do + page.within('.stage-column:nth-child(3) .build:first-child') do expect(page).to have_selector('.ci-status-icon-running') expect(page).to have_content('deploy') expect(page).to have_selector('.ci-action-icon-container .fa-ban') @@ -48,7 +48,7 @@ describe "Pipelines", feature: true, js: true do end it 'shows the success icon and a retry action for the successfull build' do - page.within('.stage-column:nth-child(3)') do + page.within('.stage-column:nth-child(2) .build:first-child') do expect(page).to have_selector('.ci-status-icon-success') expect(page).to have_content('build') expect(page).to have_selector('.ci-action-icon-container .fa-refresh') @@ -64,7 +64,7 @@ describe "Pipelines", feature: true, js: true do end it 'shows the skipped icon and a play action for the manual build' do - page.within('.stage-column:nth-child(2) .build:nth-child(2)') do + page.within('.stage-column:nth-child(3) .build:nth-child(2)') do expect(page).to have_selector('.ci-status-icon-skipped') expect(page).to have_content('manual') expect(page).to have_selector('.ci-action-icon-container .ci-play-icon') -- cgit v1.2.1 From 03a95c7070938e0fde67f2def334c08cf72d9d29 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Thu, 15 Dec 2016 11:48:05 +0000 Subject: Fix tests --- spec/features/projects/pipelines/pipeline_spec.rb | 39 +++++++++++++++++------ 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'spec/features/projects/pipelines/pipeline_spec.rb') diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb index 5094fcf33e8..80a596d34c9 100644 --- a/spec/features/projects/pipelines/pipeline_spec.rb +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -40,43 +40,62 @@ describe "Pipelines", feature: true, js: true do context 'pipeline graph' do it 'shows a running icon and a cancel action for the running build' do - page.within('.stage-column:nth-child(3) .build:first-child') do + title = "#{@running.name} - #{@running.status}" + + page.within("a[data-title='#{title}']") do expect(page).to have_selector('.ci-status-icon-running') expect(page).to have_content('deploy') + end + + page.within("a[data-title='#{title}'] + .ci-action-icon-container") do expect(page).to have_selector('.ci-action-icon-container .fa-ban') end + end it 'shows the success icon and a retry action for the successfull build' do - page.within('.stage-column:nth-child(2) .build:first-child') do + title = "#{@success.name} - #{@success.status}" + + page.within("a[data-title='#{title}']") do expect(page).to have_selector('.ci-status-icon-success') expect(page).to have_content('build') + end + + page.within("a[data-title='#{title}'] + .ci-action-icon-container") do expect(page).to have_selector('.ci-action-icon-container .fa-refresh') end end it 'shows the failed icon and a retry action for the failed build' do - page.within('.stage-column:first-child .build') do + title = "#{@failed.name} - #{@failed.status}" + + page.within("a[data-title='#{title}']") do expect(page).to have_selector('.ci-status-icon-failed') expect(page).to have_content('test') + end + + page.within("a[data-title='#{title}'] + .ci-action-icon-container") do expect(page).to have_selector('.ci-action-icon-container .fa-refresh') end end it 'shows the skipped icon and a play action for the manual build' do - page.within('.stage-column:nth-child(3) .build:nth-child(2)') do + title = "#{@manual.name} - #{@manual.status}" + + page.within("a[data-title='#{title}']") do expect(page).to have_selector('.ci-status-icon-skipped') expect(page).to have_content('manual') - expect(page).to have_selector('.ci-action-icon-container .ci-play-icon') end - end - it 'shows the success icon for the generic comit status build' do - page.within('.stage-column:nth-child(4) .build') do - expect(page).to have_selector('.ci-status-icon-success') - expect(page).to have_content('jenkins') + page.within("a[data-title='#{title}'] + .ci-action-icon-container") do + expect(page).to have_selector('.ci-action-icon-container .fa-play') end end + + it 'shows the success icon and the generic comit status build' do + expect(page).to have_selector('.ci-status-icon-success') + expect(page).to have_content('jenkins') + end end context 'page tabs' do -- cgit v1.2.1 From e42de89a15c858866d78a4d2a5837a0feec922a5 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Thu, 15 Dec 2016 17:30:49 +0000 Subject: Changes after review Changes after review Fix tooltip title Remove unneeded string interpolation --- spec/features/projects/pipelines/pipeline_spec.rb | 93 ++++++++++++++--------- 1 file changed, 59 insertions(+), 34 deletions(-) (limited to 'spec/features/projects/pipelines/pipeline_spec.rb') diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb index 80a596d34c9..0a77eaa123c 100644 --- a/spec/features/projects/pipelines/pipeline_spec.rb +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -38,63 +38,88 @@ describe "Pipelines", feature: true, js: true do expect(page).to have_css('#js-tab-pipeline.active') end - context 'pipeline graph' do - it 'shows a running icon and a cancel action for the running build' do - title = "#{@running.name} - #{@running.status}" - - page.within("a[data-title='#{title}']") do - expect(page).to have_selector('.ci-status-icon-running') - expect(page).to have_content('deploy') + describe 'pipeline graph' do + context 'when pipeline has running builds' do + it 'shows a running icon and a cancel action for the running build' do + page.within('a[data-title="deploy - running"]') do + expect(page).to have_selector('.ci-status-icon-running') + expect(page).to have_content('deploy') + end + + page.within('a[data-title="deploy - running"] + .ci-action-icon-container') do + expect(page).to have_selector('.ci-action-icon-container .fa-ban') + end end - page.within("a[data-title='#{title}'] + .ci-action-icon-container") do - expect(page).to have_selector('.ci-action-icon-container .fa-ban') - end + it 'should be possible to cancel the running build' do + find('a[data-title="deploy - running"] + .ci-action-icon-container').trigger('click') + expect(page).not_to have_content('Cancel running') + end end - it 'shows the success icon and a retry action for the successfull build' do - title = "#{@success.name} - #{@success.status}" + context 'when pipeline has successful builds' do + it 'shows the success icon and a retry action for the successfull build' do + page.within('a[data-title="build - passed"]') do + expect(page).to have_selector('.ci-status-icon-success') + expect(page).to have_content('build') + end - page.within("a[data-title='#{title}']") do - expect(page).to have_selector('.ci-status-icon-success') - expect(page).to have_content('build') + page.within('a[data-title="build - passed"] + .ci-action-icon-container') do + expect(page).to have_selector('.ci-action-icon-container .fa-refresh') + end end - page.within("a[data-title='#{title}'] + .ci-action-icon-container") do - expect(page).to have_selector('.ci-action-icon-container .fa-refresh') + it 'should be possible to retry the success build' do + find('a[data-title="build - passed"] + .ci-action-icon-container').trigger('click') + + expect(page).not_to have_content('Retry build') end end - it 'shows the failed icon and a retry action for the failed build' do - title = "#{@failed.name} - #{@failed.status}" + context 'when pipeline has failed builds' do + it 'shows the failed icon and a retry action for the failed build' do + page.within('a[data-title="test - failed"]') do + expect(page).to have_selector('.ci-status-icon-failed') + expect(page).to have_content('test') + end - page.within("a[data-title='#{title}']") do - expect(page).to have_selector('.ci-status-icon-failed') - expect(page).to have_content('test') + page.within('a[data-title="test - failed"] + .ci-action-icon-container') do + expect(page).to have_selector('.ci-action-icon-container .fa-refresh') + end end - page.within("a[data-title='#{title}'] + .ci-action-icon-container") do - expect(page).to have_selector('.ci-action-icon-container .fa-refresh') + it 'should be possible to retry the failed build' do + find('a[data-title="test - failed"] + .ci-action-icon-container').trigger('click') + + expect(page).not_to have_content('Retry build') end end - it 'shows the skipped icon and a play action for the manual build' do - title = "#{@manual.name} - #{@manual.status}" + context 'when pipeline has manual builds' do + it 'shows the skipped icon and a play action for the manual build' do + page.within('a[data-title="manual build - manual play action"]') do + expect(page).to have_selector('.ci-status-icon-skipped') + expect(page).to have_content('manual') + end - page.within("a[data-title='#{title}']") do - expect(page).to have_selector('.ci-status-icon-skipped') - expect(page).to have_content('manual') + page.within('a[data-title="manual build - manual play action"] + .ci-action-icon-container') do + expect(page).to have_selector('.ci-action-icon-container .fa-play') + end end - page.within("a[data-title='#{title}'] + .ci-action-icon-container") do - expect(page).to have_selector('.ci-action-icon-container .fa-play') + it 'should be possible to play the manual build' do + find('a[data-title="manual build - manual play action"] + .ci-action-icon-container').trigger('click') + + expect(page).not_to have_content('Play build') end end - it 'shows the success icon and the generic comit status build' do - expect(page).to have_selector('.ci-status-icon-success') - expect(page).to have_content('jenkins') + context 'when pipeline has external build' do + it 'shows the success icon and the generic comit status build' do + expect(page).to have_selector('.ci-status-icon-success') + expect(page).to have_content('jenkins') + end end end -- cgit v1.2.1