|
@@ -44,16 +44,24 @@ describe('Application life cycle test', function () {
|
|
|
function login(done) {
|
|
|
browser.manage().window().setSize(1280,768);
|
|
|
browser.manage().deleteAllCookies();
|
|
|
- browser.get('https://' + app.fqdn + '/login');
|
|
|
- browser.executeScript('localStorage.clear();')
|
|
|
-
|
|
|
- browser.get('https://' + app.fqdn + '/login');
|
|
|
- browser.sleep(5000); // takes some time for username to be visible
|
|
|
- browser.wait(until.elementLocated(by.id('username')), TEST_TIMEOUT).then(function () {
|
|
|
- browser.findElement(by.id('username')).sendKeys(username);
|
|
|
- browser.findElement(by.id('password')).sendKeys(password);
|
|
|
- browser.findElement(by.id('login')).click();
|
|
|
- browser.wait(until.elementLocated(by.xpath('//a[contains(text(), "Announcements")]')), TEST_TIMEOUT).then(function () { done(); });
|
|
|
+ browser.get('https://' + app.fqdn + '/login').then(function () {
|
|
|
+ return browser.executeScript('localStorage.clear();');
|
|
|
+ }).then(function () {
|
|
|
+ return browser.get('https://' + app.fqdn + '/login');
|
|
|
+ }).then(function () {
|
|
|
+ return browser.sleep(5000); // takes some time for username to be visible
|
|
|
+ }).then(function () {
|
|
|
+ return browser.wait(until.elementLocated(by.id('username')), TEST_TIMEOUT);
|
|
|
+ }).then(function () {
|
|
|
+ return browser.findElement(by.id('username')).sendKeys(username);
|
|
|
+ }).then(function () {
|
|
|
+ return browser.findElement(by.id('password')).sendKeys(password);
|
|
|
+ }).then(function () {
|
|
|
+ return browser.findElement(by.id('login')).click();
|
|
|
+ }).then(function () {
|
|
|
+ return browser.wait(until.elementLocated(by.xpath('//a[contains(text(), "Announcements")]')), TEST_TIMEOUT);
|
|
|
+ }).then(function () {
|
|
|
+ done();
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -97,51 +105,59 @@ describe('Application life cycle test', function () {
|
|
|
}
|
|
|
|
|
|
function activateCustomPlugin(done) {
|
|
|
- browser.get('https://' + app.fqdn + '/admin/extend/plugins#installed');
|
|
|
- browser.wait(until.elementLocated(by.xpath('//ul[contains(@class, "installed")]//strong[text()="nodebb-plugin-beep"]')), TEST_TIMEOUT).then(function () {
|
|
|
+ browser.get('https://' + app.fqdn + '/admin/extend/plugins#installed').then(function () {
|
|
|
+ return browser.wait(until.elementLocated(by.xpath('//ul[contains(@class, "installed")]//strong[text()="nodebb-plugin-beep"]')), TEST_TIMEOUT);
|
|
|
+ }).then(function () {
|
|
|
return browser.sleep(10000);
|
|
|
}).then(function () {
|
|
|
return browser.findElement(by.xpath('//li[@id="nodebb-plugin-beep"]//button[@data-action="toggleActive"]')).click(); // activate the plugin
|
|
|
}).then(function () {
|
|
|
- browser.sleep(20000).then(function() { done(); }); // wait for the action to succeed
|
|
|
+ return browser.sleep(20000); // wait for the action to succeed
|
|
|
+ }).then(function() {
|
|
|
+ done();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function listCustomPlugin(done) {
|
|
|
- browser.get('https://' + app.fqdn + '/admin/extend/plugins#installed');
|
|
|
- browser.wait(until.elementLocated(by.xpath('//strong[text()="nodebb-plugin-beep"]')), TEST_TIMEOUT).then(function () {
|
|
|
+ browser.get('https://' + app.fqdn + '/admin/extend/plugins#installed').then(function () {
|
|
|
+ return browser.wait(until.elementLocated(by.xpath('//strong[text()="nodebb-plugin-beep"]')), TEST_TIMEOUT);
|
|
|
+ }).then(function () {
|
|
|
done();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function uploadImage(done) {
|
|
|
- browser.get('https://' + app.fqdn + '/user/admin/edit');
|
|
|
- browser.wait(until.elementLocated(by.xpath('//a[text()="Change Picture"]')), TEST_TIMEOUT).then(function () {
|
|
|
- browser.findElement(by.xpath('//a[text()="Change Picture"]')).click().then(function () {
|
|
|
- return browser.sleep(4000);
|
|
|
- }).then(function () {
|
|
|
- return browser.findElement(by.xpath('//button[@data-action="upload"]')).click();
|
|
|
- }).then(function () {
|
|
|
- return browser.sleep(4000);
|
|
|
- }).then(function () {
|
|
|
- return browser.findElement(by.xpath('//input[@type="file"]')).sendKeys(path.resolve(__dirname, '../logo.png'));
|
|
|
- }).then(function () {
|
|
|
- browser.sleep(3000);
|
|
|
- }).then(function () { // upload it
|
|
|
- return browser.findElement(by.id('fileUploadSubmitBtn')).click();
|
|
|
- }).then(function () {
|
|
|
- browser.sleep(3000);
|
|
|
- }).then(function () {
|
|
|
- return browser.findElement(by.xpath('//button[text()="Crop and upload"]')).click();
|
|
|
- }).then(function () {
|
|
|
- browser.sleep(3000).then(function () { done(); });
|
|
|
- });
|
|
|
+ browser.get('https://' + app.fqdn + '/user/admin/edit').then(function () {
|
|
|
+ return browser.wait(until.elementLocated(by.xpath('//a[text()="Change Picture"]')), TEST_TIMEOUT);
|
|
|
+ }).then(function () {
|
|
|
+ return browser.findElement(by.xpath('//a[text()="Change Picture"]')).click();
|
|
|
+ }).then(function () {
|
|
|
+ return browser.sleep(4000);
|
|
|
+ }).then(function () {
|
|
|
+ return browser.findElement(by.xpath('//button[@data-action="upload"]')).click();
|
|
|
+ }).then(function () {
|
|
|
+ return browser.sleep(4000);
|
|
|
+ }).then(function () {
|
|
|
+ return browser.findElement(by.xpath('//input[@type="file"]')).sendKeys(path.resolve(__dirname, '../logo.png'));
|
|
|
+ }).then(function () {
|
|
|
+ browser.sleep(3000);
|
|
|
+ }).then(function () { // upload it
|
|
|
+ return browser.findElement(by.id('fileUploadSubmitBtn')).click();
|
|
|
+ }).then(function () {
|
|
|
+ browser.sleep(3000);
|
|
|
+ }).then(function () {
|
|
|
+ return browser.findElement(by.xpath('//button[text()="Crop and upload"]')).click();
|
|
|
+ }).then(function () {
|
|
|
+ return browser.sleep(3000);
|
|
|
+ }).then(function () {
|
|
|
+ done();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function checkImage(done) {
|
|
|
- browser.get('https://' + app.fqdn + '/user/admin');
|
|
|
- browser.wait(until.elementLocated(by.xpath('//img[@src="/assets/uploads/profile/1-profileavatar.png"]')), TEST_TIMEOUT).then(function () {
|
|
|
+ browser.get('https://' + app.fqdn + '/user/admin').then(function () {
|
|
|
+ return browser.wait(until.elementLocated(by.xpath('//img[@src="/assets/uploads/profile/1-profileavatar.png"]')), TEST_TIMEOUT);
|
|
|
+ }).then(function () {
|
|
|
var img = browser.findElement(by.xpath('//img[@src="/assets/uploads/profile/1-profileavatar.png"]'));
|
|
|
return browser.executeScript('return arguments[0].complete && arguments[0].naturalWidth', img);
|
|
|
}).then(function (imageWidth) {
|