2019-09-04 21:01:54 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
RSpec.describe 'Pipeline', :js, feature_category: :projects do
|
2019-07-07 11:18:12 +05:30
|
|
|
include RoutesHelpers
|
|
|
|
include ProjectForksHelper
|
2019-09-04 21:01:54 +05:30
|
|
|
include ::ExclusiveLeaseHelpers
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
let_it_be(:project) { create(:project) }
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
let(:user) { create(:user) }
|
2018-10-15 14:42:47 +05:30
|
|
|
let(:role) { :developer }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
before do
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in(user)
|
2018-10-15 14:42:47 +05:30
|
|
|
project.add_role(user, role)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
shared_context 'pipeline builds' do
|
2023-03-17 16:20:25 +05:30
|
|
|
let!(:external_stage) { create(:ci_stage, name: 'external', pipeline: pipeline) }
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
let!(:build_passed) do
|
|
|
|
create(:ci_build, :success,
|
2020-05-24 23:13:21 +05:30
|
|
|
pipeline: pipeline, stage: 'build', stage_idx: 0, name: 'build')
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
let!(:build_failed) do
|
|
|
|
create(:ci_build, :failed,
|
2020-05-24 23:13:21 +05:30
|
|
|
pipeline: pipeline, stage: 'test', stage_idx: 1, name: 'test')
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
let!(:build_preparing) do
|
|
|
|
create(:ci_build, :preparing,
|
2020-05-24 23:13:21 +05:30
|
|
|
pipeline: pipeline, stage: 'deploy', stage_idx: 2, name: 'prepare')
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
let!(:build_running) do
|
|
|
|
create(:ci_build, :running,
|
2020-05-24 23:13:21 +05:30
|
|
|
pipeline: pipeline, stage: 'deploy', stage_idx: 3, name: 'deploy')
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
let!(:build_manual) do
|
|
|
|
create(:ci_build, :manual,
|
2020-05-24 23:13:21 +05:30
|
|
|
pipeline: pipeline, stage: 'deploy', stage_idx: 3, name: 'manual-build')
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
let!(:build_scheduled) do
|
|
|
|
create(:ci_build, :scheduled,
|
2020-05-24 23:13:21 +05:30
|
|
|
pipeline: pipeline, stage: 'deploy', stage_idx: 3, name: 'delayed-job')
|
2018-12-05 23:21:45 +05:30
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
let!(:build_external) do
|
|
|
|
create(:generic_commit_status, status: 'success',
|
|
|
|
pipeline: pipeline,
|
|
|
|
name: 'jenkins',
|
2023-03-17 16:20:25 +05:30
|
|
|
ci_stage: external_stage,
|
2022-01-26 12:08:38 +05:30
|
|
|
ref: 'master',
|
2017-08-17 22:00:37 +05:30
|
|
|
target_url: 'http://gitlab.com/status')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
describe 'GET /:project/-/pipelines/:id' do
|
2017-08-17 22:00:37 +05:30
|
|
|
include_context 'pipeline builds'
|
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
let_it_be(:group) { create(:group) }
|
|
|
|
let_it_be(:project, reload: true) { create(:project, :repository, group: group) }
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
let(:pipeline) do
|
|
|
|
create(:ci_pipeline, name: 'Build pipeline', project: project, ref: 'master', sha: project.commit.id, user: user)
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
subject(:visit_pipeline) { visit project_pipeline_path(project, pipeline) }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
it 'shows the pipeline graph' do
|
2019-07-07 11:18:12 +05:30
|
|
|
visit_pipeline
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
expect(page).to have_selector('.js-pipeline-graph')
|
2022-10-11 01:57:18 +05:30
|
|
|
expect(page).to have_content('build')
|
|
|
|
expect(page).to have_content('test')
|
|
|
|
expect(page).to have_content('deploy')
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(page).to have_content('Retry')
|
|
|
|
expect(page).to have_content('Cancel running')
|
|
|
|
end
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
it 'shows link to the pipeline ref' do
|
2019-07-07 11:18:12 +05:30
|
|
|
visit_pipeline
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
expect(page).to have_link(pipeline.ref)
|
|
|
|
end
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
it 'shows the pipeline information' do
|
|
|
|
visit_pipeline
|
|
|
|
|
|
|
|
within '.pipeline-info' do
|
|
|
|
expect(page).to have_content("#{pipeline.statuses.count} jobs " \
|
2019-09-04 21:01:54 +05:30
|
|
|
"for #{pipeline.ref}")
|
2019-07-07 11:18:12 +05:30
|
|
|
expect(page).to have_link(pipeline.ref,
|
|
|
|
href: project_commits_path(pipeline.project, pipeline.ref))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-03-17 16:20:25 +05:30
|
|
|
it 'displays pipeline name instead of commit title' do
|
|
|
|
visit_pipeline
|
2023-01-13 00:05:48 +05:30
|
|
|
|
2023-03-17 16:20:25 +05:30
|
|
|
within 'h3' do
|
|
|
|
expect(page).to have_content(pipeline.name)
|
2023-01-13 00:05:48 +05:30
|
|
|
end
|
|
|
|
|
2023-03-17 16:20:25 +05:30
|
|
|
within '.well-segment[data-testid="commit-row"]' do
|
|
|
|
expect(page).to have_content(project.commit.title)
|
|
|
|
expect(page).to have_content(project.commit.short_id)
|
2023-01-13 00:05:48 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
describe 'pipeline stats text' do
|
|
|
|
let(:finished_pipeline) do
|
|
|
|
create(:ci_pipeline, :success, project: project,
|
|
|
|
ref: 'master', sha: project.commit.id, user: user)
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
finished_pipeline.update!(started_at: "2023-01-01 01:01:05", created_at: "2023-01-01 01:01:01",
|
|
|
|
finished_at: "2023-01-01 01:01:10", duration: 9)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'pipeline has finished' do
|
|
|
|
it 'shows pipeline stats with flag on' do
|
|
|
|
visit project_pipeline_path(project, finished_pipeline)
|
|
|
|
|
|
|
|
within '.pipeline-info' do
|
|
|
|
expect(page).to have_content("in #{finished_pipeline.duration} seconds")
|
|
|
|
expect(page).to have_content("and was queued for #{finished_pipeline.queued_duration} seconds")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'pipeline has not finished' do
|
|
|
|
it 'does not show pipeline stats' do
|
|
|
|
visit_pipeline
|
|
|
|
|
|
|
|
within '.pipeline-info' do
|
|
|
|
expect(page).not_to have_selector('[data-testid="pipeline-stats-text"]')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
describe 'related merge requests' do
|
|
|
|
context 'when there are no related merge requests' do
|
|
|
|
it 'shows a "no related merge requests" message' do
|
|
|
|
visit_pipeline
|
|
|
|
|
|
|
|
within '.related-merge-request-info' do
|
|
|
|
expect(page).to have_content('No related merge requests found.')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-12-21 20:55:43 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
context 'when there is one related merge request' do
|
2020-07-28 23:09:34 +05:30
|
|
|
let!(:merge_request) do
|
2020-03-13 15:44:24 +05:30
|
|
|
create(:merge_request,
|
|
|
|
source_project: project,
|
|
|
|
source_branch: pipeline.ref)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows a link to the merge request' do
|
|
|
|
visit_pipeline
|
|
|
|
|
|
|
|
within '.related-merge-requests' do
|
|
|
|
expect(page).to have_content('1 related merge request: ')
|
|
|
|
expect(page).to have_selector('.js-truncated-mr-list')
|
2020-07-28 23:09:34 +05:30
|
|
|
expect(page).to have_link("#{merge_request.to_reference} #{merge_request.title}")
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
expect(page).not_to have_selector('.js-full-mr-list')
|
|
|
|
expect(page).not_to have_selector('.text-expander')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when there are two related merge requests' do
|
2020-07-28 23:09:34 +05:30
|
|
|
let!(:merge_request1) do
|
|
|
|
create(:merge_request,
|
|
|
|
source_project: project,
|
|
|
|
source_branch: pipeline.ref)
|
|
|
|
end
|
2020-10-24 23:57:45 +05:30
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
let!(:merge_request2) do
|
|
|
|
create(:merge_request,
|
|
|
|
source_project: project,
|
|
|
|
source_branch: pipeline.ref,
|
|
|
|
target_branch: 'fix')
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'links to the most recent related merge request' do
|
|
|
|
visit_pipeline
|
|
|
|
|
|
|
|
within '.related-merge-requests' do
|
|
|
|
expect(page).to have_content('2 related merge requests: ')
|
2020-07-28 23:09:34 +05:30
|
|
|
expect(page).to have_link("#{merge_request2.to_reference} #{merge_request2.title}")
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(page).to have_selector('.text-expander')
|
|
|
|
expect(page).to have_selector('.js-full-mr-list', visible: false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'expands to show links to all related merge requests' do
|
|
|
|
visit_pipeline
|
|
|
|
|
|
|
|
within '.related-merge-requests' do
|
|
|
|
find('.text-expander').click
|
|
|
|
|
|
|
|
expect(page).to have_selector('.js-full-mr-list', visible: true)
|
|
|
|
|
|
|
|
pipeline.all_merge_requests.map do |merge_request|
|
|
|
|
expect(page).to have_link(href: project_merge_request_path(project, merge_request))
|
|
|
|
end
|
|
|
|
end
|
2019-12-21 20:55:43 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
describe 'pipelines details view' do
|
|
|
|
let!(:status) { create(:user_status, user: pipeline.user, emoji: 'smirk', message: 'Authoring this object') }
|
2018-11-18 11:00:15 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
it 'pipeline header shows the user status and emoji' do
|
|
|
|
visit project_pipeline_path(project, pipeline)
|
|
|
|
|
|
|
|
within '[data-testid="ci-header-content"]' do
|
|
|
|
expect(page).to have_selector("[data-testid='#{status.message}']")
|
|
|
|
expect(page).to have_selector("[data-name='#{status.emoji}']")
|
|
|
|
end
|
|
|
|
end
|
2018-11-18 11:00:15 +05:30
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
describe 'pipeline graph' do
|
|
|
|
context 'when pipeline has running builds' do
|
2022-07-16 23:28:13 +05:30
|
|
|
before do
|
|
|
|
visit_pipeline
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
it 'shows a running icon and a cancel action for the running build' do
|
|
|
|
page.within('#ci-badge-deploy') do
|
|
|
|
expect(page).to have_selector('.js-ci-status-icon-running')
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(page).to have_selector('.js-icon-cancel')
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(page).to have_content('deploy')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
it 'cancels the running build and shows retry button', :sidekiq_might_not_need_inline do
|
2018-03-17 18:26:18 +05:30
|
|
|
find('#ci-badge-deploy .ci-action-icon-container').click
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
page.within('#ci-badge-deploy') do
|
|
|
|
expect(page).to have_css('.js-icon-retry')
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
context 'when pipeline has preparing builds' do
|
2022-07-16 23:28:13 +05:30
|
|
|
before do
|
|
|
|
visit_pipeline
|
|
|
|
end
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
it 'shows a preparing icon and a cancel action' do
|
|
|
|
page.within('#ci-badge-prepare') do
|
|
|
|
expect(page).to have_selector('.js-ci-status-icon-preparing')
|
|
|
|
expect(page).to have_selector('.js-icon-cancel')
|
|
|
|
expect(page).to have_content('prepare')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
it 'cancels the preparing build and shows retry button', :sidekiq_might_not_need_inline do
|
2019-07-07 11:18:12 +05:30
|
|
|
find('#ci-badge-deploy .ci-action-icon-container').click
|
|
|
|
|
|
|
|
page.within('#ci-badge-deploy') do
|
|
|
|
expect(page).to have_css('.js-icon-retry')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
context 'when pipeline has successful builds' do
|
2022-07-16 23:28:13 +05:30
|
|
|
before do
|
|
|
|
visit_pipeline
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
it 'shows the success icon and a retry action for the successful build' do
|
|
|
|
page.within('#ci-badge-build') do
|
|
|
|
expect(page).to have_selector('.js-ci-status-icon-success')
|
|
|
|
expect(page).to have_content('build')
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
page.within('#ci-badge-build .ci-action-icon-container.js-icon-retry') do
|
|
|
|
expect(page).to have_selector('svg')
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
it 'is possible to retry the success job', :sidekiq_might_not_need_inline do
|
2018-03-17 18:26:18 +05:30
|
|
|
find('#ci-badge-build .ci-action-icon-container').click
|
2021-10-27 15:23:28 +05:30
|
|
|
wait_for_requests
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
expect(page).not_to have_content('Retry job')
|
2021-10-27 15:23:28 +05:30
|
|
|
within('.js-pipeline-header-container') do
|
|
|
|
expect(page).to have_selector('.js-ci-status-icon-running')
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
context 'when pipeline has a delayed job' do
|
2022-07-16 23:28:13 +05:30
|
|
|
before do
|
|
|
|
visit_pipeline
|
|
|
|
end
|
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
let(:project) { create(:project, :repository, group: group) }
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
it 'shows the scheduled icon and an unschedule action for the delayed job' do
|
|
|
|
page.within('#ci-badge-delayed-job') do
|
|
|
|
expect(page).to have_selector('.js-ci-status-icon-scheduled')
|
|
|
|
expect(page).to have_content('delayed-job')
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within('#ci-badge-delayed-job .ci-action-icon-container.js-icon-time-out') do
|
|
|
|
expect(page).to have_selector('svg')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
it 'unschedules the delayed job and shows play button as a manual job', :sidekiq_might_not_need_inline do
|
2018-12-05 23:21:45 +05:30
|
|
|
find('#ci-badge-delayed-job .ci-action-icon-container').click
|
|
|
|
|
|
|
|
page.within('#ci-badge-delayed-job') do
|
|
|
|
expect(page).to have_css('.js-icon-play')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
context 'when pipeline has failed builds' do
|
2022-07-16 23:28:13 +05:30
|
|
|
before do
|
|
|
|
visit_pipeline
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
it 'shows the failed icon and a retry action for the failed build' do
|
|
|
|
page.within('#ci-badge-test') do
|
|
|
|
expect(page).to have_selector('.js-ci-status-icon-failed')
|
|
|
|
expect(page).to have_content('test')
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
page.within('#ci-badge-test .ci-action-icon-container.js-icon-retry') do
|
|
|
|
expect(page).to have_selector('svg')
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
it 'is possible to retry the failed build', :sidekiq_might_not_need_inline do
|
2018-03-17 18:26:18 +05:30
|
|
|
find('#ci-badge-test .ci-action-icon-container').click
|
2021-10-27 15:23:28 +05:30
|
|
|
wait_for_requests
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
expect(page).not_to have_content('Retry job')
|
2021-10-27 15:23:28 +05:30
|
|
|
within('.js-pipeline-header-container') do
|
|
|
|
expect(page).to have_selector('.js-ci-status-icon-running')
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
it 'includes the failure reason' do
|
2018-05-09 12:01:36 +05:30
|
|
|
page.within('#ci-badge-test') do
|
|
|
|
build_link = page.find('.js-pipeline-graph-job-link')
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(build_link['title']).to eq('test - failed - (unknown failure)')
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'when pipeline has manual jobs' do
|
2022-07-16 23:28:13 +05:30
|
|
|
before do
|
|
|
|
visit_pipeline
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
it 'shows the skipped icon and a play action for the manual build' do
|
|
|
|
page.within('#ci-badge-manual-build') do
|
|
|
|
expect(page).to have_selector('.js-ci-status-icon-manual')
|
|
|
|
expect(page).to have_content('manual')
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
page.within('#ci-badge-manual-build .ci-action-icon-container.js-icon-play') do
|
|
|
|
expect(page).to have_selector('svg')
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
it 'is possible to play the manual job', :sidekiq_might_not_need_inline do
|
2018-03-17 18:26:18 +05:30
|
|
|
find('#ci-badge-manual-build .ci-action-icon-container').click
|
2021-10-27 15:23:28 +05:30
|
|
|
wait_for_requests
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
expect(page).not_to have_content('Play job')
|
2021-10-27 15:23:28 +05:30
|
|
|
within('.js-pipeline-header-container') do
|
|
|
|
expect(page).to have_selector('.js-ci-status-icon-running')
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when pipeline has external job' do
|
2022-07-16 23:28:13 +05:30
|
|
|
before do
|
|
|
|
visit_pipeline
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
it 'shows the success icon and the generic comit status build' do
|
|
|
|
expect(page).to have_selector('.js-ci-status-icon-success')
|
|
|
|
expect(page).to have_content('jenkins')
|
|
|
|
expect(page).to have_link('jenkins', href: 'http://gitlab.com/status')
|
|
|
|
end
|
|
|
|
end
|
2022-07-16 23:28:13 +05:30
|
|
|
|
|
|
|
context 'when pipeline has a downstream pipeline' do
|
|
|
|
let(:downstream_project) { create(:project, :repository, group: group) }
|
|
|
|
let(:downstream_pipeline) do
|
|
|
|
create(:ci_pipeline,
|
|
|
|
status,
|
|
|
|
user: user,
|
|
|
|
project: downstream_project,
|
|
|
|
ref: 'master',
|
|
|
|
sha: downstream_project.commit.id,
|
2023-01-13 00:05:48 +05:30
|
|
|
child_of: pipeline)
|
2022-07-16 23:28:13 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
let!(:build) { create(:ci_build, status, pipeline: downstream_pipeline, user: user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
downstream_pipeline.project.add_developer(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'and user has permission' do
|
|
|
|
before do
|
|
|
|
visit_pipeline
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a successful downstream' do
|
|
|
|
let(:status) { :success }
|
|
|
|
|
|
|
|
it 'does not show the cancel or retry action' do
|
|
|
|
expect(page).to have_selector('.ci-status-icon-success')
|
|
|
|
expect(page).not_to have_selector('button[aria-label="Retry downstream pipeline"]')
|
|
|
|
expect(page).not_to have_selector('button[aria-label="Cancel downstream pipeline"]')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a running downstream' do
|
|
|
|
let(:status) { :running }
|
|
|
|
|
|
|
|
it 'shows the cancel action' do
|
|
|
|
expect(page).to have_selector('button[aria-label="Cancel downstream pipeline"]')
|
|
|
|
end
|
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
context 'when canceling', :sidekiq_inline do
|
2022-07-16 23:28:13 +05:30
|
|
|
before do
|
|
|
|
find('button[aria-label="Cancel downstream pipeline"]').click
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the pipeline as canceled with the retry action' do
|
|
|
|
expect(page).to have_selector('button[aria-label="Retry downstream pipeline"]')
|
|
|
|
expect(page).to have_selector('.ci-status-icon-canceled')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a failed downstream' do
|
|
|
|
let(:status) { :failed }
|
|
|
|
|
|
|
|
it 'indicates that pipeline can be retried' do
|
|
|
|
expect(page).to have_selector('button[aria-label="Retry downstream pipeline"]')
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when retrying' do
|
|
|
|
before do
|
|
|
|
find('button[aria-label="Retry downstream pipeline"]').click
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows running pipeline with the cancel action' do
|
|
|
|
expect(page).to have_selector('.ci-status-icon-running')
|
|
|
|
expect(page).to have_selector('button[aria-label="Cancel downstream pipeline"]')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a canceled downstream' do
|
|
|
|
let(:status) { :canceled }
|
|
|
|
|
|
|
|
it 'indicates that pipeline can be retried' do
|
|
|
|
expect(page).to have_selector('button[aria-label="Retry downstream pipeline"]')
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when retrying' do
|
|
|
|
before do
|
|
|
|
find('button[aria-label="Retry downstream pipeline"]').click
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows running pipeline with the cancel action' do
|
|
|
|
expect(page).to have_selector('.ci-status-icon-running')
|
|
|
|
expect(page).to have_selector('button[aria-label="Cancel downstream pipeline"]')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user does not have permissions' do
|
|
|
|
let(:status) { :failed }
|
|
|
|
|
|
|
|
before do
|
|
|
|
new_user = create(:user)
|
|
|
|
project.add_role(new_user, :guest)
|
|
|
|
downstream_project.add_role(new_user, :guest)
|
|
|
|
sign_in(new_user)
|
|
|
|
|
|
|
|
visit_pipeline
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show the retry button' do
|
|
|
|
expect(page).to have_selector('.ci-status-icon-failed')
|
|
|
|
expect(page).not_to have_selector('button[aria-label="Retry downstream pipeline"]')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
context 'when the pipeline has manual stage' do
|
|
|
|
before do
|
2020-05-24 23:13:21 +05:30
|
|
|
create(:ci_build, :manual, pipeline: pipeline, stage_idx: 10, stage: 'publish', name: 'CentOS')
|
|
|
|
create(:ci_build, :manual, pipeline: pipeline, stage_idx: 10, stage: 'publish', name: 'Debian')
|
|
|
|
create(:ci_build, :manual, pipeline: pipeline, stage_idx: 10, stage: 'publish', name: 'OpenSUDE')
|
|
|
|
|
|
|
|
# force to update stages statuses
|
|
|
|
Ci::ProcessPipelineService.new(pipeline).execute
|
2019-07-31 22:56:46 +05:30
|
|
|
|
|
|
|
visit_pipeline
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays play all button' do
|
|
|
|
expect(page).to have_selector('.js-stage-action')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
context 'page tabs' do
|
2019-07-07 11:18:12 +05:30
|
|
|
before do
|
|
|
|
visit_pipeline
|
|
|
|
end
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
it 'shows Pipeline, Jobs, DAG and Failed Jobs tabs with link' do
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(page).to have_link('Pipeline')
|
|
|
|
expect(page).to have_link('Jobs')
|
2021-01-29 00:20:46 +05:30
|
|
|
expect(page).to have_link('Needs')
|
2018-10-15 14:42:47 +05:30
|
|
|
expect(page).to have_link('Failed Jobs')
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows counter in Jobs tab' do
|
2022-07-23 23:45:48 +05:30
|
|
|
expect(page.find('[data-testid="builds-counter"]').text).to eq(pipeline.total_size.to_s)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
context 'without permission to access builds' do
|
|
|
|
let(:project) { create(:project, :public, :repository, public_builds: false) }
|
|
|
|
let(:role) { :guest }
|
|
|
|
|
2021-08-04 16:29:09 +05:30
|
|
|
it 'does not show the pipeline details page' do
|
|
|
|
expect(page).to have_content('Not Found')
|
2018-10-15 14:42:47 +05:30
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
describe 'test tabs' do
|
2020-07-28 23:09:34 +05:30
|
|
|
let(:pipeline) { create(:ci_pipeline, :with_test_reports, :with_report_results, project: project) }
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
before do
|
|
|
|
visit_pipeline
|
|
|
|
wait_for_requests
|
2020-07-28 23:09:34 +05:30
|
|
|
end
|
2020-04-08 14:13:33 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
context 'with test reports' do
|
|
|
|
it 'shows badge counter in Tests tab' do
|
2022-08-27 11:52:29 +05:30
|
|
|
expect(page.find('[data-testid="tests-counter"]').text).to eq(pipeline.test_report_summary.total[:count].to_s)
|
2020-07-28 23:09:34 +05:30
|
|
|
end
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
it 'calls summary.json endpoint', :js do
|
2022-08-27 11:52:29 +05:30
|
|
|
find('.gl-tab-nav-item', text: 'Tests').click
|
2020-07-28 23:09:34 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
expect(page).to have_content('Jobs')
|
2020-11-24 15:15:51 +05:30
|
|
|
expect(page).to have_selector('[data-testid="tests-detail"]', visible: :all)
|
2020-04-08 14:13:33 +05:30
|
|
|
end
|
2020-10-24 23:57:45 +05:30
|
|
|
end
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
context 'without test reports' do
|
|
|
|
let(:pipeline) { create(:ci_pipeline, project: project) }
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
it 'shows zero' do
|
2022-08-27 11:52:29 +05:30
|
|
|
expect(page.find('[data-testid="tests-counter"]', visible: :all).text).to eq("0")
|
2020-04-08 14:13:33 +05:30
|
|
|
end
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
context 'retrying jobs' do
|
2019-07-07 11:18:12 +05:30
|
|
|
before do
|
|
|
|
visit_pipeline
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
it { expect(page).not_to have_content('retried') }
|
|
|
|
|
|
|
|
context 'when retrying' do
|
2017-09-10 17:25:29 +05:30
|
|
|
before do
|
2021-01-03 14:25:43 +05:30
|
|
|
find('[data-testid="retryPipeline"]').click
|
2021-10-27 15:23:28 +05:30
|
|
|
wait_for_requests
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
it 'does not show a "Retry" button', :sidekiq_might_not_need_inline do
|
|
|
|
expect(page).not_to have_content('Retry')
|
|
|
|
end
|
2021-10-27 15:23:28 +05:30
|
|
|
|
|
|
|
it 'shows running status in pipeline header', :sidekiq_might_not_need_inline do
|
|
|
|
within('.js-pipeline-header-container') do
|
|
|
|
expect(page).to have_selector('.js-ci-status-icon-running')
|
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'canceling jobs' do
|
2019-07-07 11:18:12 +05:30
|
|
|
before do
|
|
|
|
visit_pipeline
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
it { expect(page).not_to have_selector('.ci-canceled') }
|
|
|
|
|
|
|
|
context 'when canceling' do
|
2017-09-10 17:25:29 +05:30
|
|
|
before do
|
|
|
|
click_on 'Cancel running'
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
it 'does not show a "Cancel running" button', :sidekiq_might_not_need_inline do
|
|
|
|
expect(page).not_to have_content('Cancel running')
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
context 'when user can not delete' do
|
|
|
|
before do
|
|
|
|
visit_pipeline
|
2021-09-30 23:02:18 +05:30
|
|
|
end
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
it { expect(page).not_to have_button('Delete') }
|
2021-09-30 23:02:18 +05:30
|
|
|
end
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
context 'when deleting' do
|
2021-09-30 23:02:18 +05:30
|
|
|
before do
|
2021-10-27 15:23:28 +05:30
|
|
|
group.add_owner(user)
|
|
|
|
|
|
|
|
visit_pipeline
|
|
|
|
|
|
|
|
click_button 'Delete'
|
|
|
|
click_button 'Delete pipeline'
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
2021-09-30 23:02:18 +05:30
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
it 'redirects to pipeline overview page', :sidekiq_inline do
|
|
|
|
expect(page).to have_content('The pipeline has been deleted')
|
2022-05-07 20:08:51 +05:30
|
|
|
expect(page).to have_current_path(project_pipelines_path(project), ignore_query: true)
|
2021-10-27 15:23:28 +05:30
|
|
|
end
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
context 'when pipeline ref does not exist in repository anymore' do
|
|
|
|
let(:pipeline) do
|
|
|
|
create(:ci_empty_pipeline, project: project,
|
|
|
|
ref: 'non-existent',
|
|
|
|
sha: project.commit.id,
|
|
|
|
user: user)
|
|
|
|
end
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
before do
|
|
|
|
visit_pipeline
|
|
|
|
end
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
it 'does not render link to the pipeline ref' do
|
|
|
|
expect(page).not_to have_link(pipeline.ref)
|
|
|
|
expect(page).to have_content(pipeline.ref)
|
|
|
|
end
|
2019-09-04 21:01:54 +05:30
|
|
|
|
|
|
|
it 'does not render render raw HTML to the pipeline ref' do
|
|
|
|
page.within '.pipeline-info' do
|
|
|
|
expect(page).not_to have_content('<span class="ref-name"')
|
|
|
|
end
|
|
|
|
end
|
2018-12-13 13:39:08 +05:30
|
|
|
end
|
2019-07-07 11:18:12 +05:30
|
|
|
|
|
|
|
context 'when pipeline is detached merge request pipeline' do
|
|
|
|
let(:source_project) { project }
|
|
|
|
let(:target_project) { project }
|
|
|
|
|
|
|
|
let(:merge_request) do
|
|
|
|
create(:merge_request,
|
|
|
|
:with_detached_merge_request_pipeline,
|
|
|
|
source_project: source_project,
|
|
|
|
target_project: target_project)
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:pipeline) do
|
|
|
|
merge_request.all_pipelines.last
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the pipeline information' do
|
|
|
|
visit_pipeline
|
|
|
|
|
|
|
|
within '.pipeline-info' do
|
|
|
|
expect(page).to have_content("#{pipeline.statuses.count} jobs " \
|
|
|
|
"for !#{merge_request.iid} " \
|
|
|
|
"with #{merge_request.source_branch}")
|
|
|
|
expect(page).to have_link("!#{merge_request.iid}",
|
|
|
|
href: project_merge_request_path(project, merge_request))
|
|
|
|
expect(page).to have_link(merge_request.source_branch,
|
|
|
|
href: project_commits_path(merge_request.source_project, merge_request.source_branch))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when source branch does not exist' do
|
|
|
|
before do
|
|
|
|
project.repository.rm_branch(user, merge_request.source_branch)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not link to the source branch commit path' do
|
|
|
|
visit_pipeline
|
|
|
|
|
|
|
|
within '.pipeline-info' do
|
|
|
|
expect(page).not_to have_link(merge_request.source_branch)
|
|
|
|
expect(page).to have_content(merge_request.source_branch)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when source project is a forked project' do
|
|
|
|
let(:source_project) { fork_project(project, user, repository: true) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
visit project_pipeline_path(source_project, pipeline)
|
|
|
|
end
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
it 'shows the pipeline information', :sidekiq_might_not_need_inline do
|
2019-07-07 11:18:12 +05:30
|
|
|
within '.pipeline-info' do
|
|
|
|
expect(page).to have_content("#{pipeline.statuses.count} jobs " \
|
|
|
|
"for !#{merge_request.iid} " \
|
|
|
|
"with #{merge_request.source_branch}")
|
|
|
|
expect(page).to have_link("!#{merge_request.iid}",
|
|
|
|
href: project_merge_request_path(project, merge_request))
|
|
|
|
expect(page).to have_link(merge_request.source_branch,
|
|
|
|
href: project_commits_path(merge_request.source_project, merge_request.source_branch))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when pipeline is merge request pipeline' do
|
2021-09-30 23:02:18 +05:30
|
|
|
let(:project) { create(:project, :repository, group: group) }
|
2019-07-07 11:18:12 +05:30
|
|
|
let(:source_project) { project }
|
|
|
|
let(:target_project) { project }
|
|
|
|
|
|
|
|
let(:merge_request) do
|
|
|
|
create(:merge_request,
|
|
|
|
:with_merge_request_pipeline,
|
|
|
|
source_project: source_project,
|
|
|
|
target_project: target_project,
|
|
|
|
merge_sha: project.commit.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:pipeline) do
|
|
|
|
merge_request.all_pipelines.last
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
2021-04-29 21:17:54 +05:30
|
|
|
pipeline.update!(user: user)
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the pipeline information' do
|
|
|
|
visit_pipeline
|
|
|
|
|
|
|
|
within '.pipeline-info' do
|
|
|
|
expect(page).to have_content("#{pipeline.statuses.count} jobs " \
|
|
|
|
"for !#{merge_request.iid} " \
|
|
|
|
"with #{merge_request.source_branch} " \
|
|
|
|
"into #{merge_request.target_branch}")
|
|
|
|
expect(page).to have_link("!#{merge_request.iid}",
|
|
|
|
href: project_merge_request_path(project, merge_request))
|
|
|
|
expect(page).to have_link(merge_request.source_branch,
|
|
|
|
href: project_commits_path(merge_request.source_project, merge_request.source_branch))
|
|
|
|
expect(page).to have_link(merge_request.target_branch,
|
|
|
|
href: project_commits_path(merge_request.target_project, merge_request.target_branch))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when target branch does not exist' do
|
|
|
|
before do
|
|
|
|
project.repository.rm_branch(user, merge_request.target_branch)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not link to the target branch commit path' do
|
|
|
|
visit_pipeline
|
|
|
|
|
|
|
|
within '.pipeline-info' do
|
|
|
|
expect(page).not_to have_link(merge_request.target_branch)
|
|
|
|
expect(page).to have_content(merge_request.target_branch)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when source project is a forked project' do
|
|
|
|
let(:source_project) { fork_project(project, user, repository: true) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
visit project_pipeline_path(source_project, pipeline)
|
|
|
|
end
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
it 'shows the pipeline information', :sidekiq_might_not_need_inline do
|
2019-07-07 11:18:12 +05:30
|
|
|
within '.pipeline-info' do
|
|
|
|
expect(page).to have_content("#{pipeline.statuses.count} jobs " \
|
|
|
|
"for !#{merge_request.iid} " \
|
|
|
|
"with #{merge_request.source_branch} " \
|
|
|
|
"into #{merge_request.target_branch}")
|
|
|
|
expect(page).to have_link("!#{merge_request.iid}",
|
|
|
|
href: project_merge_request_path(project, merge_request))
|
|
|
|
expect(page).to have_link(merge_request.source_branch,
|
|
|
|
href: project_commits_path(merge_request.source_project, merge_request.source_branch))
|
|
|
|
expect(page).to have_link(merge_request.target_branch,
|
|
|
|
href: project_commits_path(merge_request.target_project, merge_request.target_branch))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
context 'when user does not have access to read jobs' do
|
|
|
|
before do
|
2021-04-29 21:17:54 +05:30
|
|
|
project.update!(public_builds: false)
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
describe 'GET /:project/-/pipelines/:id' do
|
2018-03-17 18:26:18 +05:30
|
|
|
include_context 'pipeline builds'
|
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
let_it_be(:project) { create(:project, :repository) }
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id, user: user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
visit project_pipeline_path(project, pipeline)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the pipeline graph' do
|
2021-03-11 19:13:27 +05:30
|
|
|
expect(page).to have_selector('.js-pipeline-graph')
|
2022-10-11 01:57:18 +05:30
|
|
|
expect(page).to have_content('build')
|
|
|
|
expect(page).to have_content('test')
|
|
|
|
expect(page).to have_content('deploy')
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(page).to have_content('Retry')
|
|
|
|
expect(page).to have_content('Cancel running')
|
|
|
|
end
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
it 'does not link to job' do
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(page).not_to have_selector('.js-pipeline-graph-job-link')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-03-02 22:35:43 +05:30
|
|
|
context 'when a bridge job exists' do
|
|
|
|
include_context 'pipeline builds'
|
|
|
|
|
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
let(:downstream) { create(:project, :repository) }
|
|
|
|
|
|
|
|
let(:pipeline) do
|
|
|
|
create(:ci_pipeline, project: project,
|
|
|
|
ref: 'master',
|
|
|
|
sha: project.commit.id,
|
|
|
|
user: user)
|
|
|
|
end
|
|
|
|
|
|
|
|
let!(:bridge) do
|
|
|
|
create(:ci_bridge, pipeline: pipeline,
|
|
|
|
name: 'cross-build',
|
|
|
|
user: user,
|
|
|
|
downstream: downstream)
|
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
describe 'GET /:project/-/pipelines/:id' do
|
2019-03-02 22:35:43 +05:30
|
|
|
before do
|
|
|
|
visit project_pipeline_path(project, pipeline)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the pipeline with a bridge job' do
|
2021-03-11 19:13:27 +05:30
|
|
|
expect(page).to have_selector('.js-pipeline-graph')
|
2019-03-02 22:35:43 +05:30
|
|
|
expect(page).to have_content('cross-build')
|
|
|
|
end
|
2019-09-04 21:01:54 +05:30
|
|
|
|
|
|
|
context 'when a scheduled pipeline is created by a blocked user' do
|
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
|
|
|
|
let(:schedule) do
|
|
|
|
create(:ci_pipeline_schedule,
|
|
|
|
project: project,
|
2022-04-04 11:22:00 +05:30
|
|
|
owner: project.first_owner,
|
2019-09-04 21:01:54 +05:30
|
|
|
description: 'blocked user schedule'
|
|
|
|
).tap do |schedule|
|
|
|
|
schedule.update_column(:next_run_at, 1.minute.ago)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
schedule.owner.block!
|
2023-01-13 00:05:48 +05:30
|
|
|
PipelineScheduleWorker.new.perform
|
2019-09-04 21:01:54 +05:30
|
|
|
end
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
it 'displays the PipelineSchedule in an inactive state' do
|
2022-11-25 23:54:43 +05:30
|
|
|
stub_feature_flags(pipeline_schedules_vue: false)
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
visit project_pipeline_schedules_path(project)
|
2021-04-29 21:17:54 +05:30
|
|
|
page.click_link('Inactive')
|
2019-09-04 21:01:54 +05:30
|
|
|
|
|
|
|
expect(page).to have_selector('table.ci-table > tbody > tr > td', text: 'blocked user schedule')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not create a new Pipeline' do
|
|
|
|
visit project_pipelines_path(project)
|
|
|
|
|
|
|
|
expect(page).not_to have_selector('.ci-table')
|
|
|
|
expect(schedule.last_pipeline).to be_nil
|
|
|
|
end
|
|
|
|
end
|
2019-03-02 22:35:43 +05:30
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
describe 'GET /:project/-/pipelines/:id/builds' do
|
2019-03-02 22:35:43 +05:30
|
|
|
before do
|
|
|
|
visit builds_project_pipeline_path(project, pipeline)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows a bridge job on a list' do
|
|
|
|
expect(page).to have_content('cross-build')
|
|
|
|
expect(page).to have_content(bridge.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
context 'when build requires resource', :sidekiq_inline do
|
|
|
|
let_it_be(:project) { create(:project, :repository) }
|
2021-06-08 01:23:25 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
let(:pipeline) { create(:ci_pipeline, project: project) }
|
|
|
|
let(:resource_group) { create(:ci_resource_group, project: project) }
|
|
|
|
|
|
|
|
let!(:test_job) do
|
|
|
|
create(:ci_build, :pending, stage: 'test', name: 'test',
|
2022-10-11 01:57:18 +05:30
|
|
|
stage_idx: 1, pipeline: pipeline, project: project)
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
let!(:deploy_job) do
|
|
|
|
create(:ci_build, :created, stage: 'deploy', name: 'deploy',
|
2022-10-11 01:57:18 +05:30
|
|
|
stage_idx: 2, pipeline: pipeline, project: project, resource_group: resource_group)
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
describe 'GET /:project/-/pipelines/:id' do
|
2020-03-13 15:44:24 +05:30
|
|
|
subject { visit project_pipeline_path(project, pipeline) }
|
|
|
|
|
|
|
|
it 'shows deploy job as created' do
|
|
|
|
subject
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
within('.js-pipeline-header-container') do
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(page).to have_content('pending')
|
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
within('.js-pipeline-graph') do
|
|
|
|
within(all('[data-testid="stage-column"]')[0]) do
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(page).to have_content('test')
|
|
|
|
expect(page).to have_css('.ci-status-icon-pending')
|
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
within(all('[data-testid="stage-column"]')[1]) do
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(page).to have_content('deploy')
|
|
|
|
expect(page).to have_css('.ci-status-icon-created')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when test job succeeded' do
|
|
|
|
before do
|
|
|
|
test_job.success!
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows deploy job as pending' do
|
|
|
|
subject
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
within('.js-pipeline-header-container') do
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(page).to have_content('running')
|
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
within('.js-pipeline-graph') do
|
|
|
|
within(all('[data-testid="stage-column"]')[0]) do
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(page).to have_content('test')
|
|
|
|
expect(page).to have_css('.ci-status-icon-success')
|
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
within(all('[data-testid="stage-column"]')[1]) do
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(page).to have_content('deploy')
|
|
|
|
expect(page).to have_css('.ci-status-icon-pending')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when test job succeeded but there are no available resources' do
|
|
|
|
let(:another_job) { create(:ci_build, :running, project: project, resource_group: resource_group) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
resource_group.assign_resource_to(another_job)
|
|
|
|
test_job.success!
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows deploy job as waiting for resource' do
|
|
|
|
subject
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
within('.js-pipeline-header-container') do
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(page).to have_content('waiting')
|
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
within('.js-pipeline-graph') do
|
|
|
|
within(all('[data-testid="stage-column"]')[1]) do
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(page).to have_content('deploy')
|
|
|
|
expect(page).to have_css('.ci-status-icon-waiting-for-resource')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when resource is released from another job' do
|
|
|
|
before do
|
|
|
|
another_job.success!
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows deploy job as pending' do
|
|
|
|
subject
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
within('.js-pipeline-header-container') do
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(page).to have_content('running')
|
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
within('.js-pipeline-graph') do
|
|
|
|
within(all('[data-testid="stage-column"]')[1]) do
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(page).to have_content('deploy')
|
|
|
|
expect(page).to have_css('.ci-status-icon-pending')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-03-11 19:13:27 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'when deploy job is a bridge to trigger a downstream pipeline' do
|
|
|
|
let!(:deploy_job) do
|
2022-10-11 01:57:18 +05:30
|
|
|
create(:ci_bridge, :created,
|
|
|
|
stage: 'deploy',
|
|
|
|
name: 'deploy',
|
|
|
|
stage_idx: 2,
|
|
|
|
pipeline: pipeline,
|
|
|
|
project: project,
|
|
|
|
resource_group: resource_group
|
|
|
|
)
|
2021-03-11 19:13:27 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows deploy job as waiting for resource' do
|
|
|
|
subject
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
within('.js-pipeline-header-container') do
|
2021-03-11 19:13:27 +05:30
|
|
|
expect(page).to have_content('waiting')
|
|
|
|
end
|
|
|
|
|
|
|
|
within('.js-pipeline-graph') do
|
|
|
|
within(all('[data-testid="stage-column"]')[1]) do
|
|
|
|
expect(page).to have_content('deploy')
|
|
|
|
expect(page).to have_css('.ci-status-icon-waiting-for-resource')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
describe 'GET /:project/-/pipelines/:id/builds' do
|
2022-03-02 08:16:31 +05:30
|
|
|
include_context 'pipeline builds'
|
|
|
|
|
|
|
|
let_it_be(:project) { create(:project, :repository) }
|
|
|
|
|
|
|
|
let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
visit builds_project_pipeline_path(project, pipeline)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows a list of jobs' do
|
|
|
|
expect(page).to have_content('Test')
|
|
|
|
expect(page).to have_content(build_passed.id)
|
|
|
|
expect(page).to have_content('Deploy')
|
|
|
|
expect(page).to have_content(build_failed.id)
|
|
|
|
expect(page).to have_content(build_running.id)
|
|
|
|
expect(page).to have_content(build_external.id)
|
|
|
|
expect(page).to have_content('Retry')
|
|
|
|
expect(page).to have_content('Cancel running')
|
|
|
|
expect(page).to have_button('Play')
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'page tabs' do
|
|
|
|
it 'shows Pipeline, Jobs and DAG tabs with link' do
|
|
|
|
expect(page).to have_link('Pipeline')
|
|
|
|
expect(page).to have_link('Jobs')
|
|
|
|
expect(page).to have_link('Needs')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows counter in Jobs tab' do
|
2022-07-23 23:45:48 +05:30
|
|
|
expect(page.find('[data-testid="builds-counter"]').text).to eq(pipeline.total_size.to_s)
|
2022-03-02 08:16:31 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'retrying jobs' do
|
|
|
|
it { expect(page).not_to have_content('retried') }
|
|
|
|
|
|
|
|
context 'when retrying' do
|
|
|
|
before do
|
|
|
|
find('[data-testid="retry"]', match: :first).click
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show a "Retry" button', :sidekiq_might_not_need_inline do
|
|
|
|
expect(page).not_to have_content('Retry')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'canceling jobs' do
|
|
|
|
it { expect(page).not_to have_selector('.ci-canceled') }
|
|
|
|
|
|
|
|
context 'when canceling' do
|
|
|
|
before do
|
|
|
|
click_on 'Cancel running'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show a "Cancel running" button', :sidekiq_might_not_need_inline do
|
|
|
|
expect(page).not_to have_content('Cancel running')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'playing manual job' do
|
|
|
|
before do
|
|
|
|
within '[data-testid="jobs-tab-table"]' do
|
|
|
|
click_button('Play')
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(build_manual.reload).to be_pending }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user unschedules a delayed job' do
|
|
|
|
before do
|
|
|
|
within '[data-testid="jobs-tab-table"]' do
|
|
|
|
click_button('Unschedule')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'unschedules the delayed job and shows play button as a manual job' do
|
|
|
|
expect(page).to have_button('Play')
|
|
|
|
expect(page).not_to have_button('Unschedule')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
describe 'GET /:project/-/pipelines/:id/failures' do
|
2018-10-15 14:42:47 +05:30
|
|
|
let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: '1234') }
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:pipeline_failures_page) { failures_project_pipeline_path(project, pipeline) }
|
2017-08-17 22:00:37 +05:30
|
|
|
let!(:failed_build) { create(:ci_build, :failed, pipeline: pipeline) }
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
subject { visit pipeline_failures_page }
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
context 'with failed build' do
|
|
|
|
before do
|
|
|
|
failed_build.trace.set('4 examples, 1 failure')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'lists failed builds' do
|
2018-12-13 13:39:08 +05:30
|
|
|
subject
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(page).to have_content(failed_build.name)
|
2022-10-11 01:57:18 +05:30
|
|
|
expect(page).to have_content(failed_build.stage_name)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows build failure logs' do
|
2018-12-13 13:39:08 +05:30
|
|
|
subject
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(page).to have_content('4 examples, 1 failure')
|
|
|
|
end
|
2018-11-08 19:23:39 +05:30
|
|
|
|
|
|
|
it 'shows the failure reason' do
|
2018-12-13 13:39:08 +05:30
|
|
|
subject
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
expect(page).to have_content('There is an unknown failure, please try again')
|
|
|
|
end
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
context 'when user does not have permission to retry build' do
|
|
|
|
it 'shows retry button for failed build' do
|
|
|
|
subject
|
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
page.within(find('[data-testid="tab-failures"]', match: :first)) do
|
2022-07-16 23:28:13 +05:30
|
|
|
expect(page).not_to have_button('Retry')
|
2018-12-13 13:39:08 +05:30
|
|
|
end
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
context 'when user does have permission to retry build' do
|
|
|
|
before do
|
|
|
|
create(:protected_branch, :developers_can_merge,
|
|
|
|
name: pipeline.ref, project: project)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows retry button for failed build' do
|
|
|
|
subject
|
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
page.within(find('[data-testid="tab-failures"]', match: :first)) do
|
2022-07-16 23:28:13 +05:30
|
|
|
expect(page).to have_button('Retry')
|
2018-12-13 13:39:08 +05:30
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2018-12-13 13:39:08 +05:30
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
context 'when missing build logs' do
|
2018-10-15 14:42:47 +05:30
|
|
|
it 'lists failed builds' do
|
2018-12-13 13:39:08 +05:30
|
|
|
subject
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
expect(page).to have_content(failed_build.name)
|
2022-10-11 01:57:18 +05:30
|
|
|
expect(page).to have_content(failed_build.stage_name)
|
2018-10-15 14:42:47 +05:30
|
|
|
end
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
it 'does not show log' do
|
2018-12-13 13:39:08 +05:30
|
|
|
subject
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
expect(page).to have_content('No job log')
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
context 'without permission to access builds' do
|
|
|
|
let(:role) { :guest }
|
|
|
|
|
|
|
|
before do
|
2021-04-29 21:17:54 +05:30
|
|
|
project.update!(public_builds: false)
|
2018-10-15 14:42:47 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'when accessing failed jobs page' do
|
2019-03-02 22:35:43 +05:30
|
|
|
it 'renders a 404 page' do
|
|
|
|
requests = inspect_requests { subject }
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2019-03-02 22:35:43 +05:30
|
|
|
expect(page).to have_title('Not Found')
|
|
|
|
expect(requests.first.status_code).to eq(404)
|
2018-10-15 14:42:47 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
context 'without failures' do
|
|
|
|
before do
|
|
|
|
failed_build.update!(status: :success)
|
|
|
|
end
|
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
it 'does not show the failure tab' do
|
|
|
|
subject
|
|
|
|
|
|
|
|
expect(page).not_to have_content('Failed Jobs')
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
it 'displays the pipeline graph' do
|
2018-12-13 13:39:08 +05:30
|
|
|
subject
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
expect(page).to have_current_path(pipeline_path(pipeline))
|
2021-03-11 19:13:27 +05:30
|
|
|
expect(page).to have_selector('.js-pipeline-graph')
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
2019-02-15 15:39:39 +05:30
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
describe 'GET /:project/-/pipelines/latest' do
|
|
|
|
let_it_be(:project) { create(:project, :repository) }
|
|
|
|
|
|
|
|
let!(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
visit latest_project_pipelines_path(project)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays the pipeline graph with correct URL' do
|
|
|
|
expect(page).to have_current_path("#{pipeline_path(pipeline)}/")
|
|
|
|
expect(page).to have_selector('.js-pipeline-graph')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
describe 'GET /:project/-/pipelines/:id/dag' do
|
2020-05-24 23:13:21 +05:30
|
|
|
include_context 'pipeline builds'
|
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
let_it_be(:project) { create(:project, :repository) }
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
visit dag_project_pipeline_path(project, pipeline)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'page tabs' do
|
|
|
|
it 'shows Pipeline, Jobs and DAG tabs with link' do
|
|
|
|
expect(page).to have_link('Pipeline')
|
|
|
|
expect(page).to have_link('Jobs')
|
2022-07-16 23:28:13 +05:30
|
|
|
expect(page).to have_link('Needs')
|
2020-05-24 23:13:21 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
context 'when user sees pipeline flags in a pipeline detail page' do
|
2021-09-30 23:02:18 +05:30
|
|
|
let_it_be(:project) { create(:project, :repository) }
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
context 'when pipeline is latest' do
|
|
|
|
include_context 'pipeline builds'
|
|
|
|
|
|
|
|
let(:pipeline) do
|
|
|
|
create(:ci_pipeline,
|
|
|
|
project: project,
|
|
|
|
ref: 'master',
|
|
|
|
sha: project.commit.id,
|
|
|
|
user: user)
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
visit project_pipeline_path(project, pipeline)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains badge that indicates it is the latest build' do
|
|
|
|
page.within(all('.well-segment')[1]) do
|
|
|
|
expect(page).to have_content 'latest'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when pipeline has configuration errors' do
|
|
|
|
let(:pipeline) do
|
|
|
|
create(:ci_pipeline,
|
|
|
|
:invalid,
|
|
|
|
project: project,
|
|
|
|
ref: 'master',
|
|
|
|
sha: project.commit.id,
|
|
|
|
user: user)
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
visit project_pipeline_path(project, pipeline)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains badge that indicates errors' do
|
|
|
|
page.within(all('.well-segment')[1]) do
|
|
|
|
expect(page).to have_content 'yaml invalid'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains badge with tooltip which contains error' do
|
|
|
|
expect(pipeline).to have_yaml_errors
|
|
|
|
|
|
|
|
page.within(all('.well-segment')[1]) do
|
|
|
|
expect(page).to have_selector(
|
|
|
|
%Q{span[title="#{pipeline.yaml_errors}"]})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains badge that indicates failure reason' do
|
|
|
|
expect(page).to have_content 'error'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains badge with tooltip which contains failure reason' do
|
|
|
|
expect(pipeline.failure_reason?).to eq true
|
|
|
|
|
|
|
|
page.within(all('.well-segment')[1]) do
|
|
|
|
expect(page).to have_selector(
|
|
|
|
%Q{span[title="#{pipeline.present.failure_reason}"]})
|
|
|
|
end
|
|
|
|
end
|
2020-04-08 14:13:33 +05:30
|
|
|
|
|
|
|
it 'contains a pipeline header with title' do
|
|
|
|
expect(page).to have_content "Pipeline ##{pipeline.id}"
|
|
|
|
end
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'when pipeline is stuck' do
|
|
|
|
include_context 'pipeline builds'
|
|
|
|
|
|
|
|
let(:pipeline) do
|
|
|
|
create(:ci_pipeline,
|
|
|
|
project: project,
|
|
|
|
ref: 'master',
|
|
|
|
sha: project.commit.id,
|
|
|
|
user: user)
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
create(:ci_build, :pending, pipeline: pipeline)
|
|
|
|
visit project_pipeline_path(project, pipeline)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains badge that indicates being stuck' do
|
|
|
|
page.within(all('.well-segment')[1]) do
|
|
|
|
expect(page).to have_content 'stuck'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when pipeline uses auto devops' do
|
|
|
|
include_context 'pipeline builds'
|
|
|
|
|
|
|
|
let(:project) { create(:project, :repository, auto_devops_attributes: { enabled: true }) }
|
|
|
|
let(:pipeline) do
|
|
|
|
create(:ci_pipeline,
|
|
|
|
:auto_devops_source,
|
|
|
|
project: project,
|
|
|
|
ref: 'master',
|
|
|
|
sha: project.commit.id,
|
|
|
|
user: user)
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
visit project_pipeline_path(project, pipeline)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains badge that indicates using auto devops' do
|
|
|
|
page.within(all('.well-segment')[1]) do
|
|
|
|
expect(page).to have_content 'Auto DevOps'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when pipeline runs in a merge request context' do
|
|
|
|
include_context 'pipeline builds'
|
|
|
|
|
|
|
|
let(:pipeline) do
|
|
|
|
create(:ci_pipeline,
|
2019-07-07 11:18:12 +05:30
|
|
|
source: :merge_request_event,
|
2019-02-15 15:39:39 +05:30
|
|
|
project: merge_request.source_project,
|
|
|
|
ref: 'feature',
|
|
|
|
sha: merge_request.diff_head_sha,
|
|
|
|
user: user,
|
|
|
|
merge_request: merge_request)
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:merge_request) do
|
|
|
|
create(:merge_request,
|
|
|
|
source_project: project,
|
|
|
|
source_branch: 'feature',
|
|
|
|
target_project: project,
|
|
|
|
target_branch: 'master')
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
visit project_pipeline_path(project, pipeline)
|
|
|
|
end
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
it 'contains badge that indicates detached merge request pipeline' do
|
2019-02-15 15:39:39 +05:30
|
|
|
page.within(all('.well-segment')[1]) do
|
2022-05-07 20:08:51 +05:30
|
|
|
expect(page).to have_content 'merge request'
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|