2017-03-17 17:30:32 +00:00
|
|
|
import Vue from 'vue';
|
|
|
|
import tableRowComp from '~/vue_shared/components/pipelines_table_row';
|
2017-01-29 15:30:04 +00:00
|
|
|
|
|
|
|
describe('Pipelines Table Row', () => {
|
2017-05-05 10:34:42 +00:00
|
|
|
const jsonFixtureName = 'pipelines/pipelines.json';
|
|
|
|
|
2017-01-29 15:30:04 +00:00
|
|
|
let component;
|
2017-05-05 10:34:42 +00:00
|
|
|
let pipeline;
|
|
|
|
|
|
|
|
preloadFixtures(jsonFixtureName);
|
2017-01-29 15:30:04 +00:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2017-05-05 10:34:42 +00:00
|
|
|
const pipelines = getJSONFixture(jsonFixtureName).pipelines;
|
|
|
|
pipeline = pipelines.find(p => p.id === 1);
|
2017-03-17 17:30:32 +00:00
|
|
|
const PipelinesTableRowComponent = Vue.extend(tableRowComp);
|
2017-01-29 15:30:04 +00:00
|
|
|
|
2017-03-17 17:30:32 +00:00
|
|
|
component = new PipelinesTableRowComponent({
|
2017-01-29 15:30:04 +00:00
|
|
|
el: document.querySelector('.test-dom-element'),
|
|
|
|
propsData: {
|
|
|
|
pipeline,
|
2017-03-17 17:30:32 +00:00
|
|
|
service: {},
|
2017-01-29 15:30:04 +00:00
|
|
|
},
|
2017-03-17 17:30:32 +00:00
|
|
|
}).$mount();
|
2017-01-29 15:30:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should render a table row', () => {
|
|
|
|
expect(component.$el).toEqual('TR');
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('status column', () => {
|
|
|
|
it('should render a pipeline link', () => {
|
|
|
|
expect(
|
|
|
|
component.$el.querySelector('td.commit-link a').getAttribute('href'),
|
|
|
|
).toEqual(pipeline.path);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render status text', () => {
|
|
|
|
expect(
|
|
|
|
component.$el.querySelector('td.commit-link a').textContent,
|
|
|
|
).toContain(pipeline.details.status.text);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('information column', () => {
|
|
|
|
it('should render a pipeline link', () => {
|
|
|
|
expect(
|
|
|
|
component.$el.querySelector('td:nth-child(2) a').getAttribute('href'),
|
|
|
|
).toEqual(pipeline.path);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render pipeline ID', () => {
|
|
|
|
expect(
|
|
|
|
component.$el.querySelector('td:nth-child(2) a > span').textContent,
|
|
|
|
).toEqual(`#${pipeline.id}`);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when a user is provided', () => {
|
|
|
|
it('should render user information', () => {
|
|
|
|
expect(
|
|
|
|
component.$el.querySelector('td:nth-child(2) a:nth-child(3)').getAttribute('href'),
|
|
|
|
).toEqual(pipeline.user.web_url);
|
|
|
|
|
|
|
|
expect(
|
|
|
|
component.$el.querySelector('td:nth-child(2) img').getAttribute('title'),
|
|
|
|
).toEqual(pipeline.user.name);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('commit column', () => {
|
|
|
|
it('should render link to commit', () => {
|
|
|
|
expect(
|
|
|
|
component.$el.querySelector('td:nth-child(3) .commit-id').getAttribute('href'),
|
|
|
|
).toEqual(pipeline.commit.commit_path);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('stages column', () => {
|
|
|
|
it('should render an icon for each stage', () => {
|
|
|
|
expect(
|
|
|
|
component.$el.querySelectorAll('td:nth-child(4) .js-builds-dropdown-button').length,
|
|
|
|
).toEqual(pipeline.details.stages.length);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('actions column', () => {
|
|
|
|
it('should render the provided actions', () => {
|
|
|
|
expect(
|
|
|
|
component.$el.querySelectorAll('td:nth-child(6) ul li').length,
|
|
|
|
).toEqual(pipeline.details.manual_actions.length);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|