debian-mirror-gitlab/spec/features/projects/jobs/user_browses_job_spec.rb

123 lines
3.8 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
require 'spec_helper'
describe 'User browses a job', :js do
let(:user) { create(:user) }
2018-05-09 12:01:36 +05:30
let(:user_access_level) { :developer }
let(:project) { create(:project, :repository, namespace: user.namespace) }
let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.sha, ref: 'master') }
let!(:build) { create(:ci_build, :success, :trace_artifact, :coverage, pipeline: pipeline) }
2018-03-17 18:26:18 +05:30
before do
2018-11-18 11:00:15 +05:30
project.add_maintainer(user)
2018-03-17 18:26:18 +05:30
project.enable_ci
sign_in(user)
visit(project_job_path(project, build))
end
2018-12-05 23:21:45 +05:30
it 'erases the job log', :js do
wait_for_requests
2018-03-17 18:26:18 +05:30
expect(page).to have_content("Job ##{build.id}")
2018-12-13 13:39:08 +05:30
expect(page).to have_css('.js-build-trace')
2018-03-17 18:26:18 +05:30
2018-05-09 12:01:36 +05:30
# scroll to the top of the page first
execute_script "window.scrollTo(0,0)"
accept_confirm { find('.js-erase-link').click }
2018-03-17 18:26:18 +05:30
expect(page).to have_no_css('.artifacts')
expect(build).not_to have_trace
2019-09-04 21:01:54 +05:30
expect(build.artifacts_file.present?).to be_falsy
expect(build.artifacts_metadata.present?).to be_falsy
2018-03-17 18:26:18 +05:30
2018-12-05 23:21:45 +05:30
expect(page).to have_content('Job has been erased')
2018-03-17 18:26:18 +05:30
end
2018-05-09 12:01:36 +05:30
2019-09-04 21:01:54 +05:30
shared_examples 'has collapsible sections' do
it 'collapses the section clicked' do
wait_for_requests
text_to_hide = "Cloning into '/nolith/ci-tests'"
text_to_show = 'Waiting for pod'
expect(page).to have_content(text_to_hide)
expect(page).to have_content(text_to_show)
first('.js-section-start[data-section="get-sources"]').click
expect(page).not_to have_content(text_to_hide)
expect(page).to have_content(text_to_show)
end
2019-10-12 21:52:04 +05:30
it 'collapses the section header clicked' do
wait_for_requests
text_to_hide = "Cloning into '/nolith/ci-tests'"
text_to_show = 'Waiting for pod'
expect(page).to have_content(text_to_hide)
expect(page).to have_content(text_to_show)
first('.js-section-header.js-s-get-sources').click
expect(page).not_to have_content(text_to_hide)
expect(page).to have_content(text_to_show)
end
2019-09-04 21:01:54 +05:30
end
context 'when job trace contains sections' do
let!(:build) { create(:ci_build, :success, :trace_with_sections, :coverage, pipeline: pipeline) }
it_behaves_like 'has collapsible sections'
end
context 'when job trace contains duplicate sections' do
let!(:build) { create(:ci_build, :success, :trace_with_duplicate_sections, :coverage, pipeline: pipeline) }
it_behaves_like 'has collapsible sections'
end
context 'when job trace contains sections' do
let!(:build) { create(:ci_build, :success, :trace_with_duplicate_sections, :coverage, pipeline: pipeline) }
it 'collapses a section' do
wait_for_requests
text_to_hide = "Cloning into '/nolith/ci-tests'"
text_to_show = 'Waiting for pod'
expect(page).to have_content(text_to_hide)
expect(page).to have_content(text_to_show)
first('.js-section-start[data-section="get-sources"]').click
expect(page).not_to have_content(text_to_hide)
expect(page).to have_content(text_to_show)
end
end
2018-05-09 12:01:36 +05:30
context 'with a failed job' do
let!(:build) { create(:ci_build, :failed, :trace_artifact, pipeline: pipeline) }
it 'displays the failure reason' do
2018-12-05 23:21:45 +05:30
wait_for_all_requests
2018-05-09 12:01:36 +05:30
within('.builds-container') do
build_link = first('.build-job > a')
2018-12-05 23:21:45 +05:30
expect(build_link['data-original-title']).to eq('test - failed - (unknown failure)')
2018-05-09 12:01:36 +05:30
end
end
end
context 'when a failed job has been retried' do
let!(:build) { create(:ci_build, :failed, :retried, :trace_artifact, pipeline: pipeline) }
it 'displays the failure reason and retried label' do
2018-12-05 23:21:45 +05:30
wait_for_all_requests
2018-05-09 12:01:36 +05:30
within('.builds-container') do
build_link = first('.build-job > a')
2018-12-05 23:21:45 +05:30
expect(build_link['data-original-title']).to eq('test - failed - (unknown failure) (retried)')
2018-05-09 12:01:36 +05:30
end
end
end
2018-03-17 18:26:18 +05:30
end