Commit 79fc65c0 authored by Fabio Huser's avatar Fabio Huser Committed by Paul Slaughter

Fix pipeline details page initialization on invalid pipeline

https://gitlab.com/gitlab-org/gitlab/-/merge_requests/25302
parent 94b807e2
...@@ -13,19 +13,21 @@ export default () => { ...@@ -13,19 +13,21 @@ export default () => {
}); });
} }
const pipelineTabLink = document.querySelector('.js-pipeline-tab-link a');
const { controllerAction } = document.querySelector('.js-pipeline-container').dataset; const { controllerAction } = document.querySelector('.js-pipeline-container').dataset;
const pipelineStatusUrl = `${document
.querySelector('.js-pipeline-tab-link a')
.getAttribute('href')}/status.json`;
// eslint-disable-next-line no-new if (pipelineTabLink) {
new Pipelines({ const pipelineStatusUrl = `${pipelineTabLink.getAttribute('href')}/status.json`;
initTabs: true,
pipelineStatusUrl, // eslint-disable-next-line no-new
tabsOptions: { new Pipelines({
action: controllerAction, initTabs: true,
defaultAction: 'pipelines', pipelineStatusUrl,
parentEl: '.pipelines-tabs', tabsOptions: {
}, action: controllerAction,
}); defaultAction: 'pipelines',
parentEl: '.pipelines-tabs',
},
});
}
}; };
...@@ -95,14 +95,14 @@ export default () => { ...@@ -95,14 +95,14 @@ export default () => {
}, },
}); });
const tabsElement = document.querySelector('.pipelines-tabs');
const testReportsEnabled = const testReportsEnabled =
window.gon && window.gon.features && window.gon.features.junitPipelineView; window.gon && window.gon.features && window.gon.features.junitPipelineView;
if (testReportsEnabled) { if (tabsElement && testReportsEnabled) {
const fetchReportsAction = 'fetchReports'; const fetchReportsAction = 'fetchReports';
testReportsStore.dispatch('setEndpoint', dataset.testReportEndpoint); testReportsStore.dispatch('setEndpoint', dataset.testReportEndpoint);
const tabsElmement = document.querySelector('.pipelines-tabs');
const isTestTabActive = Boolean( const isTestTabActive = Boolean(
document.querySelector('.pipelines-tabs > li > a.test-tab.active'), document.querySelector('.pipelines-tabs > li > a.test-tab.active'),
); );
...@@ -113,11 +113,11 @@ export default () => { ...@@ -113,11 +113,11 @@ export default () => {
const tabClickHandler = e => { const tabClickHandler = e => {
if (e.target.className === 'test-tab') { if (e.target.className === 'test-tab') {
testReportsStore.dispatch(fetchReportsAction); testReportsStore.dispatch(fetchReportsAction);
tabsElmement.removeEventListener('click', tabClickHandler); tabsElement.removeEventListener('click', tabClickHandler);
} }
}; };
tabsElmement.addEventListener('click', tabClickHandler); tabsElement.addEventListener('click', tabClickHandler);
} }
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
......
---
title: Fix pipeline details page initialisation on invalid pipeline
merge_request: 25302
author: Fabio Huser
type: fixed
...@@ -22,6 +22,7 @@ FactoryBot.define do ...@@ -22,6 +22,7 @@ FactoryBot.define do
factory :ci_pipeline do factory :ci_pipeline do
trait :invalid do trait :invalid do
status { :failed }
yaml_errors { 'invalid YAML' } yaml_errors { 'invalid YAML' }
failure_reason { :config_error } failure_reason { :config_error }
end end
......
...@@ -1077,8 +1077,6 @@ describe 'Pipeline', :js do ...@@ -1077,8 +1077,6 @@ describe 'Pipeline', :js do
end end
context 'when pipeline has configuration errors' do context 'when pipeline has configuration errors' do
include_context 'pipeline builds'
let(:pipeline) do let(:pipeline) do
create(:ci_pipeline, create(:ci_pipeline,
:invalid, :invalid,
...@@ -1119,6 +1117,10 @@ describe 'Pipeline', :js do ...@@ -1119,6 +1117,10 @@ describe 'Pipeline', :js do
%Q{span[title="#{pipeline.present.failure_reason}"]}) %Q{span[title="#{pipeline.present.failure_reason}"]})
end end
end end
it 'contains a pipeline header with title' do
expect(page).to have_content "Pipeline ##{pipeline.id}"
end
end end
context 'when pipeline is stuck' do context 'when pipeline is stuck' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment