Skip to content

Commit 063fb0d

Browse files
Update to es6
1 parent 05f1fe9 commit 063fb0d

File tree

12 files changed

+232
-254
lines changed

12 files changed

+232
-254
lines changed

test/.jshintrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"node": true,
33
"browser": true,
4-
"esnext": true,
4+
"esversion": 6,
55
"bitwise": true,
66
"camelcase": false,
77
"curly": true,
@@ -18,6 +18,7 @@
1818
"sub" : true,
1919
"undef": true,
2020
"unused": true,
21+
"expr" : true,
2122
"globals": {
2223
"ace": false,
2324
"after": false,

test/integration/helpers/inputs.js

+28-28
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
11
'use strict';
2+
/*jshint esversion: 6 */
23

34
// is a pain to get an array of input values because .getAttribute()
45
// is a promise
5-
// example:
6-
// getInputValues(element(by.css('input[type="text"]')))
7-
// .then(function(values) { /* do stuff */ });
8-
var getInputValues = function(inputs) {
9-
var allValues = protractor.promise.defer();
10-
var values = [];
11-
var count;
12-
inputs.count().then(function(num) {
13-
count = num;
14-
});
15-
inputs.each(function(input, i) {
16-
input.getAttribute('value').then(function(val) {
17-
values.push(val);
18-
if((i+1) === count) {
19-
allValues.fulfill(values);
20-
}
6+
const getInputValues = (inputs) => {
7+
let allValues = protractor.promise.defer();
8+
let values = [];
9+
let count;
10+
inputs.count()
11+
.then((num) => {
12+
count = num + 1;
2113
});
14+
inputs.each((input, i) => {
15+
input
16+
.getAttribute('value')
17+
.then(function(val) {
18+
values.push(val);
19+
if((i) === count) {
20+
allValues.fulfill(values);
21+
}
22+
});
2223
});
2324
return allValues.promise;
2425
};
2526

26-
2727
// inputs: protractor object
2828
// - element.all(by.model('parameter.value'))
2929
// value: string
30-
var findValueInInputs = function(inputs, value) {
31-
return getInputValues(inputs).then(function(values) {
32-
var found = values.find(function(val) {
33-
return val === value;
34-
});
35-
return found;
36-
});
30+
const findValueInInputs = (inputs, value) => {
31+
return getInputValues(inputs)
32+
.then((values) => {
33+
let found = values.find((val) => { val === value; });
34+
return found;
35+
});
3736
};
3837

38+
3939
// example:
4040
// check(element(by.css('input[type="checkbox"]')))
41-
var check = function(checkboxElem) {
42-
return checkboxElem.isSelected().then(function(selected) {
41+
const check = (checkboxElem) => {
42+
return checkboxElem.isSelected().then((selected) => {
4343
if(!selected) {
4444
return checkboxElem.click();
4545
}
@@ -48,8 +48,8 @@ var check = function(checkboxElem) {
4848

4949
// example:
5050
// unCheck(element(by.css('input[type="checkbox"]')))
51-
var uncheck = function(checkboxElem) {
52-
return checkboxElem.isSelected().then(function(selected) {
51+
const uncheck = (checkboxElem) => {
52+
return checkboxElem.isSelected().then((selected) => {
5353
if(selected) {
5454
return checkboxElem.click();
5555
}
+7-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
'use strict';
22

3-
var _ = require('lodash');var Page = require('./page').Page;
3+
const Page = require('./page').Page;
44

5-
var BuildsPage = function(project) {
6-
this.project = project;
7-
};
8-
9-
_.extend(BuildsPage.prototype, Page.prototype, {
10-
getUrl: function() {
5+
class BuildsPage extends Page {
6+
constructor(project, menu) {
7+
super(project, menu);
8+
}
9+
getUrl() {
1110
return 'project/' + this.project.name + '/browse/builds';
1211
}
13-
});
12+
}
1413

1514
exports.BuildsPage = BuildsPage;
+35-40
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
'use strict';
22

3-
var h = require('../helpers.js');
4-
var _ = require('lodash');
5-
var inputs = require('../helpers/inputs');
6-
var Page = require('./page').Page;
7-
//var logger = require('../helpers/logger');
3+
const h = require('../helpers.js');
4+
const inputs = require('../helpers/inputs');
5+
const Page = require('./page').Page;
86

9-
var AddTemplateModal = function(project) {
7+
let AddTemplateModal = function(project) {
108
this.project = project;
119
this.modal = element(by.css('.modal-dialog'));
1210
this.checkboxes = this.modal.all(by.css('input[type="checkbox"]'));
@@ -33,62 +31,59 @@ var AddTemplateModal = function(project) {
3331
};
3432
};
3533

36-
var CatalogPage = function(project) {
37-
this.project = project;
38-
};
39-
40-
_.extend(CatalogPage.prototype, Page.prototype, {
41-
getUrl: function() {
42-
// ?tab=tab=fromFile, ?tab=fromCatalog, ?tab=deployImage
34+
class CatalogPage extends Page {
35+
constructor(project, menu) {
36+
super(project, menu);
37+
}
38+
getUrl() {
39+
// TODO: ?tab=tab=fromFile, ?tab=fromCatalog, ?tab=deployImage
4340
return 'project/' + this.project.name + '/create';
44-
},
45-
// TODO: push this up into Page, include a way to pass tab names to the constructor &
46-
// auto generate clickTab<name>() functions?
47-
_findTabs: function() {
48-
var tabs = element(by.css('.nav-tabs'));
41+
}
42+
_findTabs() {
43+
let tabs = element(by.css('.nav-tabs'));
4944
h.waitForElem(tabs);
5045
return tabs;
51-
},
52-
clickBrowseCatalog: function() {
46+
}
47+
clickBrowseCatalog() {
5348
return this._findTabs()
5449
.element(by.cssContainingText('a', 'Browse Catalog'))
5550
.click();
56-
},
57-
clickDeployImage: function() {
51+
}
52+
clickDeployImage() {
5853
return this._findTabs()
5954
.element(by.cssContainingText('a', 'Deploy Image'))
6055
.click();
61-
},
62-
clickImport: function() {
56+
}
57+
clickImport() {
6358
return this._findTabs()
6459
.element(by.cssContainingText('a', 'Import YAML / JSON'))
6560
.click();
66-
},
67-
setImportValue: function(str) {
68-
return browser.executeScript(function(value) {
61+
}
62+
setImportValue(str) {
63+
return browser.executeScript((value) => {
6964
window.ace.edit('add-component-editor').setValue(value);
7065
}, str);
71-
},
72-
getImportValue: function() {
73-
return browser.executeScript(function() {
66+
}
67+
getImportValue() {
68+
return browser.executeScript(() => {
7469
return window.ace.edit('add-component-editor').getValue();
7570
});
76-
},
77-
submitImport: function() {
71+
}
72+
submitImport() {
7873
element(by.cssContainingText('.btn-primary','Create')).click();
79-
return browser.sleep(500).then(function() {
74+
return browser.sleep(500).then(() => {
8075
return new AddTemplateModal(this.project);
81-
}.bind(this));
82-
},
83-
processTemplate: function(templateStr) {
76+
});
77+
}
78+
processTemplate(templateStr) {
8479
this.clickImport();
85-
return this.setImportValue(templateStr).then(function() {
86-
return this.submitImport().then(function(addTemplateModal) {
80+
return this.setImportValue(templateStr).then(() => {
81+
return this.submitImport().then((addTemplateModal) => {
8782
// implicit nav therefore returns new CreateFromTemplatePage()
8883
return addTemplateModal.process();
8984
});
90-
}.bind(this));
85+
});
9186
}
92-
});
87+
}
9388

9489
exports.CatalogPage = CatalogPage;
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,29 @@
11
'use strict';
22

3-
var h = require('../helpers');
4-
var scroll = require('../helpers/scroll');
5-
var _ = require('lodash');
6-
var Page = require('./page').Page;
7-
//var logger = require('../helpers/logger');
3+
const h = require('../helpers');
4+
const Page = require('./page').Page;
5+
const scroller = require('../helpers/scroll');
86

9-
var CreateFromTemplatePage = function(project, template) {
10-
this.project = project;
11-
this.template = template;
12-
};
13-
14-
_.extend(CreateFromTemplatePage.prototype, Page.prototype, {
15-
getUrl: function() {
16-
var url = 'project/' + this.project.name + '/create/fromtemplate';
7+
class CreateFromTemplatePage extends Page {
8+
constructor(project, menu) {
9+
super(project, menu);
10+
}
11+
getUrl() {
12+
let url = 'project/' + this.project.name + '/create/fromtemplate';
1713
if(this.template) {
1814
url += '?template='+this.template.name; //+'&namespace='; may need template namespace...
1915
}
2016
return url;
21-
},
22-
clickCreate: function() {
23-
scroll.toBottom();
24-
var button = element(by.buttonText('Create'));
17+
}
18+
clickCreate() {
19+
scroller.toBottom();
20+
let button = element(by.buttonText('Create'));
2521
h.waitForElem(button);
26-
return button.click().then(function() {
27-
return new require('./overview').OverviewPage(this.project);
28-
}.bind(this));
22+
return button.click().then(() => {
23+
const OverviewPage = require('./overview').OverviewPage;
24+
return new OverviewPage(this.project);
25+
});
2926
}
30-
});
27+
}
3128

3229
exports.CreateFromTemplatePage = CreateFromTemplatePage;
+17-21
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,32 @@
11
'use strict';
22

3-
var _ = require('lodash');
4-
var h = require('../helpers.js');
5-
var Page = require('./page').Page;
6-
var CatalogPage = require('./catalog').CatalogPage;
3+
const h = require('../helpers.js');
4+
const Page = require('./page').Page;
5+
const CatalogPage = require('./catalog').CatalogPage;
76

8-
var CreateProjectPage = function(project) {
9-
this.project = project;
10-
};
11-
12-
_.extend(CreateProjectPage.prototype, Page.prototype, {
13-
getUrl: function() {
7+
class CreateProjectPage extends Page {
8+
constructor(project, menu) {
9+
super(project, menu);
10+
}
11+
getUrl() {
1412
return 'create-project';
15-
},
16-
enterProjectInfo: function() {
17-
for (var key in this.project) {
13+
}
14+
enterProjectInfo() {
15+
for (let key in this.project) {
1816
h.waitForElem( element( by.model( key )));
1917
h.setInputValue(key, this.project[key]);
2018
}
2119
return this;
22-
},
23-
submit: function() {
24-
var button = element(by.buttonText('Create'));
20+
}
21+
submit() {
22+
let button = element(by.buttonText('Create'));
2523
button.click();
2624
return new CatalogPage(this.project);
27-
},
28-
// call createProject() so you dont have to do the above manally
29-
// returns a new CatalogPage()
30-
createProject: function() {
25+
}
26+
createProject() {
3127
this.enterProjectInfo();
3228
return this.submit();
3329
}
34-
});
30+
}
3531

3632
exports.CreateProjectPage = CreateProjectPage;
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
'use strict';
22

3-
var _ = require('lodash');
4-
var Page = require('./page').Page;
3+
const Page = require('./page').Page;
54

6-
var DeploymentsPage = function(project) {
7-
this.project = project;
8-
};
9-
10-
_.extend(DeploymentsPage.prototype, Page.prototype, {
11-
getUrl: function() {
5+
class DeploymentsPage extends Page {
6+
constructor(project, menu) {
7+
super(project, menu);
8+
}
9+
getUrl() {
1210
return 'project/' + this.project.name + '/browse/deployments';
1311
}
14-
});
12+
}
1513

1614
exports.DeploymentsPage = DeploymentsPage;

0 commit comments

Comments
 (0)