From 32cc8175e51c88679601d09bfebb0479e5a18947 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Sun, 12 Aug 2018 10:36:17 -0700 Subject: [PATCH] Fix tests --- test/test.js | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/test/test.js b/test/test.js index 15de6b2..ff13750 100755 --- a/test/test.js +++ b/test/test.js @@ -73,7 +73,7 @@ describe('Application life cycle test', function () { expect(app).to.be.an('object'); } - function setAvatar(done) { + function setAvatarOld(done) { browser.get('https://' + app.fqdn + '/user/settings/avatar').then(function () { return browser.findElement(by.xpath('//input[@type="file" and @name="avatar"]')).sendKeys(path.resolve(__dirname, '../logo.png')); }).then(function () { @@ -89,6 +89,25 @@ describe('Application life cycle test', function () { }); } + function setAvatar(done) { + if (app.manifest.version === '1.5.4') return setAvatarOld(done); + + browser.get('https://' + app.fqdn + '/user/settings').then(function () { + var button = browser.findElement(by.xpath('//label[contains(text(), "Use Custom Avatar")]')); + return browser.executeScript('arguments[0].scrollIntoView(false)', button); + }).then(function () { + return browser.findElement(by.xpath('//label[contains(text(), "Use Custom Avatar")]')).click(); + }).then(function () { + return browser.findElement(by.xpath('//input[@type="file" and @name="avatar"]')).sendKeys(path.resolve(__dirname, '../logo.png')); + }).then(function () { + return browser.findElement(by.xpath('//button[contains(text(), "Update Avatar")]')).click(); + }).then(function () { + return browser.wait(until.elementLocated(by.xpath('//p[contains(text(),"Your avatar has been updated.")]')), TIMEOUT); + }).then(function () { + done(); + }); + } + function checkAvatar(done) { return done(); superagent.get('https://' + app.fqdn + '/avatars/a3e6f3316fc1738e29d621e6a26e93d3').end(function (error, result) { @@ -129,12 +148,7 @@ return done(); function addPublicKey(done) { var publicKey = fs.readFileSync(__dirname + '/id_rsa.pub', 'utf8'); - var sshPage; - if (app.manifest.version === '1.0.3') { - sshPage = 'https://' + app.fqdn + '/user/settings/ssh'; - } else { - sshPage = 'https://' + app.fqdn + '/user/settings/keys'; - } + const sshPage = 'https://' + app.fqdn + '/user/settings/keys'; browser.get(sshPage).then(function () { return browser.findElement(by.xpath('//div[text()="Add Key"]')).click(); @@ -248,7 +262,7 @@ return done(); }).then(function () { return browser.findElement(by.xpath('//button[@id="test-mail-btn"]')).click(); }).then(function () { - return browser.wait(until.elementLocated(by.xpath('//p[contains(text(),"Test email has been sent to \'test@cloudron.io\'")]')), TIMEOUT); + return browser.wait(until.elementLocated(by.xpath('//p[contains(text(),"A testing email has been sent to \'test@cloudron.io\'")]')), TIMEOUT); }).then(function () { done(); });