debian-mirror-gitlab/spec/javascripts/pipelines/pipeline_url_spec.js

119 lines
3.1 KiB
JavaScript
Raw Normal View History

2017-08-17 22:00:37 +05:30
import Vue from 'vue';
2017-09-10 17:25:29 +05:30
import pipelineUrlComp from '~/pipelines/components/pipeline_url.vue';
2017-08-17 22:00:37 +05:30
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: {},
},
2018-03-17 18:26:18 +05:30
autoDevopsHelpPath: 'foo',
2017-08-17 22:00:37 +05:30
},
}).$mount();
2017-09-10 17:25:29 +05:30
expect(component.$el.getAttribute('class')).toContain('table-section');
2017-08-17 22:00:37 +05:30
});
it('should render a link the provided path and id', () => {
const component = new PipelineUrlComponent({
propsData: {
pipeline: {
id: 1,
path: 'foo',
flags: {},
},
2018-03-17 18:26:18 +05:30
autoDevopsHelpPath: 'foo',
2017-08-17 22:00:37 +05:30
},
}).$mount();
2018-11-18 11:00:15 +05:30
expect(component.$el.querySelector('.js-pipeline-url-link').getAttribute('href')).toEqual(
'foo',
);
2018-12-13 13:39:08 +05:30
2017-08-17 22:00:37 +05:30
expect(component.$el.querySelector('.js-pipeline-url-link span').textContent).toEqual('#1');
});
2019-02-15 15:39:39 +05:30
it('should render latest, yaml invalid, merge request, and stuck flags when provided', () => {
2017-08-17 22:00:37 +05:30
const component = new PipelineUrlComponent({
propsData: {
pipeline: {
id: 1,
path: 'foo',
flags: {
latest: true,
yaml_errors: true,
stuck: true,
2019-07-07 11:18:12 +05:30
merge_request_pipeline: true,
detached_merge_request_pipeline: true,
2017-08-17 22:00:37 +05:30
},
},
2018-03-17 18:26:18 +05:30
autoDevopsHelpPath: 'foo',
2017-08-17 22:00:37 +05:30
},
}).$mount();
2017-09-10 17:25:29 +05:30
expect(component.$el.querySelector('.js-pipeline-url-latest').textContent).toContain('latest');
2019-07-07 11:18:12 +05:30
2018-11-18 11:00:15 +05:30
expect(component.$el.querySelector('.js-pipeline-url-yaml').textContent).toContain(
'yaml invalid',
);
2018-12-13 13:39:08 +05:30
2019-05-30 16:15:17 +05:30
expect(component.$el.querySelector('.js-pipeline-url-stuck').textContent).toContain('stuck');
2019-07-07 11:18:12 +05:30
expect(component.$el.querySelector('.js-pipeline-url-detached').textContent).toContain(
'detached',
);
2017-08-17 22:00:37 +05:30
});
2018-03-17 18:26:18 +05:30
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,
},
},
autoDevopsHelpPath: 'foo',
},
}).$mount();
2018-11-18 11:00:15 +05:30
expect(component.$el.querySelector('.js-pipeline-url-autodevops').textContent.trim()).toEqual(
'Auto DevOps',
);
2018-03-17 18:26:18 +05:30
});
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,
},
failure_reason: 'some reason',
},
autoDevopsHelpPath: 'foo',
},
}).$mount();
expect(component.$el.querySelector('.js-pipeline-url-failure').textContent).toContain('error');
2018-11-18 11:00:15 +05:30
expect(
component.$el.querySelector('.js-pipeline-url-failure').getAttribute('data-original-title'),
).toContain('some reason');
2018-03-17 18:26:18 +05:30
});
2017-08-17 22:00:37 +05:30
});