asyncify
This commit is contained in:
parent
67383ed187
commit
ae4e726aa9
121
test/test.js
121
test/test.js
|
@ -5,6 +5,7 @@
|
||||||
/* global before */
|
/* global before */
|
||||||
/* global after */
|
/* global after */
|
||||||
/* global it */
|
/* global it */
|
||||||
|
/* global xit */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -15,7 +16,7 @@ const execSync = require('child_process').execSync,
|
||||||
superagent = require('superagent'),
|
superagent = require('superagent'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
timers = require('timers/promises'),
|
timers = require('timers/promises'),
|
||||||
{ Builder, By, Key, until } = require('selenium-webdriver'),
|
{ Builder, By, until } = require('selenium-webdriver'),
|
||||||
{ Options } = require('selenium-webdriver/chrome');
|
{ Options } = require('selenium-webdriver/chrome');
|
||||||
|
|
||||||
describe('Application life cycle test', function () {
|
describe('Application life cycle test', function () {
|
||||||
|
@ -44,94 +45,56 @@ describe('Application life cycle test', function () {
|
||||||
expect(app).to.be.an('object');
|
expect(app).to.be.an('object');
|
||||||
}
|
}
|
||||||
|
|
||||||
function waitForElement(elem) {
|
async function waitForElement(elem) {
|
||||||
return browser.wait(until.elementLocated(elem), TEST_TIMEOUT).then(function () {
|
await browser.wait(until.elementLocated(elem), TEST_TIMEOUT);
|
||||||
return browser.wait(until.elementIsVisible(browser.findElement(elem)), TEST_TIMEOUT);
|
await browser.wait(until.elementIsVisible(browser.findElement(elem)), TEST_TIMEOUT);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function invalidPassword(callback) {
|
async function invalidPassword() {
|
||||||
superagent.get('https://' + app.fqdn).auth(username, password + 'x').end(function (error, result) {
|
const result = await superagent.get('https://' + app.fqdn).auth(username, password + 'x').ok(() => true);
|
||||||
expect(result.status).to.eql(401);
|
expect(result.statusCode).to.eql(401);
|
||||||
|
|
||||||
callback();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadPage(callback) {
|
async function loadPage() {
|
||||||
browser.manage().deleteAllCookies().then(function () {
|
await browser.manage().deleteAllCookies();
|
||||||
return browser.sleep(5000);
|
await browser.sleep(5000);
|
||||||
}).then(function() {
|
await browser.get('https://' + username + ':' + encodeURIComponent(password) + '@' + app.fqdn);
|
||||||
return browser.get('https://' + username + ':' + encodeURIComponent(password) + '@' + app.fqdn).then(function () {
|
await browser.get('https://' + app.fqdn);
|
||||||
return browser.get('https://' + app.fqdn);
|
await browser.sleep(5000);
|
||||||
});
|
await browser.get('https://' + app.fqdn);
|
||||||
}).then(function () {
|
await waitForElement(By.xpath('//span[text()="Actions"]'));
|
||||||
return browser.sleep(5000);
|
|
||||||
}).then(function () {
|
|
||||||
return browser.get('https://' + app.fqdn);
|
|
||||||
}).then(function () {
|
|
||||||
return waitForElement(By.xpath('//span[text()="Actions"]'));
|
|
||||||
}).then(function () {
|
|
||||||
callback();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function addFolder(callback) {
|
async function addFolder() {
|
||||||
browser.get('https://' + app.fqdn).then(function () {
|
await browser.get('https://' + app.fqdn);
|
||||||
return browser.findElement(By.css('[ng-click*=addFolder]')).click();
|
await browser.findElement(By.css('[ng-click*=addFolder]')).click();
|
||||||
}).then(function () {
|
await waitForElement(By.id('folderPath'));
|
||||||
return waitForElement(By.id('folderPath'));
|
await browser.sleep(4000); // wait more, not sure why this is needed
|
||||||
}).then(function () {
|
await browser.findElement(By.id('folderLabel')).sendKeys(FOLDER);
|
||||||
return browser.sleep(4000); // wait more, not sure why this is needed
|
await browser.sleep(4000); // without this sometimes only part of the folder name gets through
|
||||||
}).then(function() {
|
await browser.findElement(By.css('[ng-click*=saveFolder]')).click();
|
||||||
return browser.findElement(By.id('folderLabel')).sendKeys(FOLDER);
|
await browser.wait(until.elementLocated(By.css('#folders .panel-status span[ng-switch-when=unshared]')), TEST_TIMEOUT);
|
||||||
}).then(function () {
|
await browser.sleep(4000);
|
||||||
return browser.sleep(4000); // without this sometimes only part of the folder name gets through
|
|
||||||
}).then(function() {
|
|
||||||
return browser.findElement(By.css('[ng-click*=saveFolder]')).click();
|
|
||||||
}).then(function() {
|
|
||||||
return browser.wait(until.elementLocated(By.css('#folders .panel-status span[ng-switch-when=unshared]')), TEST_TIMEOUT);
|
|
||||||
}).then(function () {
|
|
||||||
return browser.sleep(4000);
|
|
||||||
}).then(function() {
|
|
||||||
callback();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkFolder(callback) {
|
async function checkFolder() {
|
||||||
browser.get('https://' + app.fqdn).then(function () {
|
await browser.get('https://' + app.fqdn);
|
||||||
return browser.sleep(5000);
|
await browser.sleep(5000);
|
||||||
}).then(function () {
|
await browser.get('https://' + app.fqdn);
|
||||||
return browser.get('https://' + app.fqdn);
|
await browser.wait(until.elementLocated(By.xpath(`//span[text()="${FOLDER}"]`)), TEST_TIMEOUT);
|
||||||
}).then(function () {
|
|
||||||
return browser.wait(until.elementLocated(By.xpath(`//span[text()="${FOLDER}"]`)), TEST_TIMEOUT);
|
|
||||||
}).then(function () {
|
|
||||||
callback();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeFolder(callback) {
|
async function removeFolder() {
|
||||||
browser.get('https://' + app.fqdn).then(function () {
|
await browser.get('https://' + app.fqdn);
|
||||||
return waitForElement(By.xpath('//span[text()="Actions"]'));
|
await waitForElement(By.xpath('//span[text()="Actions"]'));
|
||||||
}).then(function() {
|
await browser.findElement(By.css('#folders button')).click();
|
||||||
return browser.findElement(By.css('#folders button')).click();
|
await browser.sleep(3000); //No way to check for visibility of angular-js components
|
||||||
}).then(function () {
|
await browser.findElement(By.css('#folder-0 button[ng-click*=editFolder]')).click();
|
||||||
return browser.sleep(3000); //No way to check for visibility of angular-js components
|
await browser.sleep(3000); //No way to check for visibility of angular-js components
|
||||||
}).then(function () {
|
await browser.findElement(By.xpath('//button[@data-target="#remove-folder-confirmation"]')).click();
|
||||||
return browser.findElement(By.css('#folder-0 button[ng-click*=editFolder]')).click();
|
await browser.sleep(3000); //No way to check for visibility of angular-js components
|
||||||
}).then(function () {
|
await browser.findElement(By.css('[ng-click*=deleteFolder]')).click();
|
||||||
return browser.sleep(3000); //No way to check for visibility of angular-js components
|
await browser.sleep(3000); //This needs to run for some time
|
||||||
}).then(function () {
|
|
||||||
return browser.findElement(By.xpath('//button[@data-target="#remove-folder-confirmation"]')).click();
|
|
||||||
}).then(function () {
|
|
||||||
return browser.sleep(3000); //No way to check for visibility of angular-js components
|
|
||||||
}).then(function () {
|
|
||||||
return browser.findElement(By.css('[ng-click*=deleteFolder]')).click();
|
|
||||||
}).then(function () {
|
|
||||||
return browser.sleep(3000); //This needs to run for some time
|
|
||||||
}).then(function () {
|
|
||||||
callback();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
xit('build app', function () { execSync('cloudron build', EXEC_ARGS); });
|
xit('build app', function () { execSync('cloudron build', EXEC_ARGS); });
|
||||||
|
|
Loading…
Reference in New Issue