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