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');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render user information when a user is provided', () => {
|
|
|
|
const mockData = {
|
|
|
|
pipeline: {
|
|
|
|
id: 1,
|
|
|
|
path: 'foo',
|
|
|
|
flags: {},
|
|
|
|
user: {
|
|
|
|
web_url: '/',
|
|
|
|
name: 'foo',
|
|
|
|
avatar_url: '/',
|
2017-09-10 17:25:29 +05:30
|
|
|
path: '/',
|
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
|
|
|
};
|
|
|
|
|
|
|
|
const component = new PipelineUrlComponent({
|
|
|
|
propsData: mockData,
|
|
|
|
}).$mount();
|
|
|
|
|
|
|
|
const image = component.$el.querySelector('.js-pipeline-url-user img');
|
2018-12-13 13:39:08 +05:30
|
|
|
const tooltip = component.$el.querySelector(
|
|
|
|
'.js-pipeline-url-user .js-user-avatar-image-toolip',
|
|
|
|
);
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
expect(component.$el.querySelector('.js-pipeline-url-user').getAttribute('href')).toEqual(
|
|
|
|
mockData.pipeline.user.web_url,
|
|
|
|
);
|
2018-12-13 13:39:08 +05:30
|
|
|
|
|
|
|
expect(tooltip.textContent.trim()).toEqual(mockData.pipeline.user.name);
|
2018-11-18 11:00:15 +05:30
|
|
|
expect(image.getAttribute('src')).toEqual(`${mockData.pipeline.user.avatar_url}?width=20`);
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('should render "API" when no user is provided', () => {
|
|
|
|
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();
|
|
|
|
|
|
|
|
expect(component.$el.querySelector('.js-pipeline-url-api').textContent).toContain('API');
|
|
|
|
});
|
|
|
|
|
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-05-18 00:54:41 +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-05-18 00:54:41 +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
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(component.$el.querySelector('.js-pipeline-url-stuck').textContent).toContain('stuck');
|
2019-05-18 00:54:41 +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
|
|
|
});
|