Commit 61cb27b0 authored by Filipa Lacerda's avatar Filipa Lacerda Committed by Steve Azzopardi

Fixes empty block in MR widget

This commit prevents the pipeline block to be rendered
when no pipeline information is provided
parent 224c1462
......@@ -94,8 +94,8 @@ export default {
</script>
<template>
<div v-if="hasPipeline || hasCIError" class="ci-widget media js-ci-widget">
<template v-if="hasCIError">
<div class="ci-widget media js-ci-widget">
<template v-if="!hasPipeline || hasCIError">
<div
class="add-border ci-status-icon ci-status-icon-failed ci-error js-ci-error append-right-default"
>
......
---
title: Fix empty block in MR widget when user doesn't have permission
merge_request: 27462
author:
type: fixed
......@@ -670,4 +670,26 @@ describe 'Merge request > User sees merge widget', :js do
end
end
end
context 'when MR has pipeline but user does not have permission' do
let(:sha) { project.commit(merge_request.source_branch).sha }
let!(:pipeline) { create(:ci_pipeline_without_jobs, status: 'success', sha: sha, project: project, ref: merge_request.source_branch) }
before do
project.update(
visibility_level: Gitlab::VisibilityLevel::PUBLIC,
public_builds: false
)
merge_request.update!(head_pipeline: pipeline)
sign_out(:user)
visit project_merge_request_path(project, merge_request)
end
it 'renders a CI pipeline error' do
within '.ci-widget' do
expect(page).to have_content('Could not retrieve the pipeline status.')
end
end
end
end
......@@ -78,6 +78,19 @@ describe('MRWidgetPipeline', () => {
);
});
it('should render CI error when no pipeline is provided', () => {
vm = mountComponent(Component, {
pipeline: {},
hasCi: true,
ciStatus: 'success',
troubleshootingDocsPath: 'help',
});
expect(vm.$el.querySelector('.media-body').textContent.trim()).toContain(
'Could not retrieve the pipeline status. For troubleshooting steps, read the documentation.',
);
});
describe('with a pipeline', () => {
beforeEach(() => {
vm = mountComponent(Component, {
......
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