2017-02-09 11:52:22 +00:00
|
|
|
const RollbackComponent = require('~/environments/components/environment_rollback');
|
2016-12-29 21:42:48 +00:00
|
|
|
|
2016-11-10 18:58:35 +00:00
|
|
|
describe('Rollback Component', () => {
|
2016-12-31 00:14:33 +00:00
|
|
|
preloadFixtures('static/environments/element.html.raw');
|
2016-11-10 18:58:35 +00:00
|
|
|
|
|
|
|
const retryURL = 'https://gitlab.com/retry';
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2016-12-31 00:14:33 +00:00
|
|
|
loadFixtures('static/environments/element.html.raw');
|
2016-11-10 18:58:35 +00:00
|
|
|
});
|
|
|
|
|
2016-12-08 12:06:49 +00:00
|
|
|
it('Should link to the provided retryUrl', () => {
|
2017-02-09 11:52:22 +00:00
|
|
|
const component = new RollbackComponent({
|
2016-11-10 18:58:35 +00:00
|
|
|
el: document.querySelector('.test-dom-element'),
|
|
|
|
propsData: {
|
2016-12-08 11:54:08 +00:00
|
|
|
retryUrl: retryURL,
|
|
|
|
isLastDeployment: true,
|
2016-11-10 18:58:35 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(component.$el.getAttribute('href')).toEqual(retryURL);
|
|
|
|
});
|
|
|
|
|
2016-12-08 12:06:49 +00:00
|
|
|
it('Should render Re-deploy label when isLastDeployment is true', () => {
|
2017-02-09 11:52:22 +00:00
|
|
|
const component = new RollbackComponent({
|
2016-11-10 18:58:35 +00:00
|
|
|
el: document.querySelector('.test-dom-element'),
|
|
|
|
propsData: {
|
2016-12-08 11:54:08 +00:00
|
|
|
retryUrl: retryURL,
|
|
|
|
isLastDeployment: true,
|
2016-11-10 18:58:35 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(component.$el.querySelector('span').textContent).toContain('Re-deploy');
|
|
|
|
});
|
|
|
|
|
2016-12-08 12:06:49 +00:00
|
|
|
it('Should render Rollback label when isLastDeployment is false', () => {
|
2017-02-09 11:52:22 +00:00
|
|
|
const component = new RollbackComponent({
|
2016-11-10 18:58:35 +00:00
|
|
|
el: document.querySelector('.test-dom-element'),
|
|
|
|
propsData: {
|
2016-12-08 11:54:08 +00:00
|
|
|
retryUrl: retryURL,
|
|
|
|
isLastDeployment: false,
|
2016-11-10 18:58:35 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(component.$el.querySelector('span').textContent).toContain('Rollback');
|
|
|
|
});
|
|
|
|
});
|