2017-08-17 22:00:37 +05:30
|
|
|
import Vue from '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
|
|
|
import graphComponent from '~/pipelines/components/graph/graph_component.vue';
|
|
|
|
import graphJSON from './mock_data';
|
|
|
|
|
|
|
|
describe('graph component', () => {
|
2018-10-15 14:42:47 +05:30
|
|
|
const GraphComponent = Vue.extend(graphComponent);
|
|
|
|
let component;
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
afterEach(() => {
|
|
|
|
component.$destroy();
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
describe('while is loading', () => {
|
|
|
|
it('should render a loading icon', () => {
|
2018-10-15 14:42:47 +05:30
|
|
|
component = mountComponent(GraphComponent, {
|
|
|
|
isLoading: true,
|
|
|
|
pipeline: {},
|
|
|
|
});
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(component.$el.querySelector('.loading-icon')).toBeDefined();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
describe('with data', () => {
|
|
|
|
it('should render the graph', () => {
|
2018-10-15 14:42:47 +05:30
|
|
|
component = mountComponent(GraphComponent, {
|
|
|
|
isLoading: false,
|
|
|
|
pipeline: graphJSON,
|
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(component.$el.classList.contains('js-pipeline-graph')).toEqual(true);
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(
|
|
|
|
component.$el.querySelector('.stage-column:first-child').classList.contains('no-margin'),
|
|
|
|
).toEqual(true);
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(
|
|
|
|
component.$el.querySelector('.stage-column:nth-child(2)').classList.contains('left-margin'),
|
|
|
|
).toEqual(true);
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(
|
|
|
|
component.$el.querySelector('.stage-column:nth-child(2) .build:nth-child(1)').classList.contains('left-connector'),
|
|
|
|
).toEqual(true);
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(component.$el.querySelector('loading-icon')).toBe(null);
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(component.$el.querySelector('.stage-column-list')).toBeDefined();
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
});
|
2018-10-15 14:42:47 +05:30
|
|
|
|
|
|
|
describe('capitalizeStageName', () => {
|
|
|
|
it('capitalizes and escapes stage name', () => {
|
|
|
|
component = mountComponent(GraphComponent, {
|
|
|
|
isLoading: false,
|
|
|
|
pipeline: graphJSON,
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(component.$el.querySelector('.stage-column:nth-child(2) .stage-name').textContent.trim()).toEqual('Deploy <img src=x onerror=alert(document.domain)>');
|
|
|
|
});
|
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|