2020-01-01 13:55:28 +05:30
|
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
import { trimText } from 'helpers/text_helper';
|
2018-12-13 13:39:08 +05:30
|
|
|
import JobItem from '~/pipelines/components/graph/job_item.vue';
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
describe('pipeline graph job item', () => {
|
2020-01-01 13:55:28 +05:30
|
|
|
let wrapper;
|
|
|
|
|
|
|
|
const createWrapper = propsData => {
|
2020-03-09 13:42:32 +05:30
|
|
|
wrapper = mount(JobItem, {
|
|
|
|
propsData,
|
|
|
|
});
|
2020-01-01 13:55:28 +05:30
|
|
|
};
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
const delayedJobFixture = getJSONFixture('jobs/delayed.json');
|
2017-08-17 22:00:37 +05:30
|
|
|
const mockJob = {
|
|
|
|
id: 4256,
|
|
|
|
name: 'test',
|
|
|
|
status: {
|
2018-11-18 11:00:15 +05:30
|
|
|
icon: 'status_success',
|
2017-08-17 22:00:37 +05:30
|
|
|
text: 'passed',
|
|
|
|
label: 'passed',
|
2018-05-09 12:01:36 +05:30
|
|
|
tooltip: 'passed',
|
2017-08-17 22:00:37 +05:30
|
|
|
group: 'success',
|
|
|
|
details_path: '/root/ci-mock/builds/4256',
|
2018-03-17 18:26:18 +05:30
|
|
|
has_details: true,
|
2017-08-17 22:00:37 +05:30
|
|
|
action: {
|
2018-03-17 18:26:18 +05:30
|
|
|
icon: 'retry',
|
2017-08-17 22:00:37 +05:30
|
|
|
title: 'Retry',
|
|
|
|
path: '/root/ci-mock/builds/4256/retry',
|
|
|
|
method: 'post',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
afterEach(() => {
|
2020-01-01 13:55:28 +05:30
|
|
|
wrapper.destroy();
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
describe('name with link', () => {
|
2018-12-13 13:39:08 +05:30
|
|
|
it('should render the job name and status with a link', done => {
|
2020-01-01 13:55:28 +05:30
|
|
|
createWrapper({ job: mockJob });
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
wrapper.vm.$nextTick(() => {
|
|
|
|
const link = wrapper.find('a');
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
expect(link.attributes('href')).toBe(mockJob.status.details_path);
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2020-03-09 13:42:32 +05:30
|
|
|
expect(link.attributes('title')).toEqual(`${mockJob.name} - ${mockJob.status.label}`);
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
expect(wrapper.find('.js-status-icon-success')).toBeDefined();
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
expect(trimText(wrapper.find('.ci-status-text').text())).toBe(mockJob.name);
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('name without link', () => {
|
|
|
|
it('it should render status and name', () => {
|
2020-01-01 13:55:28 +05:30
|
|
|
createWrapper({
|
2018-03-17 18:26:18 +05:30
|
|
|
job: {
|
|
|
|
id: 4257,
|
|
|
|
name: 'test',
|
|
|
|
status: {
|
2018-11-18 11:00:15 +05:30
|
|
|
icon: 'status_success',
|
2018-03-17 18:26:18 +05:30
|
|
|
text: 'passed',
|
|
|
|
label: 'passed',
|
|
|
|
group: 'success',
|
|
|
|
details_path: '/root/ci-mock/builds/4257',
|
|
|
|
has_details: false,
|
2017-08-17 22:00:37 +05:30
|
|
|
},
|
|
|
|
},
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
expect(wrapper.find('.js-status-icon-success')).toBeDefined();
|
|
|
|
expect(wrapper.find('a').exists()).toBe(false);
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
expect(trimText(wrapper.find('.ci-status-text').text())).toEqual(mockJob.name);
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('action icon', () => {
|
|
|
|
it('it should render the action icon', () => {
|
2020-01-01 13:55:28 +05:30
|
|
|
createWrapper({ job: mockJob });
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
expect(wrapper.find('a.ci-action-icon-container')).toBeDefined();
|
|
|
|
expect(wrapper.find('i.ci-action-icon-wrapper')).toBeDefined();
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render provided class name', () => {
|
2020-01-01 13:55:28 +05:30
|
|
|
createWrapper({
|
2018-03-17 18:26:18 +05:30
|
|
|
job: mockJob,
|
|
|
|
cssClassJobName: 'css-class-job-name',
|
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
expect(wrapper.find('a').classes()).toContain('css-class-job-name');
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
describe('status label', () => {
|
|
|
|
it('should not render status label when it is not provided', () => {
|
2020-01-01 13:55:28 +05:30
|
|
|
createWrapper({
|
2018-03-17 18:26:18 +05:30
|
|
|
job: {
|
|
|
|
id: 4258,
|
|
|
|
name: 'test',
|
|
|
|
status: {
|
2018-11-18 11:00:15 +05:30
|
|
|
icon: 'status_success',
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2020-03-09 13:42:32 +05:30
|
|
|
expect(wrapper.find('.js-job-component-tooltip').attributes('title')).toBe('test');
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('should not render status label when it is provided', () => {
|
2020-01-01 13:55:28 +05:30
|
|
|
createWrapper({
|
2018-03-17 18:26:18 +05:30
|
|
|
job: {
|
|
|
|
id: 4259,
|
|
|
|
name: 'test',
|
|
|
|
status: {
|
2018-11-18 11:00:15 +05:30
|
|
|
icon: 'status_success',
|
2018-03-17 18:26:18 +05:30
|
|
|
label: 'success',
|
2018-05-09 12:01:36 +05:30
|
|
|
tooltip: 'success',
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2020-03-09 13:42:32 +05:30
|
|
|
expect(wrapper.find('.js-job-component-tooltip').attributes('title')).toEqual(
|
2020-01-01 13:55:28 +05:30
|
|
|
'test - success',
|
|
|
|
);
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
});
|
2018-10-15 14:42:47 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
describe('for delayed job', () => {
|
2019-02-15 15:39:39 +05:30
|
|
|
it('displays remaining time in tooltip', () => {
|
2020-01-01 13:55:28 +05:30
|
|
|
createWrapper({
|
2018-12-13 13:39:08 +05:30
|
|
|
job: delayedJobFixture,
|
|
|
|
});
|
|
|
|
|
2020-03-09 13:42:32 +05:30
|
|
|
expect(wrapper.find('.js-pipeline-graph-job-link').attributes('title')).toEqual(
|
2020-01-01 13:55:28 +05:30
|
|
|
`delayed job - delayed manual action (${wrapper.vm.remainingTime})`,
|
|
|
|
);
|
2018-12-13 13:39:08 +05:30
|
|
|
});
|
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|