Skip to content

Commit fd6d24d

Browse files
Update addTemplateModal fn to class, extract to separate file
1 parent 295a6c8 commit fd6d24d

File tree

2 files changed

+38
-31
lines changed

2 files changed

+38
-31
lines changed

test/integration/page-objects/catalog.js

+1-31
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,8 @@
11
'use strict';
22

33
const h = require('../helpers.js');
4-
const inputs = require('../helpers/inputs');
54
const Page = require('./page').Page;
6-
7-
let AddTemplateModal = function(project) {
8-
this.project = project;
9-
this.modal = element(by.css('.modal-dialog'));
10-
this.checkboxes = this.modal.all(by.css('input[type="checkbox"]'));
11-
this.processBox = this.checkboxes.get(0);
12-
this.saveBox = this.checkboxes.get(1);
13-
this.continue = this.modal.element(by.cssContainingText('.btn-primary', 'Continue'));
14-
this.cancel = this.modal.element(by.cssContainingText('.btn-default', 'Cancel'));
15-
this.process = function() {
16-
inputs.check(this.processBox);
17-
inputs.uncheck(this.saveBox);
18-
this.continue.click();
19-
return browser.sleep(500).then(function() {
20-
// lazy require to avoid potential of circular dependencies
21-
var CreateFromTemplatePage = require('./createFromTemplate').CreateFromTemplatePage;
22-
return new CreateFromTemplatePage(this.project);
23-
}.bind(this));
24-
};
25-
this.save = function() {
26-
inputs.uncheck(this.processBox);
27-
inputs.check(this.saveBox);
28-
this.continue.click();
29-
return browser.sleep(500).then(() => {
30-
// lazy require
31-
var OverviewPage = require('./overview').OverviewPage;
32-
return new OverviewPage(this.project); // automatic redirect
33-
});
34-
};
35-
};
5+
const AddTemplateModal = require('./modals/addTemplateModal').AddTemplateModal;
366

377
class CatalogPage extends Page {
388
constructor(project, menu) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict';
2+
3+
const inputs = require('../../helpers/inputs');
4+
5+
class AddTemplateModal {
6+
constructor(project) {
7+
this.project = project;
8+
this.modal = element(by.css('.modal-dialog'));
9+
this.checkboxes = this.modal.all(by.css('input[type="checkbox"]'));
10+
this.processBox = this.checkboxes.get(0);
11+
this.saveBox = this.checkboxes.get(1);
12+
this.continue = this.modal.element(by.cssContainingText('.btn-primary', 'Continue'));
13+
this.cancel = this.modal.element(by.cssContainingText('.btn-default', 'Cancel'));
14+
}
15+
process() {
16+
inputs.check(this.processBox);
17+
inputs.uncheck(this.saveBox);
18+
this.continue.click();
19+
return browser.sleep(500).then(() => {
20+
// lazy require to avoid potential of circular dependencies
21+
let CreateFromTemplatePage = require('./createFromTemplate').CreateFromTemplatePage;
22+
return new CreateFromTemplatePage(this.project);
23+
});
24+
}
25+
save() {
26+
inputs.uncheck(this.processBox);
27+
inputs.check(this.saveBox);
28+
this.continue.click();
29+
return browser.sleep(500).then(() => {
30+
// lazy require
31+
let OverviewPage = require('./overview').OverviewPage;
32+
return new OverviewPage(this.project); // automatic redirect
33+
});
34+
}
35+
}
36+
37+
exports.AddTemplateModal = AddTemplateModal;

0 commit comments

Comments
 (0)