2017-08-17 22:00:37 +05:30
|
|
|
import 'timeago.js';
|
|
|
|
import Vue from 'vue';
|
|
|
|
import environmentItemComp from '~/environments/components/environment_item.vue';
|
|
|
|
|
|
|
|
describe('Environment item', () => {
|
|
|
|
let EnvironmentItem;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
EnvironmentItem = Vue.extend(environmentItemComp);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('When item is folder', () => {
|
|
|
|
let mockItem;
|
|
|
|
let component;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
mockItem = {
|
|
|
|
name: 'review',
|
|
|
|
folderName: 'review',
|
|
|
|
size: 3,
|
|
|
|
isFolder: true,
|
|
|
|
environment_path: 'url',
|
2019-07-07 11:18:12 +05:30
|
|
|
log_path: 'url',
|
2017-08-17 22:00:37 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
component = new EnvironmentItem({
|
|
|
|
propsData: {
|
|
|
|
model: mockItem,
|
|
|
|
canReadEnvironment: true,
|
|
|
|
},
|
|
|
|
}).$mount();
|
|
|
|
});
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
it('should render folder icon and name', () => {
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(component.$el.querySelector('.folder-name').textContent).toContain(mockItem.name);
|
|
|
|
expect(component.$el.querySelector('.folder-icon')).toBeDefined();
|
|
|
|
});
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
it('should render the number of children in a badge', () => {
|
2018-12-13 13:39:08 +05:30
|
|
|
expect(component.$el.querySelector('.folder-name .badge').textContent).toContain(
|
|
|
|
mockItem.size,
|
|
|
|
);
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when item is not folder', () => {
|
|
|
|
let environment;
|
|
|
|
let component;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
environment = {
|
|
|
|
name: 'production',
|
|
|
|
size: 1,
|
|
|
|
state: 'stopped',
|
|
|
|
external_url: 'http://external.com',
|
|
|
|
environment_type: null,
|
|
|
|
last_deployment: {
|
|
|
|
id: 66,
|
|
|
|
iid: 6,
|
|
|
|
sha: '500aabcb17c97bdcf2d0c410b70cb8556f0362dd',
|
|
|
|
ref: {
|
|
|
|
name: 'master',
|
2019-07-07 11:18:12 +05:30
|
|
|
ref_url: 'root/ci-folders/tree/master',
|
2017-08-17 22:00:37 +05:30
|
|
|
},
|
|
|
|
tag: true,
|
|
|
|
'last?': true,
|
|
|
|
user: {
|
|
|
|
name: 'Administrator',
|
|
|
|
username: 'root',
|
|
|
|
id: 1,
|
|
|
|
state: 'active',
|
2018-12-13 13:39:08 +05:30
|
|
|
avatar_url:
|
|
|
|
'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon',
|
2017-08-17 22:00:37 +05:30
|
|
|
web_url: 'http://localhost:3000/root',
|
|
|
|
},
|
|
|
|
commit: {
|
|
|
|
id: '500aabcb17c97bdcf2d0c410b70cb8556f0362dd',
|
|
|
|
short_id: '500aabcb',
|
|
|
|
title: 'Update .gitlab-ci.yml',
|
|
|
|
author_name: 'Administrator',
|
|
|
|
author_email: 'admin@example.com',
|
|
|
|
created_at: '2016-11-07T18:28:13.000+00:00',
|
|
|
|
message: 'Update .gitlab-ci.yml',
|
|
|
|
author: {
|
|
|
|
name: 'Administrator',
|
|
|
|
username: 'root',
|
|
|
|
id: 1,
|
|
|
|
state: 'active',
|
2018-12-13 13:39:08 +05:30
|
|
|
avatar_url:
|
|
|
|
'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon',
|
2017-08-17 22:00:37 +05:30
|
|
|
web_url: 'http://localhost:3000/root',
|
|
|
|
},
|
|
|
|
commit_path: '/root/ci-folders/tree/500aabcb17c97bdcf2d0c410b70cb8556f0362dd',
|
|
|
|
},
|
|
|
|
deployable: {
|
|
|
|
id: 1279,
|
|
|
|
name: 'deploy',
|
|
|
|
build_path: '/root/ci-folders/builds/1279',
|
|
|
|
retry_path: '/root/ci-folders/builds/1279/retry',
|
|
|
|
created_at: '2016-11-29T18:11:58.430Z',
|
|
|
|
updated_at: '2016-11-29T18:11:58.430Z',
|
|
|
|
},
|
|
|
|
manual_actions: [
|
|
|
|
{
|
|
|
|
name: 'action',
|
|
|
|
play_path: '/play',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2018-11-18 11:00:15 +05:30
|
|
|
has_stop_action: true,
|
2017-08-17 22:00:37 +05:30
|
|
|
environment_path: 'root/ci-folders/environments/31',
|
2019-07-07 11:18:12 +05:30
|
|
|
log_path: 'root/ci-folders/environments/31/logs',
|
2017-08-17 22:00:37 +05:30
|
|
|
created_at: '2016-11-07T11:11:16.525Z',
|
|
|
|
updated_at: '2016-11-10T15:55:58.778Z',
|
|
|
|
};
|
|
|
|
|
|
|
|
component = new EnvironmentItem({
|
|
|
|
propsData: {
|
|
|
|
model: environment,
|
|
|
|
canReadEnvironment: true,
|
|
|
|
},
|
|
|
|
}).$mount();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render environment name', () => {
|
2018-12-13 13:39:08 +05:30
|
|
|
expect(component.$el.querySelector('.environment-name').textContent).toContain(
|
|
|
|
environment.name,
|
|
|
|
);
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
describe('With deployment', () => {
|
|
|
|
it('should render deployment internal id', () => {
|
2018-12-13 13:39:08 +05:30
|
|
|
expect(component.$el.querySelector('.deployment-column span').textContent).toContain(
|
|
|
|
environment.last_deployment.iid,
|
|
|
|
);
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
expect(component.$el.querySelector('.deployment-column span').textContent).toContain('#');
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('should render last deployment date', () => {
|
|
|
|
const timeagoInstance = new timeago(); // eslint-disable-line
|
|
|
|
const formatedDate = timeagoInstance.format(
|
|
|
|
environment.last_deployment.deployable.created_at,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(
|
|
|
|
component.$el.querySelector('.environment-created-date-timeago').textContent,
|
|
|
|
).toContain(formatedDate);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('With user information', () => {
|
|
|
|
it('should render user avatar with link to profile', () => {
|
|
|
|
expect(
|
|
|
|
component.$el.querySelector('.js-deploy-user-container').getAttribute('href'),
|
|
|
|
).toEqual(environment.last_deployment.user.web_url);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('With build url', () => {
|
2019-07-07 11:18:12 +05:30
|
|
|
it('should link to build url provided', () => {
|
2018-12-13 13:39:08 +05:30
|
|
|
expect(component.$el.querySelector('.build-link').getAttribute('href')).toEqual(
|
|
|
|
environment.last_deployment.deployable.build_path,
|
|
|
|
);
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
it('should render deployable name and id', () => {
|
2018-12-13 13:39:08 +05:30
|
|
|
expect(component.$el.querySelector('.build-link').getAttribute('href')).toEqual(
|
|
|
|
environment.last_deployment.deployable.build_path,
|
|
|
|
);
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('With commit information', () => {
|
|
|
|
it('should render commit component', () => {
|
2018-12-13 13:39:08 +05:30
|
|
|
expect(component.$el.querySelector('.js-commit-component')).toBeDefined();
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('With manual actions', () => {
|
2019-07-07 11:18:12 +05:30
|
|
|
it('should render actions component', () => {
|
2018-12-13 13:39:08 +05:30
|
|
|
expect(component.$el.querySelector('.js-manual-actions-container')).toBeDefined();
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('With external URL', () => {
|
|
|
|
it('should render external url component', () => {
|
2018-12-13 13:39:08 +05:30
|
|
|
expect(component.$el.querySelector('.js-external-url-container')).toBeDefined();
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('With stop action', () => {
|
2019-07-07 11:18:12 +05:30
|
|
|
it('should render stop action component', () => {
|
2018-12-13 13:39:08 +05:30
|
|
|
expect(component.$el.querySelector('.js-stop-component-container')).toBeDefined();
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('With retry action', () => {
|
2019-07-07 11:18:12 +05:30
|
|
|
it('should render rollback component', () => {
|
2018-12-13 13:39:08 +05:30
|
|
|
expect(component.$el.querySelector('.js-rollback-component-container')).toBeDefined();
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|