From b00ace547253326a78c3afeff57e3579a891a22c Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Tue, 3 Nov 2020 15:38:03 +0100 Subject: [PATCH] Improve tests, but still not working --- test/test.js | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/test/test.js b/test/test.js index a983471..47ce46b 100644 --- a/test/test.js +++ b/test/test.js @@ -39,17 +39,13 @@ describe('Application life cycle test', function () { function getAppInfo() { 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'); } - function pageLoaded() { - return browser.wait(until.titleMatches(/[0-9a-f]{12} \| Syncthing/), 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); + function waitForElement(elem) { + return browser.wait(until.elementLocated(elem), TEST_TIMEOUT).then(function () { + return browser.wait(until.elementIsVisible(browser.findElement(elem)), TEST_TIMEOUT); }); } @@ -63,13 +59,13 @@ describe('Application life cycle test', function () { function loadPage(callback) { browser.manage().deleteAllCookies().then(function () { - return browser.sleep(10000); + return browser.sleep(5000); }).then(function() { return browser.get('https://' + username + ':' + encodeURIComponent(password) + '@' + app.fqdn).then(function () { return browser.get('https://' + app.fqdn); }); }).then(function () { - return pageLoaded(); + return waitForElement(By.xpath('//span[text()="Actions"]')); }).then(function () { callback(); }); @@ -79,7 +75,7 @@ describe('Application life cycle test', function () { browser.get('https://' + app.fqdn).then(function () { return browser.findElement(By.css('[ng-click*=addFolder]')).click(); }).then(function () { - return visible(By.id('folderPath')); + return waitForElement(By.id('folderPath')); }).then(function () { return browser.sleep(4000); // wait more, not sure why this is needed }).then(function() { @@ -107,7 +103,7 @@ describe('Application life cycle test', function () { function removeFolder(callback) { browser.get('https://' + app.fqdn).then(function () { - return pageLoaded(); + return waitForElement(By.xpath('//span[text()="Actions"]')); }).then(function() { return browser.findElement(By.css('#folders button')).click(); }).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); }); it('install app', function () { execSync('cloudron install --port-bindings SYNC_PORT=' + SYNC_PORT + ' --location ' + LOCATION, EXEC_ARGS); }); it('can get app information', getAppInfo); + it('wait', wait); + it('fails with invalid password', invalidPassword); it('can load page', loadPage); 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('restore app', function () { execSync('cloudron restore --app ' + app.id, EXEC_ARGS); }); + it('wait', wait); + it('can load page', loadPage); it('can check folder', checkFolder); @@ -153,6 +157,8 @@ describe('Application life cycle test', function () { }); it('can get app information', getAppInfo); + it('wait', wait); + it('can load page', loadPage); it('can check folder', checkFolder); it('can remove folder', removeFolder); @@ -167,10 +173,11 @@ describe('Application life cycle test', function () { // 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 get app information', getAppInfo); + it('wait', wait); it('can load page', loadPage); it('can add folder', addFolder); 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('uninstall app', function (done) {