Commit f46abd4c authored by Dave Pisek's avatar Dave Pisek

Hide job-link in DL-failure-alert if no jobPath

If a job for the dependency-list generation fails, and the result
does not contain a path to the job the alert on the client-side
should not contain a button.

This commit adds a check to make sure the button within the alert
only shows if it receivs a 'jobPath' property.
parent 796624ed
......@@ -12,7 +12,8 @@ export default {
props: {
jobPath: {
type: String,
required: true,
required: false,
default: '',
},
},
data() {
......@@ -36,7 +37,7 @@ export default {
v-on="$listeners"
>
<p v-html="message"></p>
<gl-button :href="jobPath" class="btn-inverted btn-danger mb-2">
<gl-button v-if="jobPath" :href="jobPath" class="btn-inverted btn-danger mb-2">
{{ __('View job') }}
</gl-button>
</dependency-list-alert>
......
---
title: Dependency List Job Failed Alert - Hide link to job if payload from API does
not include 'job_path'
merge_request: 15068
author:
type: changed
import { createLocalVue, shallowMount } from '@vue/test-utils';
import { GlButton } from '@gitlab/ui';
import DependencyListAlert from 'ee/dependencies/components/dependency_list_alert.vue';
import DependencyListJobFailedAlert from 'ee/dependencies/components/dependency_list_job_failed_alert.vue';
......@@ -24,6 +25,27 @@ describe('DependencyListJobFailedAlert component', () => {
expect(wrapper.element).toMatchSnapshot();
});
it('inludes a button button if "jobPath" is given', () => {
factory({ propsData: { jobPath: '/jobs/foo/3210' } });
expect(wrapper.find(GlButton).exists()).toBe(true);
});
it('does not include a button if "jobPath" is not given', () => {
factory();
expect(wrapper.find(GlButton).exists()).toBe(false);
});
it.each([undefined, null, ''])(
'does not include a button if "jobPath" is given but empty',
jobPath => {
factory({ propsData: { jobPath } });
expect(wrapper.find(GlButton).exists()).toBe(false);
},
);
describe('when the generic alert component emits a close event', () => {
let closeListenerSpy;
......
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