summaryrefslogtreecommitdiff
path: root/spec/javascripts/environments
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2017-02-16 10:23:59 +0000
committerFilipa Lacerda <filipa@gitlab.com>2017-02-16 10:23:59 +0000
commit605195c26add353805bdb5b3e927ebc286f91fec (patch)
tree5e0437cd8899b398955e0fbebc8d6eeab67c744a /spec/javascripts/environments
parent9ac8bf2c2227036394882d64a5822dcf0dd726d7 (diff)
downloadgitlab-ce-605195c26add353805bdb5b3e927ebc286f91fec.tar.gz
Diffstat (limited to 'spec/javascripts/environments')
-rw-r--r--spec/javascripts/environments/environment_item_spec.js.es6115
-rw-r--r--spec/javascripts/environments/environments_store_spec.js.es67
-rw-r--r--spec/javascripts/environments/folder/environments_folder_view_spec.js.es616
-rw-r--r--spec/javascripts/environments/mock_data.js.es633
4 files changed, 96 insertions, 75 deletions
diff --git a/spec/javascripts/environments/environment_item_spec.js.es6 b/spec/javascripts/environments/environment_item_spec.js.es6
index 88413d9ae2b..7fea80ed799 100644
--- a/spec/javascripts/environments/environment_item_spec.js.es6
+++ b/spec/javascripts/environments/environment_item_spec.js.es6
@@ -14,11 +14,10 @@ describe('Environment item', () => {
beforeEach(() => {
mockItem = {
name: 'review',
+ folderName: 'review',
size: 3,
isFolder: true,
- latest: {
- environment_path: 'url',
- },
+ environment_path: 'url',
};
component = new EnvironmentItem({
@@ -49,21 +48,36 @@ describe('Environment item', () => {
environment = {
name: 'production',
size: 1,
- latest: {
- state: 'stopped',
- external_url: 'http://external.com',
- environment_type: null,
- last_deployment: {
- id: 66,
- iid: 6,
- sha: '500aabcb17c97bdcf2d0c410b70cb8556f0362dd',
- ref: {
- name: 'master',
- ref_path: 'root/ci-folders/tree/master',
- },
- tag: true,
- 'last?': true,
- user: {
+ state: 'stopped',
+ external_url: 'http://external.com',
+ environment_type: null,
+ last_deployment: {
+ id: 66,
+ iid: 6,
+ sha: '500aabcb17c97bdcf2d0c410b70cb8556f0362dd',
+ ref: {
+ name: 'master',
+ ref_path: 'root/ci-folders/tree/master',
+ },
+ tag: true,
+ 'last?': true,
+ user: {
+ name: 'Administrator',
+ username: 'root',
+ id: 1,
+ state: 'active',
+ avatar_url: 'http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon',
+ 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,
@@ -71,44 +85,27 @@ describe('Environment item', () => {
avatar_url: 'http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon',
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',
- avatar_url: 'http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon',
- 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',
- },
- ],
+ commit_path: '/root/ci-folders/tree/500aabcb17c97bdcf2d0c410b70cb8556f0362dd',
},
- 'stop_action?': true,
- environment_path: 'root/ci-folders/environments/31',
- created_at: '2016-11-07T11:11:16.525Z',
- updated_at: '2016-11-10T15:55:58.778Z',
+ 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',
+ },
+ ],
},
+ 'stop_action?': true,
+ environment_path: 'root/ci-folders/environments/31',
+ created_at: '2016-11-07T11:11:16.525Z',
+ updated_at: '2016-11-10T15:55:58.778Z',
};
component = new EnvironmentItem({
@@ -129,7 +126,7 @@ describe('Environment item', () => {
it('should render deployment internal id', () => {
expect(
component.$el.querySelector('.deployment-column span').textContent,
- ).toContain(environment.latest.last_deployment.iid);
+ ).toContain(environment.last_deployment.iid);
expect(
component.$el.querySelector('.deployment-column span').textContent,
@@ -139,7 +136,7 @@ describe('Environment item', () => {
it('should render last deployment date', () => {
const timeagoInstance = new timeago(); // eslint-disable-line
const formatedDate = timeagoInstance.format(
- environment.latest.last_deployment.deployable.created_at,
+ environment.last_deployment.deployable.created_at,
);
expect(
@@ -151,7 +148,7 @@ describe('Environment item', () => {
it('should render user avatar with link to profile', () => {
expect(
component.$el.querySelector('.js-deploy-user-container').getAttribute('href'),
- ).toEqual(environment.latest.last_deployment.user.web_url);
+ ).toEqual(environment.last_deployment.user.web_url);
});
});
@@ -159,13 +156,13 @@ describe('Environment item', () => {
it('Should link to build url provided', () => {
expect(
component.$el.querySelector('.build-link').getAttribute('href'),
- ).toEqual(environment.latest.last_deployment.deployable.build_path);
+ ).toEqual(environment.last_deployment.deployable.build_path);
});
it('Should render deployable name and id', () => {
expect(
component.$el.querySelector('.build-link').getAttribute('href'),
- ).toEqual(environment.latest.last_deployment.deployable.build_path);
+ ).toEqual(environment.last_deployment.deployable.build_path);
});
});
diff --git a/spec/javascripts/environments/environments_store_spec.js.es6 b/spec/javascripts/environments/environments_store_spec.js.es6
index 8fd660c3edb..49c7dc4b25c 100644
--- a/spec/javascripts/environments/environments_store_spec.js.es6
+++ b/spec/javascripts/environments/environments_store_spec.js.es6
@@ -1,5 +1,5 @@
const Store = require('~/environments/stores/environments_store');
-const { environmentsList } = require('./mock_data');
+const { environmentsList, serverData } = require('./mock_data');
(() => {
describe('Store', () => {
@@ -17,8 +17,9 @@ const { environmentsList } = require('./mock_data');
});
it('should store environments', () => {
- store.storeEnvironments(environmentsList);
- expect(store.state.environments.length).toEqual(environmentsList.length);
+ store.storeEnvironments(serverData);
+ expect(store.state.environments.length).toEqual(serverData.length);
+ expect(store.state.environments[0]).toEqual(environmentsList[0]);
});
it('should store available count', () => {
diff --git a/spec/javascripts/environments/folder/environments_folder_view_spec.js.es6 b/spec/javascripts/environments/folder/environments_folder_view_spec.js.es6
index 6a95fabcea5..d1335b5b304 100644
--- a/spec/javascripts/environments/folder/environments_folder_view_spec.js.es6
+++ b/spec/javascripts/environments/folder/environments_folder_view_spec.js.es6
@@ -8,7 +8,7 @@ describe('Environments Folder View', () => {
beforeEach(() => {
loadFixtures('static/environments/environments_folder_view.html.raw');
- window.history.pushState({}, null, 'environments/folders/51');
+ window.history.pushState({}, null, 'environments/folders/build');
});
let component;
@@ -80,12 +80,11 @@ describe('Environments Folder View', () => {
}, 0);
});
- // FIX ME:
it('should render parent folder name', (done) => {
setTimeout(() => {
expect(
- component.$el.querySelector('.js-folder-name'),
- ).toBe(null);
+ component.$el.querySelector('.js-folder-name').textContent,
+ ).toContain('Environments / build');
done();
}, 0);
});
@@ -199,14 +198,5 @@ describe('Environments Folder View', () => {
done();
}, 0);
});
-
- it('should not render parent folder name', (done) => {
- setTimeout(() => {
- expect(
- component.$el.querySelector('.js-folder-name'),
- ).toBe(null);
- done();
- }, 0);
- });
});
});
diff --git a/spec/javascripts/environments/mock_data.js.es6 b/spec/javascripts/environments/mock_data.js.es6
index 081897f5456..5c395c6b2d8 100644
--- a/spec/javascripts/environments/mock_data.js.es6
+++ b/spec/javascripts/environments/mock_data.js.es6
@@ -2,6 +2,38 @@ const environmentsList = [
{
name: 'DEV',
size: 1,
+ id: 7,
+ state: 'available',
+ external_url: null,
+ environment_type: null,
+ last_deployment: null,
+ 'stop_action?': false,
+ environment_path: '/root/review-app/environments/7',
+ stop_path: '/root/review-app/environments/7/stop',
+ created_at: '2017-01-31T10:53:46.894Z',
+ updated_at: '2017-01-31T10:53:46.894Z',
+ },
+ {
+ folderName: 'build',
+ size: 5,
+ id: 12,
+ name: 'build/update-README',
+ state: 'available',
+ external_url: null,
+ environment_type: 'build',
+ last_deployment: null,
+ 'stop_action?': false,
+ environment_path: '/root/review-app/environments/12',
+ stop_path: '/root/review-app/environments/12/stop',
+ created_at: '2017-02-01T19:42:18.400Z',
+ updated_at: '2017-02-01T19:42:18.400Z',
+ },
+];
+
+const serverData = [
+ {
+ name: 'DEV',
+ size: 1,
latest: {
id: 7,
name: 'DEV',
@@ -56,4 +88,5 @@ const environment = {
module.exports = {
environmentsList,
environment,
+ serverData,
};