Fix tests

This commit is contained in:
Girish Ramakrishnan 2018-08-12 10:36:17 -07:00
parent 534e4884b4
commit 32cc8175e5
1 changed files with 22 additions and 8 deletions

View File

@ -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();
});