2017-08-17 22:00:37 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
import stageColumnComponent from '~/pipelines/components/graph/stage_column_component.vue';
|
2018-10-15 14:42:47 +05:30
|
|
|
import mountComponent from 'spec/helpers/vue_mount_component_helper';
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
describe('stage column component', () => {
|
|
|
|
let component;
|
2018-10-15 14:42:47 +05:30
|
|
|
const StageColumnComponent = Vue.extend(stageColumnComponent);
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
const mockJob = {
|
2018-03-17 18:26:18 +05:30
|
|
|
id: 4250,
|
2017-08-17 22:00:37 +05:30
|
|
|
name: 'test',
|
|
|
|
status: {
|
|
|
|
icon: 'icon_status_success',
|
|
|
|
text: 'passed',
|
|
|
|
label: 'passed',
|
|
|
|
group: 'success',
|
2018-03-17 18:26:18 +05:30
|
|
|
details_path: '/root/ci-mock/builds/4250',
|
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',
|
2018-03-17 18:26:18 +05:30
|
|
|
path: '/root/ci-mock/builds/4250/retry',
|
2017-08-17 22:00:37 +05:30
|
|
|
method: 'post',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2018-03-17 18:26:18 +05:30
|
|
|
const mockJobs = [];
|
|
|
|
for (let i = 0; i < 3; i += 1) {
|
|
|
|
const mockedJob = Object.assign({}, mockJob);
|
|
|
|
mockedJob.id += i;
|
|
|
|
mockJobs.push(mockedJob);
|
|
|
|
}
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
component = mountComponent(StageColumnComponent, {
|
|
|
|
title: 'foo',
|
|
|
|
jobs: mockJobs,
|
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('should render provided title', () => {
|
|
|
|
expect(component.$el.querySelector('.stage-name').textContent.trim()).toEqual('foo');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render the provided jobs', () => {
|
|
|
|
expect(component.$el.querySelectorAll('.builds-container > ul > li').length).toEqual(3);
|
|
|
|
});
|
2018-10-15 14:42:47 +05:30
|
|
|
|
|
|
|
describe('jobId', () => {
|
|
|
|
it('escapes job name', () => {
|
|
|
|
component = mountComponent(StageColumnComponent, {
|
|
|
|
jobs: [
|
|
|
|
{
|
|
|
|
id: 4259,
|
|
|
|
name: '<img src=x onerror=alert(document.domain)>',
|
|
|
|
status: {
|
|
|
|
icon: 'icon_status_success',
|
|
|
|
label: 'success',
|
|
|
|
tooltip: '<img src=x onerror=alert(document.domain)>',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
title: 'test',
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(
|
|
|
|
component.$el.querySelector('.builds-container li').getAttribute('id'),
|
|
|
|
).toEqual('ci-badge-<img src=x onerror=alert(document.domain)>');
|
|
|
|
});
|
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|