2017-05-06 17:02:06 +00:00
|
|
|
import Vue from 'vue';
|
|
|
|
import jobComponent from '~/pipelines/components/graph/job_component.vue';
|
2018-02-26 19:43:34 +00:00
|
|
|
import mountComponent from 'spec/helpers/vue_mount_component_helper';
|
2017-05-06 17:02:06 +00:00
|
|
|
|
|
|
|
describe('pipeline graph job component', () => {
|
|
|
|
let JobComponent;
|
2017-12-04 15:18:23 +00:00
|
|
|
let component;
|
2017-05-06 17:02:06 +00:00
|
|
|
|
|
|
|
const mockJob = {
|
|
|
|
id: 4256,
|
|
|
|
name: 'test',
|
|
|
|
status: {
|
|
|
|
icon: 'icon_status_success',
|
|
|
|
text: 'passed',
|
|
|
|
label: 'passed',
|
|
|
|
group: 'success',
|
|
|
|
details_path: '/root/ci-mock/builds/4256',
|
2017-12-04 15:18:23 +00:00
|
|
|
has_details: true,
|
2017-05-06 17:02:06 +00:00
|
|
|
action: {
|
2017-10-05 21:16:37 +00:00
|
|
|
icon: 'retry',
|
2017-05-06 17:02:06 +00:00
|
|
|
title: 'Retry',
|
|
|
|
path: '/root/ci-mock/builds/4256/retry',
|
|
|
|
method: 'post',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
JobComponent = Vue.extend(jobComponent);
|
|
|
|
});
|
|
|
|
|
2017-12-04 15:18:23 +00:00
|
|
|
afterEach(() => {
|
|
|
|
component.$destroy();
|
|
|
|
});
|
|
|
|
|
2017-05-06 17:02:06 +00:00
|
|
|
describe('name with link', () => {
|
2017-05-24 11:42:23 +00:00
|
|
|
it('should render the job name and status with a link', (done) => {
|
2017-12-04 15:18:23 +00:00
|
|
|
component = mountComponent(JobComponent, { job: mockJob });
|
2017-05-06 17:02:06 +00:00
|
|
|
|
2017-05-24 11:42:23 +00:00
|
|
|
Vue.nextTick(() => {
|
|
|
|
const link = component.$el.querySelector('a');
|
2017-05-06 17:02:06 +00:00
|
|
|
|
2017-05-24 11:42:23 +00:00
|
|
|
expect(link.getAttribute('href')).toEqual(mockJob.status.details_path);
|
2017-05-06 17:02:06 +00:00
|
|
|
|
2017-05-24 11:42:23 +00:00
|
|
|
expect(
|
|
|
|
link.getAttribute('data-original-title'),
|
|
|
|
).toEqual(`${mockJob.name} - ${mockJob.status.label}`);
|
2017-05-06 17:02:06 +00:00
|
|
|
|
2017-05-24 11:42:23 +00:00
|
|
|
expect(component.$el.querySelector('.js-status-icon-success')).toBeDefined();
|
2017-05-06 17:02:06 +00:00
|
|
|
|
2017-05-24 11:42:23 +00:00
|
|
|
expect(
|
|
|
|
component.$el.querySelector('.ci-status-text').textContent.trim(),
|
|
|
|
).toEqual(mockJob.name);
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
2017-05-06 17:02:06 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('name without link', () => {
|
|
|
|
it('it should render status and name', () => {
|
2017-12-04 15:18:23 +00:00
|
|
|
component = mountComponent(JobComponent, {
|
|
|
|
job: {
|
2018-01-23 09:37:07 +00:00
|
|
|
id: 4257,
|
2017-12-04 15:18:23 +00:00
|
|
|
name: 'test',
|
|
|
|
status: {
|
|
|
|
icon: 'icon_status_success',
|
|
|
|
text: 'passed',
|
|
|
|
label: 'passed',
|
|
|
|
group: 'success',
|
2018-01-23 09:37:07 +00:00
|
|
|
details_path: '/root/ci-mock/builds/4257',
|
2017-12-04 15:18:23 +00:00
|
|
|
has_details: false,
|
2017-05-06 17:02:06 +00:00
|
|
|
},
|
|
|
|
},
|
2017-12-04 15:18:23 +00:00
|
|
|
});
|
2017-05-06 17:02:06 +00:00
|
|
|
|
|
|
|
expect(component.$el.querySelector('.js-status-icon-success')).toBeDefined();
|
2017-12-04 15:18:23 +00:00
|
|
|
expect(component.$el.querySelector('a')).toBeNull();
|
2017-05-06 17:02:06 +00:00
|
|
|
|
|
|
|
expect(
|
|
|
|
component.$el.querySelector('.ci-status-text').textContent.trim(),
|
|
|
|
).toEqual(mockJob.name);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('action icon', () => {
|
|
|
|
it('it should render the action icon', () => {
|
2017-12-04 15:18:23 +00:00
|
|
|
component = mountComponent(JobComponent, { job: mockJob });
|
2017-05-06 17:02:06 +00:00
|
|
|
|
|
|
|
expect(component.$el.querySelector('a.ci-action-icon-container')).toBeDefined();
|
|
|
|
expect(component.$el.querySelector('i.ci-action-icon-wrapper')).toBeDefined();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('dropdown', () => {
|
|
|
|
it('should render the dropdown action icon', () => {
|
2017-12-04 15:18:23 +00:00
|
|
|
component = mountComponent(JobComponent, {
|
|
|
|
job: mockJob,
|
|
|
|
isDropdown: true,
|
|
|
|
});
|
2017-05-06 17:02:06 +00:00
|
|
|
|
|
|
|
expect(component.$el.querySelector('a.ci-action-icon-wrapper')).toBeDefined();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render provided class name', () => {
|
2017-12-04 15:18:23 +00:00
|
|
|
component = mountComponent(JobComponent, {
|
|
|
|
job: mockJob,
|
|
|
|
cssClassJobName: 'css-class-job-name',
|
|
|
|
});
|
2017-05-06 17:02:06 +00:00
|
|
|
|
|
|
|
expect(
|
|
|
|
component.$el.querySelector('a').classList.contains('css-class-job-name'),
|
|
|
|
).toBe(true);
|
|
|
|
});
|
2017-12-11 20:13:39 +00:00
|
|
|
|
|
|
|
describe('status label', () => {
|
|
|
|
it('should not render status label when it is not provided', () => {
|
|
|
|
component = mountComponent(JobComponent, {
|
|
|
|
job: {
|
2018-01-23 09:37:07 +00:00
|
|
|
id: 4258,
|
2017-12-11 20:13:39 +00:00
|
|
|
name: 'test',
|
|
|
|
status: {
|
|
|
|
icon: 'icon_status_success',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(component.$el.querySelector('.js-job-component-tooltip').getAttribute('data-original-title')).toEqual('test');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not render status label when it is provided', () => {
|
|
|
|
component = mountComponent(JobComponent, {
|
|
|
|
job: {
|
2018-01-23 09:37:07 +00:00
|
|
|
id: 4259,
|
2017-12-11 20:13:39 +00:00
|
|
|
name: 'test',
|
|
|
|
status: {
|
|
|
|
icon: 'icon_status_success',
|
|
|
|
label: 'success',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(component.$el.querySelector('.js-job-component-tooltip').getAttribute('data-original-title')).toEqual('test - success');
|
|
|
|
});
|
|
|
|
});
|
2017-05-06 17:02:06 +00:00
|
|
|
});
|