2017-08-17 22:00:37 +05:30
|
|
|
import Vue from 'vue';
|
2017-09-10 17:25:29 +05:30
|
|
|
import pipelinesTableComp from '~/pipelines/components/pipelines_table.vue';
|
2017-08-17 22:00:37 +05:30
|
|
|
import '~/lib/utils/datetime_utility';
|
|
|
|
|
|
|
|
describe('Pipelines Table', () => {
|
2017-09-10 17:25:29 +05:30
|
|
|
const jsonFixtureName = 'pipelines/pipelines.json';
|
|
|
|
|
|
|
|
let pipeline;
|
2017-08-17 22:00:37 +05:30
|
|
|
let PipelinesTableComponent;
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
preloadFixtures(jsonFixtureName);
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
beforeEach(() => {
|
2018-11-08 19:23:39 +05:30
|
|
|
const { pipelines } = getJSONFixture(jsonFixtureName);
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
PipelinesTableComponent = Vue.extend(pipelinesTableComp);
|
|
|
|
pipeline = pipelines.find(p => p.user !== null && p.commit !== null);
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
describe('table', () => {
|
|
|
|
let component;
|
|
|
|
beforeEach(() => {
|
|
|
|
component = new PipelinesTableComponent({
|
|
|
|
propsData: {
|
|
|
|
pipelines: [],
|
2018-03-17 18:26:18 +05:30
|
|
|
autoDevopsHelpPath: 'foo',
|
|
|
|
viewType: 'root',
|
2017-08-17 22:00:37 +05:30
|
|
|
},
|
|
|
|
}).$mount();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
component.$destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render a table', () => {
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(component.$el.getAttribute('class')).toContain('ci-table');
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('should render table head with correct columns', () => {
|
2018-12-13 13:39:08 +05:30
|
|
|
expect(
|
|
|
|
component.$el.querySelector('.table-section.js-pipeline-status').textContent.trim(),
|
|
|
|
).toEqual('Status');
|
|
|
|
|
|
|
|
expect(
|
|
|
|
component.$el.querySelector('.table-section.js-pipeline-info').textContent.trim(),
|
|
|
|
).toEqual('Pipeline');
|
|
|
|
|
|
|
|
expect(
|
|
|
|
component.$el.querySelector('.table-section.js-pipeline-commit').textContent.trim(),
|
|
|
|
).toEqual('Commit');
|
|
|
|
|
|
|
|
expect(
|
|
|
|
component.$el.querySelector('.table-section.js-pipeline-stages').textContent.trim(),
|
|
|
|
).toEqual('Stages');
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('without data', () => {
|
|
|
|
it('should render an empty table', () => {
|
|
|
|
const component = new PipelinesTableComponent({
|
|
|
|
propsData: {
|
|
|
|
pipelines: [],
|
2018-03-17 18:26:18 +05:30
|
|
|
autoDevopsHelpPath: 'foo',
|
|
|
|
viewType: 'root',
|
2017-08-17 22:00:37 +05:30
|
|
|
},
|
|
|
|
}).$mount();
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(component.$el.querySelectorAll('.commit.gl-responsive-table-row').length).toEqual(0);
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with data', () => {
|
|
|
|
it('should render rows', () => {
|
|
|
|
const component = new PipelinesTableComponent({
|
|
|
|
propsData: {
|
|
|
|
pipelines: [pipeline],
|
2018-03-17 18:26:18 +05:30
|
|
|
autoDevopsHelpPath: 'foo',
|
|
|
|
viewType: 'root',
|
2017-08-17 22:00:37 +05:30
|
|
|
},
|
|
|
|
}).$mount();
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(component.$el.querySelectorAll('.commit.gl-responsive-table-row').length).toEqual(1);
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|