2017-09-10 17:25:29 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
import headerComponent from '~/jobs/components/header.vue';
|
2018-03-27 19:54:05 +05:30
|
|
|
import mountComponent from 'spec/helpers/vue_mount_component_helper';
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
describe('Job details header', () => {
|
|
|
|
let HeaderComponent;
|
|
|
|
let vm;
|
|
|
|
let props;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
HeaderComponent = Vue.extend(headerComponent);
|
|
|
|
|
|
|
|
const threeWeeksAgo = new Date();
|
|
|
|
threeWeeksAgo.setDate(threeWeeksAgo.getDate() - 21);
|
|
|
|
|
|
|
|
props = {
|
|
|
|
job: {
|
|
|
|
status: {
|
|
|
|
group: 'failed',
|
|
|
|
icon: 'ci-status-failed',
|
|
|
|
label: 'failed',
|
|
|
|
text: 'failed',
|
|
|
|
details_path: 'path',
|
|
|
|
},
|
|
|
|
id: 123,
|
|
|
|
created_at: threeWeeksAgo.toISOString(),
|
|
|
|
user: {
|
|
|
|
web_url: 'path',
|
|
|
|
name: 'Foo',
|
|
|
|
username: 'foobar',
|
|
|
|
email: 'foo@bar.com',
|
|
|
|
avatar_url: 'link',
|
|
|
|
},
|
2018-03-17 18:26:18 +05:30
|
|
|
started: '2018-01-08T09:48:27.319Z',
|
2017-09-10 17:25:29 +05:30
|
|
|
new_issue_path: 'path',
|
|
|
|
},
|
|
|
|
isLoading: false,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
|
|
|
});
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
describe('job reason', () => {
|
|
|
|
it('should not render the reason when reason is absent', () => {
|
|
|
|
vm = mountComponent(HeaderComponent, props);
|
|
|
|
|
|
|
|
expect(vm.shouldRenderReason).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render the reason when reason is present', () => {
|
|
|
|
props.job.callout_message = 'There is an unknown failure, please try again';
|
|
|
|
|
|
|
|
vm = mountComponent(HeaderComponent, props);
|
|
|
|
|
|
|
|
expect(vm.shouldRenderReason).toBe(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
describe('triggered job', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
vm = mountComponent(HeaderComponent, props);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render provided job information', () => {
|
|
|
|
expect(
|
2018-10-15 14:42:47 +05:30
|
|
|
vm.$el
|
|
|
|
.querySelector('.header-main-content')
|
|
|
|
.textContent.replace(/\s+/g, ' ')
|
|
|
|
.trim(),
|
2018-03-17 18:26:18 +05:30
|
|
|
).toEqual('failed Job #123 triggered 3 weeks ago by Foo');
|
|
|
|
});
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it('should render new issue link', () => {
|
2018-10-15 14:42:47 +05:30
|
|
|
expect(vm.$el.querySelector('.js-new-issue').getAttribute('href')).toEqual(
|
|
|
|
props.job.new_issue_path,
|
|
|
|
);
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
describe('created job', () => {
|
|
|
|
it('should render created key', () => {
|
|
|
|
props.job.started = false;
|
|
|
|
vm = mountComponent(HeaderComponent, props);
|
|
|
|
|
|
|
|
expect(
|
2018-10-15 14:42:47 +05:30
|
|
|
vm.$el
|
|
|
|
.querySelector('.header-main-content')
|
|
|
|
.textContent.replace(/\s+/g, ' ')
|
|
|
|
.trim(),
|
2018-03-17 18:26:18 +05:30
|
|
|
).toEqual('failed Job #123 created 3 weeks ago by Foo');
|
|
|
|
});
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
});
|