debian-mirror-gitlab/spec/javascripts/pipelines/graph/stage_column_component_spec.js

72 lines
1.9 KiB
JavaScript
Raw Normal View History

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: {
2018-11-18 11:00:15 +05:30
icon: 'status_success',
2017-08-17 22:00:37 +05:30
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-12-13 13:39:08 +05:30
const mockGroups = [];
2018-03-17 18:26:18 +05:30
for (let i = 0; i < 3; i += 1) {
const mockedJob = Object.assign({}, mockJob);
mockedJob.id += i;
2018-12-13 13:39:08 +05:30
mockGroups.push(mockedJob);
2018-03-17 18:26:18 +05:30
}
2018-10-15 14:42:47 +05:30
component = mountComponent(StageColumnComponent, {
title: 'foo',
2018-12-13 13:39:08 +05:30
groups: mockGroups,
2018-10-15 14:42:47 +05:30
});
2017-08-17 22:00:37 +05:30
});
it('should render provided title', () => {
expect(component.$el.querySelector('.stage-name').textContent.trim()).toEqual('foo');
});
2018-12-13 13:39:08 +05:30
it('should render the provided groups', () => {
2017-08-17 22:00:37 +05:30
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, {
2018-12-13 13:39:08 +05:30
groups: [
2018-10-15 14:42:47 +05:30
{
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',
});
2018-12-13 13:39:08 +05:30
expect(component.$el.querySelector('.builds-container li').getAttribute('id')).toEqual(
'ci-badge-&lt;img src=x onerror=alert(document.domain)&gt;',
);
2018-10-15 14:42:47 +05:30
});
});
2017-08-17 22:00:37 +05:30
});