Commit 374d4f17 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Refactor pipeline_spec

This makes sure we load the page as part of the spec, instead of a
before block. So we could still perform setup inside shared examples,
avoiding failures caught by data being wrongly cached when loading the
page multiple times during a single spec
parent 9763c9cc
...@@ -59,11 +59,11 @@ describe 'Pipeline', :js do ...@@ -59,11 +59,11 @@ describe 'Pipeline', :js do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id, user: user) } let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id, user: user) }
before do subject(:visit_pipeline) { visit project_pipeline_path(project, pipeline) }
visit project_pipeline_path(project, pipeline)
end
it 'shows the pipeline graph' do it 'shows the pipeline graph' do
visit_pipeline
expect(page).to have_selector('.pipeline-visualization') expect(page).to have_selector('.pipeline-visualization')
expect(page).to have_content('Build') expect(page).to have_content('Build')
expect(page).to have_content('Test') expect(page).to have_content('Test')
...@@ -73,14 +73,20 @@ describe 'Pipeline', :js do ...@@ -73,14 +73,20 @@ describe 'Pipeline', :js do
end end
it 'shows Pipeline tab pane as active' do it 'shows Pipeline tab pane as active' do
visit_pipeline
expect(page).to have_css('#js-tab-pipeline.active') expect(page).to have_css('#js-tab-pipeline.active')
end end
it 'shows link to the pipeline ref' do it 'shows link to the pipeline ref' do
visit_pipeline
expect(page).to have_link(pipeline.ref) expect(page).to have_link(pipeline.ref)
end end
it 'shows the pipeline information' do it 'shows the pipeline information' do
visit_pipeline
within '.pipeline-info' do within '.pipeline-info' do
expect(page).to have_content("#{pipeline.statuses.count} jobs " \ expect(page).to have_content("#{pipeline.statuses.count} jobs " \
"for #{pipeline.ref} ") "for #{pipeline.ref} ")
...@@ -96,6 +102,10 @@ describe 'Pipeline', :js do ...@@ -96,6 +102,10 @@ describe 'Pipeline', :js do
end end
describe 'pipeline graph' do describe 'pipeline graph' do
before do
visit_pipeline
end
context 'when pipeline has running builds' do context 'when pipeline has running builds' do
it 'shows a running icon and a cancel action for the running build' do it 'shows a running icon and a cancel action for the running build' do
page.within('#ci-badge-deploy') do page.within('#ci-badge-deploy') do
...@@ -227,6 +237,10 @@ describe 'Pipeline', :js do ...@@ -227,6 +237,10 @@ describe 'Pipeline', :js do
end end
context 'page tabs' do context 'page tabs' do
before do
visit_pipeline
end
it 'shows Pipeline, Jobs and Failed Jobs tabs with link' do it 'shows Pipeline, Jobs and Failed Jobs tabs with link' do
expect(page).to have_link('Pipeline') expect(page).to have_link('Pipeline')
expect(page).to have_link('Jobs') expect(page).to have_link('Jobs')
...@@ -253,6 +267,10 @@ describe 'Pipeline', :js do ...@@ -253,6 +267,10 @@ describe 'Pipeline', :js do
end end
context 'retrying jobs' do context 'retrying jobs' do
before do
visit_pipeline
end
it { expect(page).not_to have_content('retried') } it { expect(page).not_to have_content('retried') }
context 'when retrying' do context 'when retrying' do
...@@ -265,6 +283,10 @@ describe 'Pipeline', :js do ...@@ -265,6 +283,10 @@ describe 'Pipeline', :js do
end end
context 'canceling jobs' do context 'canceling jobs' do
before do
visit_pipeline
end
it { expect(page).not_to have_selector('.ci-canceled') } it { expect(page).not_to have_selector('.ci-canceled') }
context 'when canceling' do context 'when canceling' do
...@@ -284,6 +306,10 @@ describe 'Pipeline', :js do ...@@ -284,6 +306,10 @@ describe 'Pipeline', :js do
user: user) user: user)
end end
before do
visit_pipeline
end
it 'does not render link to the pipeline ref' do it 'does not render link to the pipeline ref' do
expect(page).not_to have_link(pipeline.ref) expect(page).not_to have_link(pipeline.ref)
expect(page).to have_content(pipeline.ref) expect(page).to have_content(pipeline.ref)
...@@ -305,6 +331,10 @@ describe 'Pipeline', :js do ...@@ -305,6 +331,10 @@ describe 'Pipeline', :js do
merge_request.all_pipelines.last merge_request.all_pipelines.last
end end
before do
visit_pipeline
end
it 'shows the pipeline information' do it 'shows the pipeline information' do
within '.pipeline-info' do within '.pipeline-info' do
expect(page).to have_content("#{pipeline.statuses.count} jobs " \ expect(page).to have_content("#{pipeline.statuses.count} jobs " \
...@@ -356,6 +386,8 @@ describe 'Pipeline', :js do ...@@ -356,6 +386,8 @@ describe 'Pipeline', :js do
before do before do
pipeline.update(user: user) pipeline.update(user: user)
visit_pipeline
end end
it 'shows the pipeline information' do it 'shows the pipeline information' do
......
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