2017-09-10 17:25:29 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
import sidebarDetailsBlock from '~/jobs/components/sidebar_details_block.vue';
|
2018-11-20 20:47:30 +05:30
|
|
|
import job from '../mock_data';
|
|
|
|
import mountComponent from '../../helpers/vue_mount_component_helper';
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
describe('Sidebar details block', () => {
|
|
|
|
let SidebarComponent;
|
|
|
|
let vm;
|
|
|
|
|
|
|
|
function trimWhitespace(element) {
|
|
|
|
return element.textContent.replace(/\s+/g, ' ').trim();
|
|
|
|
}
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
SidebarComponent = Vue.extend(sidebarDetailsBlock);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when it is loading', () => {
|
|
|
|
it('should render a loading spinner', () => {
|
2018-11-20 20:47:30 +05:30
|
|
|
vm = mountComponent(SidebarComponent, {
|
|
|
|
job: {},
|
|
|
|
isLoading: true,
|
|
|
|
});
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(vm.$el.querySelector('.fa-spinner')).toBeDefined();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
describe('when there is no retry path retry', () => {
|
2018-10-15 14:42:47 +05:30
|
|
|
it('should not render a retry button', () => {
|
2018-11-20 20:47:30 +05:30
|
|
|
vm = mountComponent(SidebarComponent, {
|
|
|
|
job: {},
|
|
|
|
isLoading: false,
|
|
|
|
});
|
2018-10-15 14:42:47 +05:30
|
|
|
|
|
|
|
expect(vm.$el.querySelector('.js-retry-job')).toBeNull();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
describe('without terminal path', () => {
|
|
|
|
it('does not render terminal link', () => {
|
|
|
|
vm = mountComponent(SidebarComponent, {
|
2017-09-10 17:25:29 +05:30
|
|
|
job,
|
|
|
|
isLoading: false,
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
expect(vm.$el.querySelector('.js-terminal-link')).toBeNull();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with terminal path', () => {
|
|
|
|
it('renders terminal link', () => {
|
|
|
|
vm = mountComponent(SidebarComponent, {
|
|
|
|
job,
|
|
|
|
isLoading: false,
|
|
|
|
terminalPath: 'job/43123/terminal',
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(vm.$el.querySelector('.js-terminal-link')).not.toBeNull();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
vm = mountComponent(SidebarComponent, {
|
|
|
|
job,
|
|
|
|
isLoading: false,
|
|
|
|
});
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
describe('actions', () => {
|
|
|
|
it('should render link to new issue', () => {
|
2018-10-15 14:42:47 +05:30
|
|
|
expect(vm.$el.querySelector('.js-new-issue').getAttribute('href')).toEqual(
|
|
|
|
job.new_issue_path,
|
|
|
|
);
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(vm.$el.querySelector('.js-new-issue').textContent.trim()).toEqual('New issue');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render link to retry job', () => {
|
|
|
|
expect(vm.$el.querySelector('.js-retry-job').getAttribute('href')).toEqual(job.retry_path);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render link to cancel job', () => {
|
|
|
|
expect(vm.$el.querySelector('.js-cancel-job').getAttribute('href')).toEqual(job.cancel_path);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('information', () => {
|
|
|
|
it('should render merge request link', () => {
|
2018-10-15 14:42:47 +05:30
|
|
|
expect(trimWhitespace(vm.$el.querySelector('.js-job-mr'))).toEqual('Merge Request: !2');
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
expect(vm.$el.querySelector('.js-job-mr a').getAttribute('href')).toEqual(
|
|
|
|
job.merge_request.path,
|
|
|
|
);
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('should render job duration', () => {
|
2018-10-15 14:42:47 +05:30
|
|
|
expect(trimWhitespace(vm.$el.querySelector('.js-job-duration'))).toEqual(
|
|
|
|
'Duration: 6 seconds',
|
|
|
|
);
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('should render erased date', () => {
|
2018-10-15 14:42:47 +05:30
|
|
|
expect(trimWhitespace(vm.$el.querySelector('.js-job-erased'))).toEqual('Erased: 3 weeks ago');
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('should render finished date', () => {
|
2018-10-15 14:42:47 +05:30
|
|
|
expect(trimWhitespace(vm.$el.querySelector('.js-job-finished'))).toEqual(
|
|
|
|
'Finished: 3 weeks ago',
|
|
|
|
);
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('should render queued date', () => {
|
2018-10-15 14:42:47 +05:30
|
|
|
expect(trimWhitespace(vm.$el.querySelector('.js-job-queued'))).toEqual('Queued: 9 seconds');
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('should render runner ID', () => {
|
2018-11-20 20:47:30 +05:30
|
|
|
expect(trimWhitespace(vm.$el.querySelector('.js-job-runner'))).toEqual(
|
|
|
|
'Runner: local ci runner (#1)',
|
|
|
|
);
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
it('should render timeout information', () => {
|
2018-11-20 20:47:30 +05:30
|
|
|
expect(trimWhitespace(vm.$el.querySelector('.js-job-timeout'))).toEqual(
|
|
|
|
'Timeout: 1m 40s (from runner)',
|
|
|
|
);
|
2018-05-09 12:01:36 +05:30
|
|
|
});
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
it('should render coverage', () => {
|
2018-10-15 14:42:47 +05:30
|
|
|
expect(trimWhitespace(vm.$el.querySelector('.js-job-coverage'))).toEqual('Coverage: 20%');
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('should render tags', () => {
|
2018-10-15 14:42:47 +05:30
|
|
|
expect(trimWhitespace(vm.$el.querySelector('.js-job-tags'))).toEqual('Tags: tag');
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|