2019-07-25 05:24:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-08-26 01:42:46 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2021-10-07 00:09:20 +00:00
|
|
|
RSpec.describe 'Admin Jobs' do
|
2015-08-26 01:42:46 +00:00
|
|
|
before do
|
2020-11-23 15:09:37 +00:00
|
|
|
admin = create(:admin)
|
|
|
|
sign_in(admin)
|
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
2015-08-26 01:42:46 +00:00
|
|
|
end
|
|
|
|
|
2021-10-07 00:09:20 +00:00
|
|
|
describe 'GET /admin/jobs' do
|
2016-06-03 14:22:26 +00:00
|
|
|
let(:pipeline) { create(:ci_pipeline) }
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2015-12-30 14:25:42 +00:00
|
|
|
context 'All tab' do
|
2017-01-26 11:52:58 +00:00
|
|
|
context 'when have jobs' do
|
2020-10-28 21:08:42 +00:00
|
|
|
it 'shows all jobs', :js do
|
2016-06-03 14:22:26 +00:00
|
|
|
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)
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2017-05-16 11:41:15 +00:00
|
|
|
visit admin_jobs_path
|
2015-12-04 11:55:23 +00:00
|
|
|
|
2021-10-07 00:09:20 +00:00
|
|
|
expect(page).to have_selector('[data-testid="jobs-tabs"] a.active', text: 'All')
|
2017-01-26 11:52:58 +00:00
|
|
|
expect(page).to have_selector('.row-content-block', text: 'All jobs')
|
2015-12-30 14:25:42 +00:00
|
|
|
expect(page.all('.build-link').size).to eq(4)
|
2018-01-08 16:37:00 +00:00
|
|
|
expect(page).to have_button 'Stop all jobs'
|
2020-10-28 21:08:42 +00:00
|
|
|
|
|
|
|
click_button 'Stop all jobs'
|
|
|
|
expect(page).to have_button 'Stop jobs'
|
|
|
|
expect(page).to have_content 'Stop all jobs?'
|
2015-12-30 14:25:42 +00:00
|
|
|
end
|
2015-12-04 11:55:23 +00:00
|
|
|
end
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2017-01-26 11:52:58 +00:00
|
|
|
context 'when have no jobs' do
|
2015-12-30 14:25:42 +00:00
|
|
|
it 'shows a message' do
|
2017-05-16 11:41:15 +00:00
|
|
|
visit admin_jobs_path
|
2015-12-30 14:25:42 +00:00
|
|
|
|
2021-10-07 00:09:20 +00:00
|
|
|
expect(page).to have_selector('[data-testid="jobs-tabs"] a.active', text: 'All')
|
2017-01-26 11:52:58 +00:00
|
|
|
expect(page).to have_content 'No jobs to show'
|
2018-01-08 16:37:00 +00:00
|
|
|
expect(page).not_to have_button 'Stop all jobs'
|
2015-12-30 14:25:42 +00:00
|
|
|
end
|
|
|
|
end
|
2015-08-26 01:42:46 +00:00
|
|
|
end
|
|
|
|
|
2016-07-05 12:39:55 +00:00
|
|
|
context 'Pending tab' do
|
2017-01-26 11:52:58 +00:00
|
|
|
context 'when have pending jobs' do
|
|
|
|
it 'shows pending jobs' do
|
2016-07-05 12:39:55 +00:00
|
|
|
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)
|
|
|
|
|
2017-05-16 11:41:15 +00:00
|
|
|
visit admin_jobs_path(scope: :pending)
|
2016-07-05 12:39:55 +00:00
|
|
|
|
2021-10-07 00:09:20 +00:00
|
|
|
expect(page).to have_selector('[data-testid="jobs-tabs"] a.active', text: 'Pending')
|
2016-07-05 12:39:55 +00:00
|
|
|
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)
|
2018-01-08 16:37:00 +00:00
|
|
|
expect(page).to have_button 'Stop all jobs'
|
2016-07-05 12:39:55 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-01-26 11:52:58 +00:00
|
|
|
context 'when have no jobs pending' do
|
2016-07-05 12:39:55 +00:00
|
|
|
it 'shows a message' do
|
|
|
|
create(:ci_build, pipeline: pipeline, status: :success)
|
|
|
|
|
2017-05-16 11:41:15 +00:00
|
|
|
visit admin_jobs_path(scope: :pending)
|
2016-07-05 12:39:55 +00:00
|
|
|
|
2021-10-07 00:09:20 +00:00
|
|
|
expect(page).to have_selector('[data-testid="jobs-tabs"] a.active', text: 'Pending')
|
2017-01-26 11:52:58 +00:00
|
|
|
expect(page).to have_content 'No jobs to show'
|
2018-01-08 16:37:00 +00:00
|
|
|
expect(page).not_to have_button 'Stop all jobs'
|
2016-07-05 12:39:55 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-12-30 14:25:42 +00:00
|
|
|
context 'Running tab' do
|
2017-01-26 11:52:58 +00:00
|
|
|
context 'when have running jobs' do
|
|
|
|
it 'shows running jobs' do
|
2016-07-05 12:39:55 +00:00
|
|
|
build1 = create(:ci_build, pipeline: pipeline, status: :running)
|
2016-06-03 14:22:26 +00:00
|
|
|
build2 = create(:ci_build, pipeline: pipeline, status: :success)
|
|
|
|
build3 = create(:ci_build, pipeline: pipeline, status: :failed)
|
2016-07-05 12:39:55 +00:00
|
|
|
build4 = create(:ci_build, pipeline: pipeline, status: :pending)
|
2015-12-30 14:25:42 +00:00
|
|
|
|
2017-05-16 11:41:15 +00:00
|
|
|
visit admin_jobs_path(scope: :running)
|
2015-12-30 14:25:42 +00:00
|
|
|
|
2021-10-07 00:09:20 +00:00
|
|
|
expect(page).to have_selector('[data-testid="jobs-tabs"] a.active', text: 'Running')
|
2015-12-30 14:25:42 +00:00
|
|
|
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)
|
2016-07-05 12:39:55 +00:00
|
|
|
expect(page.find('.build-link')).not_to have_content(build4.id)
|
2018-01-08 16:37:00 +00:00
|
|
|
expect(page).to have_button 'Stop all jobs'
|
2015-12-30 14:25:42 +00:00
|
|
|
end
|
|
|
|
end
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2017-01-26 11:52:58 +00:00
|
|
|
context 'when have no jobs running' do
|
2015-12-30 14:25:42 +00:00
|
|
|
it 'shows a message' do
|
2016-06-03 14:22:26 +00:00
|
|
|
create(:ci_build, pipeline: pipeline, status: :success)
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2017-05-16 11:41:15 +00:00
|
|
|
visit admin_jobs_path(scope: :running)
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2021-10-07 00:09:20 +00:00
|
|
|
expect(page).to have_selector('[data-testid="jobs-tabs"] a.active', text: 'Running')
|
2017-01-26 11:52:58 +00:00
|
|
|
expect(page).to have_content 'No jobs to show'
|
2018-01-08 16:37:00 +00:00
|
|
|
expect(page).not_to have_button 'Stop all jobs'
|
2015-12-30 14:25:42 +00:00
|
|
|
end
|
|
|
|
end
|
2015-08-26 01:42:46 +00:00
|
|
|
end
|
|
|
|
|
2015-12-30 14:25:42 +00:00
|
|
|
context 'Finished tab' do
|
2017-01-26 11:52:58 +00:00
|
|
|
context 'when have finished jobs' do
|
|
|
|
it 'shows finished jobs' do
|
2016-06-03 14:22:26 +00:00
|
|
|
build1 = create(:ci_build, pipeline: pipeline, status: :pending)
|
|
|
|
build2 = create(:ci_build, pipeline: pipeline, status: :running)
|
|
|
|
build3 = create(:ci_build, pipeline: pipeline, status: :success)
|
2015-12-30 14:25:42 +00:00
|
|
|
|
2017-05-16 11:41:15 +00:00
|
|
|
visit admin_jobs_path(scope: :finished)
|
2015-12-30 14:25:42 +00:00
|
|
|
|
2021-10-07 00:09:20 +00:00
|
|
|
expect(page).to have_selector('[data-testid="jobs-tabs"] a.active', text: 'Finished')
|
2015-12-30 14:25:42 +00:00
|
|
|
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)
|
2018-01-08 16:37:00 +00:00
|
|
|
expect(page).to have_button 'Stop all jobs'
|
2015-12-30 14:25:42 +00:00
|
|
|
end
|
|
|
|
end
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2017-01-26 11:52:58 +00:00
|
|
|
context 'when have no jobs finished' do
|
2015-12-30 14:25:42 +00:00
|
|
|
it 'shows a message' do
|
2016-06-03 14:22:26 +00:00
|
|
|
create(:ci_build, pipeline: pipeline, status: :running)
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2017-05-16 11:41:15 +00:00
|
|
|
visit admin_jobs_path(scope: :finished)
|
2015-08-26 01:42:46 +00:00
|
|
|
|
2021-10-07 00:09:20 +00:00
|
|
|
expect(page).to have_selector('[data-testid="jobs-tabs"] a.active', text: 'Finished')
|
2017-01-26 11:52:58 +00:00
|
|
|
expect(page).to have_content 'No jobs to show'
|
2018-01-08 16:37:00 +00:00
|
|
|
expect(page).to have_button 'Stop all jobs'
|
2015-12-30 14:25:42 +00:00
|
|
|
end
|
|
|
|
end
|
2015-08-26 01:42:46 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|