2017-03-17 13:30:32 -04:00
|
|
|
import Vue from 'vue';
|
2017-05-29 06:02:06 -04:00
|
|
|
import pipelineUrlComp from '~/pipelines/components/pipeline_url.vue';
|
2017-03-17 13:30:32 -04:00
|
|
|
|
|
|
|
describe('Pipeline Url Component', () => {
|
|
|
|
let PipelineUrlComponent;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
PipelineUrlComponent = Vue.extend(pipelineUrlComp);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render a table cell', () => {
|
|
|
|
const component = new PipelineUrlComponent({
|
|
|
|
propsData: {
|
|
|
|
pipeline: {
|
|
|
|
id: 1,
|
|
|
|
path: 'foo',
|
|
|
|
flags: {},
|
|
|
|
},
|
2017-09-01 06:20:14 -04:00
|
|
|
autoDevopsHelpPath: 'foo',
|
2017-03-17 13:30:32 -04:00
|
|
|
},
|
|
|
|
}).$mount();
|
|
|
|
|
2017-06-16 08:00:28 -04:00
|
|
|
expect(component.$el.getAttribute('class')).toContain('table-section');
|
2017-03-17 13:30:32 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should render a link the provided path and id', () => {
|
|
|
|
const component = new PipelineUrlComponent({
|
|
|
|
propsData: {
|
|
|
|
pipeline: {
|
|
|
|
id: 1,
|
|
|
|
path: 'foo',
|
|
|
|
flags: {},
|
|
|
|
},
|
2017-09-01 06:20:14 -04:00
|
|
|
autoDevopsHelpPath: 'foo',
|
2017-03-17 13:30:32 -04:00
|
|
|
},
|
|
|
|
}).$mount();
|
|
|
|
|
2018-08-07 02:04:33 -04:00
|
|
|
expect(component.$el.querySelector('.js-pipeline-url-link').getAttribute('href')).toEqual(
|
|
|
|
'foo',
|
|
|
|
);
|
2018-10-09 14:03:09 -04:00
|
|
|
|
2017-03-17 13:30:32 -04:00
|
|
|
expect(component.$el.querySelector('.js-pipeline-url-link span').textContent).toEqual('#1');
|
|
|
|
});
|
|
|
|
|
2018-12-05 16:36:18 -05:00
|
|
|
it('should render latest, yaml invalid, merge request, and stuck flags when provided', () => {
|
2017-03-17 13:30:32 -04:00
|
|
|
const component = new PipelineUrlComponent({
|
|
|
|
propsData: {
|
|
|
|
pipeline: {
|
|
|
|
id: 1,
|
|
|
|
path: 'foo',
|
|
|
|
flags: {
|
|
|
|
latest: true,
|
|
|
|
yaml_errors: true,
|
|
|
|
stuck: true,
|
2019-03-20 11:39:27 -04:00
|
|
|
merge_request_pipeline: true,
|
|
|
|
detached_merge_request_pipeline: true,
|
2017-03-17 13:30:32 -04:00
|
|
|
},
|
|
|
|
},
|
2017-09-01 06:20:14 -04:00
|
|
|
autoDevopsHelpPath: 'foo',
|
2017-03-17 13:30:32 -04:00
|
|
|
},
|
|
|
|
}).$mount();
|
|
|
|
|
2017-06-16 08:00:28 -04:00
|
|
|
expect(component.$el.querySelector('.js-pipeline-url-latest').textContent).toContain('latest');
|
2019-03-20 11:39:27 -04:00
|
|
|
|
2018-08-07 02:04:33 -04:00
|
|
|
expect(component.$el.querySelector('.js-pipeline-url-yaml').textContent).toContain(
|
|
|
|
'yaml invalid',
|
|
|
|
);
|
2018-10-09 14:03:09 -04:00
|
|
|
|
2017-03-17 13:30:32 -04:00
|
|
|
expect(component.$el.querySelector('.js-pipeline-url-stuck').textContent).toContain('stuck');
|
2019-03-20 11:39:27 -04:00
|
|
|
|
|
|
|
expect(component.$el.querySelector('.js-pipeline-url-detached').textContent).toContain(
|
|
|
|
'detached',
|
|
|
|
);
|
2017-03-17 13:30:32 -04:00
|
|
|
});
|
2017-09-01 05:46:08 -04:00
|
|
|
|
|
|
|
it('should render a badge for autodevops', () => {
|
|
|
|
const component = new PipelineUrlComponent({
|
|
|
|
propsData: {
|
|
|
|
pipeline: {
|
|
|
|
id: 1,
|
|
|
|
path: 'foo',
|
|
|
|
flags: {
|
|
|
|
latest: true,
|
|
|
|
yaml_errors: true,
|
|
|
|
stuck: true,
|
|
|
|
auto_devops: true,
|
|
|
|
},
|
|
|
|
},
|
2017-09-01 06:20:14 -04:00
|
|
|
autoDevopsHelpPath: 'foo',
|
2017-09-01 05:46:08 -04:00
|
|
|
},
|
|
|
|
}).$mount();
|
|
|
|
|
2018-08-07 02:04:33 -04:00
|
|
|
expect(component.$el.querySelector('.js-pipeline-url-autodevops').textContent.trim()).toEqual(
|
|
|
|
'Auto DevOps',
|
|
|
|
);
|
2017-09-01 05:46:08 -04:00
|
|
|
});
|
2017-10-04 03:32:22 -04:00
|
|
|
|
|
|
|
it('should render error badge when pipeline has a failure reason set', () => {
|
|
|
|
const component = new PipelineUrlComponent({
|
|
|
|
propsData: {
|
|
|
|
pipeline: {
|
|
|
|
id: 1,
|
|
|
|
path: 'foo',
|
|
|
|
flags: {
|
|
|
|
failure_reason: true,
|
|
|
|
},
|
2017-10-04 05:02:52 -04:00
|
|
|
failure_reason: 'some reason',
|
2017-10-04 03:32:22 -04:00
|
|
|
},
|
2017-10-04 05:02:52 -04:00
|
|
|
autoDevopsHelpPath: 'foo',
|
2017-10-04 03:32:22 -04:00
|
|
|
},
|
|
|
|
}).$mount();
|
|
|
|
|
|
|
|
expect(component.$el.querySelector('.js-pipeline-url-failure').textContent).toContain('error');
|
2018-08-07 02:04:33 -04:00
|
|
|
expect(
|
|
|
|
component.$el.querySelector('.js-pipeline-url-failure').getAttribute('data-original-title'),
|
|
|
|
).toContain('some reason');
|
2017-10-04 03:32:22 -04:00
|
|
|
});
|
2017-03-17 13:30:32 -04:00
|
|
|
});
|