Commit 6a7a31b8 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Improve code in pipelines feature specs file

parent 9cfefbad
...@@ -14,10 +14,9 @@ describe 'Pipelines', :feature, :js do ...@@ -14,10 +14,9 @@ describe 'Pipelines', :feature, :js do
project.team << [user, :developer] project.team << [user, :developer]
end end
describe 'GET /:project/pipelines', feature: true, js: true do describe 'GET /:project/pipelines' do
include WaitForVueResource
let(:project) { create(:project) } let(:project) { create(:project) }
let!(:pipeline) do let!(:pipeline) do
create( create(
:ci_empty_pipeline, :ci_empty_pipeline,
...@@ -29,39 +28,38 @@ describe 'Pipelines', :feature, :js do ...@@ -29,39 +28,38 @@ describe 'Pipelines', :feature, :js do
end end
[:all, :running, :branches].each do |scope| [:all, :running, :branches].each do |scope|
context "displaying #{scope}" do context "when displaying #{scope}" do
before do before do
visit namespace_project_pipelines_path( visit_project_pipelines(scope: scope)
project.namespace,
project, scope: scope
)
wait_for_vue_resource
end end
it do it 'contains pipeline commit short SHA' do
expect(page).to have_content(pipeline.short_sha) expect(page).to have_content(pipeline.short_sha)
end end
end end
end end
context 'anonymous access' do context 'anonymous access' do
let(:project) { create(:project, :public) }
before do before do
visit namespace_project_pipelines_path(project.namespace, project) logout
wait_for_vue_resource visit_project_pipelines
end end
it { expect(page).to have_http_status(:success) } it { expect(page).to have_http_status(:success) }
end end
context 'cancelable pipeline' do context 'when pipeline is cancelable' do
let!(:build) do let!(:build) do
create(:ci_build, pipeline: pipeline, stage: 'test', commands: 'test') create(:ci_build, pipeline: pipeline,
stage: 'test',
commands: 'test')
end end
before do before do
build.run build.run
visit namespace_project_pipelines_path(project.namespace, project) visit_project_pipelines
wait_for_vue_resource
end end
it { expect(page).to have_link('Cancel') } it { expect(page).to have_link('Cancel') }
...@@ -69,35 +67,30 @@ describe 'Pipelines', :feature, :js do ...@@ -69,35 +67,30 @@ describe 'Pipelines', :feature, :js do
it { expect(page).to have_selector('.ci-running') } it { expect(page).to have_selector('.ci-running') }
context 'when canceling' do context 'when canceling' do
before do before { click_link('Cancel') }
wait_for_vue_resource
click_link('Cancel')
end
it { expect(page).not_to have_link('Cancel') } it { expect(page).not_to have_link('Cancel') }
it { expect(page).to have_selector('.ci-canceled') } it { expect(page).to have_selector('.ci-canceled') }
end end
end end
context 'retryable pipelines' do context 'when pipeline is retryable' do
let!(:build) do let!(:build) do
create(:ci_build, pipeline: pipeline, stage: 'test', commands: 'test') create(:ci_build, pipeline: pipeline,
stage: 'test',
commands: 'test')
end end
before do before do
build.drop build.drop
visit namespace_project_pipelines_path(project.namespace, project) visit_project_pipelines
end end
it { expect(page).to have_link('Retry') } it { expect(page).to have_link('Retry') }
it { expect(page).to have_selector('.ci-failed') } it { expect(page).to have_selector('.ci-failed') }
context 'when retrying' do context 'when retrying' do
before do before { click_link('Retry') }
wait_for_vue_resource
click_link('Retry')
end
it { expect(page).not_to have_link('Retry') } it { expect(page).not_to have_link('Retry') }
it { expect(page).to have_selector('.ci-running') } it { expect(page).to have_selector('.ci-running') }
...@@ -106,21 +99,14 @@ describe 'Pipelines', :feature, :js do ...@@ -106,21 +99,14 @@ describe 'Pipelines', :feature, :js do
context 'with manual actions' do context 'with manual actions' do
let!(:manual) do let!(:manual) do
create( create(:ci_build, :manual,
:ci_build,
:manual,
pipeline: pipeline, pipeline: pipeline,
name: 'manual build', name: 'manual build',
stage: 'test', stage: 'test',
commands: 'test' commands: 'test')
)
end end
before do before { visit_project_pipelines }
visit namespace_project_pipelines_path(project.namespace, project)
wait_for_vue_resource
end
it 'has a dropdown with play button' do 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-toggle.btn.btn-default .icon-play')
...@@ -147,18 +133,14 @@ describe 'Pipelines', :feature, :js do ...@@ -147,18 +133,14 @@ describe 'Pipelines', :feature, :js do
context 'for generic statuses' do context 'for generic statuses' do
context 'when running' do context 'when running' do
let!(:running) do let!(:running) do
create( create(:generic_commit_status,
:generic_commit_status,
status: 'running', status: 'running',
pipeline: pipeline, pipeline: pipeline,
stage: 'test' stage: 'test'
) )
end end
before do before { visit_project_pipelines }
visit namespace_project_pipelines_path(project.namespace, project)
wait_for_vue_resource
end
it 'is cancelable' do it 'is cancelable' do
expect(page).to have_link('Cancel') expect(page).to have_link('Cancel')
...@@ -178,17 +160,14 @@ describe 'Pipelines', :feature, :js do ...@@ -178,17 +160,14 @@ describe 'Pipelines', :feature, :js do
context 'when failed' do context 'when failed' do
let!(:status) do let!(:status) do
create( create(:generic_commit_status, :pending,
:generic_commit_status,
:pending,
pipeline: pipeline, pipeline: pipeline,
stage: 'test' stage: 'test')
)
end end
before do before do
status.drop status.drop
visit namespace_project_pipelines_path(project.namespace, project) visit_project_pipelines
end end
it 'is not retryable' do it 'is not retryable' do
...@@ -204,21 +183,13 @@ describe 'Pipelines', :feature, :js do ...@@ -204,21 +183,13 @@ describe 'Pipelines', :feature, :js do
context 'downloadable pipelines' do context 'downloadable pipelines' do
context 'with artifacts' do context 'with artifacts' do
let!(:with_artifacts) do let!(:with_artifacts) do
create( create(:ci_build, :artifacts, :success,
:ci_build,
:artifacts,
:success,
pipeline: pipeline, pipeline: pipeline,
name: 'rspec tests', name: 'rspec tests',
stage: 'test' stage: 'test')
)
end end
before do before { visit_project_pipelines }
visit namespace_project_pipelines_path(project.namespace, project)
wait_for_vue_resource
end
it 'has artifats' do it 'has artifats' do
expect(page).to have_selector('.build-artifacts') expect(page).to have_selector('.build-artifacts')
...@@ -233,37 +204,26 @@ describe 'Pipelines', :feature, :js do ...@@ -233,37 +204,26 @@ describe 'Pipelines', :feature, :js do
context 'with artifacts expired' do context 'with artifacts expired' do
let!(:with_artifacts_expired) do let!(:with_artifacts_expired) do
create( create(:ci_build, :artifacts_expired, :success,
:ci_build,
:artifacts_expired,
:success,
pipeline: pipeline, pipeline: pipeline,
name: 'rspec', name: 'rspec',
stage: 'test' stage: 'test')
)
end end
before do before { visit_project_pipelines }
visit namespace_project_pipelines_path(project.namespace, project)
end
it { expect(page).not_to have_selector('.build-artifacts') } it { expect(page).not_to have_selector('.build-artifacts') }
end end
context 'without artifacts' do context 'without artifacts' do
let!(:without_artifacts) do let!(:without_artifacts) do
create( create(:ci_build, :success,
:ci_build,
:success,
pipeline: pipeline, pipeline: pipeline,
name: 'rspec', name: 'rspec',
stage: 'test' stage: 'test')
)
end end
before do before { visit_project_pipelines }
visit namespace_project_pipelines_path(project.namespace, project)
end
it { expect(page).not_to have_selector('.build-artifacts') } it { expect(page).not_to have_selector('.build-artifacts') }
end end
...@@ -271,13 +231,12 @@ describe 'Pipelines', :feature, :js do ...@@ -271,13 +231,12 @@ describe 'Pipelines', :feature, :js do
context 'mini pipleine graph' do context 'mini pipleine graph' do
let!(:build) do let!(:build) do
create(:ci_build, pipeline: pipeline, stage: 'build', name: 'build') create(:ci_build, pipeline: pipeline,
stage: 'build',
name: 'build')
end end
before do before { visit_project_pipelines }
visit namespace_project_pipelines_path(project.namespace, project)
wait_for_vue_resource
end
context 'when clicking a graph stage' do context 'when clicking a graph stage' do
it 'should open a dropdown' do it 'should open a dropdown' do
...@@ -296,7 +255,7 @@ describe 'Pipelines', :feature, :js do ...@@ -296,7 +255,7 @@ describe 'Pipelines', :feature, :js do
end end
end end
describe 'POST /:project/pipelines', feature: true, js: true do describe 'POST /:project/pipelines' do
let(:project) { create(:project) } let(:project) { create(:project) }
before do before do
...@@ -332,7 +291,7 @@ describe 'Pipelines', :feature, :js do ...@@ -332,7 +291,7 @@ describe 'Pipelines', :feature, :js do
end end
end end
describe 'Create pipelines', feature: true, js: true do describe 'Create pipelines' do
let(:project) { create(:project) } let(:project) { create(:project) }
before do before do
...@@ -357,4 +316,9 @@ describe 'Pipelines', :feature, :js do ...@@ -357,4 +316,9 @@ describe 'Pipelines', :feature, :js do
end end
end end
end end
def visit_project_pipelines(**query)
visit namespace_project_pipelines_path(project.namespace, project, query)
wait_for_vue_resource
end
end end
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