diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
commit | d9ab72d6080f594d0b3cae15f14b3ef2c6c638cb (patch) | |
tree | 2341ef426af70ad1e289c38036737e04b0aa5007 /spec/features/admin/admin_jobs_spec.rb | |
parent | d6e514dd13db8947884cd58fe2a9c2a063400a9b (diff) |
Add latest changes from gitlab-org/gitlab@14-4-stable-eev14.4.0-rc42
Diffstat (limited to 'spec/features/admin/admin_jobs_spec.rb')
-rw-r--r-- | spec/features/admin/admin_jobs_spec.rb | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/spec/features/admin/admin_jobs_spec.rb b/spec/features/admin/admin_jobs_spec.rb new file mode 100644 index 00000000000..36822f89c12 --- /dev/null +++ b/spec/features/admin/admin_jobs_spec.rb @@ -0,0 +1,141 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Admin Jobs' do + before do + admin = create(:admin) + sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) + end + + describe 'GET /admin/jobs' do + let(:pipeline) { create(:ci_pipeline) } + + context 'All tab' do + context 'when have jobs' do + it 'shows all jobs', :js do + create(:ci_build, pipeline: pipeline, status: :pending) + create(:ci_build, pipeline: pipeline, status: :running) + create(:ci_build, pipeline: pipeline, status: :success) + create(:ci_build, pipeline: pipeline, status: :failed) + + visit admin_jobs_path + + expect(page).to have_selector('[data-testid="jobs-tabs"] a.active', text: 'All') + expect(page).to have_selector('.row-content-block', text: 'All jobs') + expect(page.all('.build-link').size).to eq(4) + expect(page).to have_button 'Stop all jobs' + + click_button 'Stop all jobs' + expect(page).to have_button 'Stop jobs' + expect(page).to have_content 'Stop all jobs?' + end + end + + context 'when have no jobs' do + it 'shows a message' do + visit admin_jobs_path + + expect(page).to have_selector('[data-testid="jobs-tabs"] a.active', text: 'All') + expect(page).to have_content 'No jobs to show' + expect(page).not_to have_button 'Stop all jobs' + end + end + end + + context 'Pending tab' do + context 'when have pending jobs' do + it 'shows pending jobs' do + build1 = create(:ci_build, pipeline: pipeline, status: :pending) + build2 = create(:ci_build, pipeline: pipeline, status: :running) + build3 = create(:ci_build, pipeline: pipeline, status: :success) + build4 = create(:ci_build, pipeline: pipeline, status: :failed) + + visit admin_jobs_path(scope: :pending) + + expect(page).to have_selector('[data-testid="jobs-tabs"] a.active', text: 'Pending') + expect(page.find('.build-link')).to have_content(build1.id) + expect(page.find('.build-link')).not_to have_content(build2.id) + expect(page.find('.build-link')).not_to have_content(build3.id) + expect(page.find('.build-link')).not_to have_content(build4.id) + expect(page).to have_button 'Stop all jobs' + end + end + + context 'when have no jobs pending' do + it 'shows a message' do + create(:ci_build, pipeline: pipeline, status: :success) + + visit admin_jobs_path(scope: :pending) + + expect(page).to have_selector('[data-testid="jobs-tabs"] a.active', text: 'Pending') + expect(page).to have_content 'No jobs to show' + expect(page).not_to have_button 'Stop all jobs' + end + end + end + + context 'Running tab' do + context 'when have running jobs' do + it 'shows running jobs' do + build1 = create(:ci_build, pipeline: pipeline, status: :running) + build2 = create(:ci_build, pipeline: pipeline, status: :success) + build3 = create(:ci_build, pipeline: pipeline, status: :failed) + build4 = create(:ci_build, pipeline: pipeline, status: :pending) + + visit admin_jobs_path(scope: :running) + + expect(page).to have_selector('[data-testid="jobs-tabs"] a.active', text: 'Running') + expect(page.find('.build-link')).to have_content(build1.id) + expect(page.find('.build-link')).not_to have_content(build2.id) + expect(page.find('.build-link')).not_to have_content(build3.id) + expect(page.find('.build-link')).not_to have_content(build4.id) + expect(page).to have_button 'Stop all jobs' + end + end + + context 'when have no jobs running' do + it 'shows a message' do + create(:ci_build, pipeline: pipeline, status: :success) + + visit admin_jobs_path(scope: :running) + + expect(page).to have_selector('[data-testid="jobs-tabs"] a.active', text: 'Running') + expect(page).to have_content 'No jobs to show' + expect(page).not_to have_button 'Stop all jobs' + end + end + end + + context 'Finished tab' do + context 'when have finished jobs' do + it 'shows finished jobs' do + build1 = create(:ci_build, pipeline: pipeline, status: :pending) + build2 = create(:ci_build, pipeline: pipeline, status: :running) + build3 = create(:ci_build, pipeline: pipeline, status: :success) + + visit admin_jobs_path(scope: :finished) + + expect(page).to have_selector('[data-testid="jobs-tabs"] a.active', text: 'Finished') + expect(page.find('.build-link')).not_to have_content(build1.id) + expect(page.find('.build-link')).not_to have_content(build2.id) + expect(page.find('.build-link')).to have_content(build3.id) + expect(page).to have_button 'Stop all jobs' + end + end + + context 'when have no jobs finished' do + it 'shows a message' do + create(:ci_build, pipeline: pipeline, status: :running) + + visit admin_jobs_path(scope: :finished) + + expect(page).to have_selector('[data-testid="jobs-tabs"] a.active', text: 'Finished') + expect(page).to have_content 'No jobs to show' + expect(page).to have_button 'Stop all jobs' + end + end + end + end +end |