Improve tests, but still not working

This commit is contained in:
Johannes Zellner 2020-11-03 15:38:03 +01:00
parent 107c1abf30
commit b00ace5472
1 changed files with 20 additions and 13 deletions

View File

@ -39,17 +39,13 @@ describe('Application life cycle test', function () {
function getAppInfo() { function getAppInfo() {
var inspect = JSON.parse(execSync('cloudron inspect')); var inspect = JSON.parse(execSync('cloudron inspect'));
app = inspect.apps.filter(function (a) { return a.location === LOCATION || a.location === LOCATION + '2'; })[0]; app = inspect.apps.filter(function (a) { return a.location.indexOf(LOCATION) === 0; })[0];
expect(app).to.be.an('object'); expect(app).to.be.an('object');
} }
function pageLoaded() { function waitForElement(elem) {
return browser.wait(until.titleMatches(/[0-9a-f]{12} \| Syncthing/), TEST_TIMEOUT); return browser.wait(until.elementLocated(elem), TEST_TIMEOUT).then(function () {
} return browser.wait(until.elementIsVisible(browser.findElement(elem)), TEST_TIMEOUT);
function visible(selector) {
return browser.wait(until.elementLocated(selector), TEST_TIMEOUT).then(function () {
return browser.wait(until.elementIsVisible(browser.findElement(selector)), TEST_TIMEOUT);
}); });
} }
@ -63,13 +59,13 @@ describe('Application life cycle test', function () {
function loadPage(callback) { function loadPage(callback) {
browser.manage().deleteAllCookies().then(function () { browser.manage().deleteAllCookies().then(function () {
return browser.sleep(10000); return browser.sleep(5000);
}).then(function() { }).then(function() {
return browser.get('https://' + username + ':' + encodeURIComponent(password) + '@' + app.fqdn).then(function () { return browser.get('https://' + username + ':' + encodeURIComponent(password) + '@' + app.fqdn).then(function () {
return browser.get('https://' + app.fqdn); return browser.get('https://' + app.fqdn);
}); });
}).then(function () { }).then(function () {
return pageLoaded(); return waitForElement(By.xpath('//span[text()="Actions"]'));
}).then(function () { }).then(function () {
callback(); callback();
}); });
@ -79,7 +75,7 @@ describe('Application life cycle test', function () {
browser.get('https://' + app.fqdn).then(function () { browser.get('https://' + app.fqdn).then(function () {
return browser.findElement(By.css('[ng-click*=addFolder]')).click(); return browser.findElement(By.css('[ng-click*=addFolder]')).click();
}).then(function () { }).then(function () {
return visible(By.id('folderPath')); return waitForElement(By.id('folderPath'));
}).then(function () { }).then(function () {
return browser.sleep(4000); // wait more, not sure why this is needed return browser.sleep(4000); // wait more, not sure why this is needed
}).then(function() { }).then(function() {
@ -107,7 +103,7 @@ describe('Application life cycle test', function () {
function removeFolder(callback) { function removeFolder(callback) {
browser.get('https://' + app.fqdn).then(function () { browser.get('https://' + app.fqdn).then(function () {
return pageLoaded(); return waitForElement(By.xpath('//span[text()="Actions"]'));
}).then(function() { }).then(function() {
return browser.findElement(By.css('#folders button')).click(); return browser.findElement(By.css('#folders button')).click();
}).then(function () { }).then(function () {
@ -129,11 +125,17 @@ describe('Application life cycle test', function () {
}); });
} }
function wait (done) {
setTimeout(done, 10000);
}
xit('build app', function () { execSync('cloudron build', EXEC_ARGS); }); xit('build app', function () { execSync('cloudron build', EXEC_ARGS); });
it('install app', function () { execSync('cloudron install --port-bindings SYNC_PORT=' + SYNC_PORT + ' --location ' + LOCATION, EXEC_ARGS); }); it('install app', function () { execSync('cloudron install --port-bindings SYNC_PORT=' + SYNC_PORT + ' --location ' + LOCATION, EXEC_ARGS); });
it('can get app information', getAppInfo); it('can get app information', getAppInfo);
it('wait', wait);
it('fails with invalid password', invalidPassword); it('fails with invalid password', invalidPassword);
it('can load page', loadPage); it('can load page', loadPage);
it('can add folder', addFolder); it('can add folder', addFolder);
@ -141,6 +143,8 @@ describe('Application life cycle test', function () {
it('backup app', function () { execSync('cloudron backup create --app ' + app.id, EXEC_ARGS); }); it('backup app', function () { execSync('cloudron backup create --app ' + app.id, EXEC_ARGS); });
it('restore app', function () { execSync('cloudron restore --app ' + app.id, EXEC_ARGS); }); it('restore app', function () { execSync('cloudron restore --app ' + app.id, EXEC_ARGS); });
it('wait', wait);
it('can load page', loadPage); it('can load page', loadPage);
it('can check folder', checkFolder); it('can check folder', checkFolder);
@ -153,6 +157,8 @@ describe('Application life cycle test', function () {
}); });
it('can get app information', getAppInfo); it('can get app information', getAppInfo);
it('wait', wait);
it('can load page', loadPage); it('can load page', loadPage);
it('can check folder', checkFolder); it('can check folder', checkFolder);
it('can remove folder', removeFolder); it('can remove folder', removeFolder);
@ -167,10 +173,11 @@ describe('Application life cycle test', function () {
// test update // test update
it('can install app', function () { execSync('cloudron install --port-bindings SYNC_PORT=' + SYNC_PORT + ' --appstore-id net.syncthing.cloudronapp2 --location ' + LOCATION, EXEC_ARGS); }); it('can install app', function () { execSync('cloudron install --port-bindings SYNC_PORT=' + SYNC_PORT + ' --appstore-id net.syncthing.cloudronapp2 --location ' + LOCATION, EXEC_ARGS); });
it('can get app information', getAppInfo); it('can get app information', getAppInfo);
it('wait', wait);
it('can load page', loadPage); it('can load page', loadPage);
it('can add folder', addFolder); it('can add folder', addFolder);
it('can update', function () { execSync('cloudron update --app ' + LOCATION, EXEC_ARGS); }); it('can update', function () { execSync('cloudron update --app ' + LOCATION, EXEC_ARGS); });
it('wait for app to startup fully', function (done) { setTimeout(done, 10000); }); it('wait', wait);
it('can check folder', checkFolder); it('can check folder', checkFolder);
it('uninstall app', function (done) { it('uninstall app', function (done) {