Fixup tests for base url and password

This commit is contained in:
Girish Ramakrishnan 2019-01-03 16:36:12 -08:00
parent 9ca04c0e8c
commit 213e1e740f
1 changed files with 35 additions and 18 deletions

View File

@ -14,8 +14,7 @@ var by = webdriver.By,
until = webdriver.until;
var username = 'admin',
password = 'password';
password = 'changeme';
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
@ -55,8 +54,26 @@ describe('Application life cycle test', function () {
});
}
function login(callback) {
browser.manage().deleteAllCookies().then(function () {
function baseUrl() {
if (app.manifest.version === '1.4.0') return `https://${app.fqdn}/p`;
return `https://${app.fqdn}`;
}
// we do this because it perm redirects to /p/ in old versions
function clearCache() {
// https://stackoverflow.com/questions/49614217/selenium-clear-chrome-cache
// defaut clearance is 1 hour of cache
return browser.get('chrome://settings/clearBrowserData').then(function () {
return visible(by.css('* /deep/ #clearBrowsingDataConfirm'));
}).then(function () {
return browser.findElement(by.css('* /deep/ #clearBrowsingDataConfirm')).click();
}).then(function () {
return browser.sleep(5000);
});
}
function login(password, callback) {
clearCache().then(function () {
return browser.get('https://' + app.fqdn);
}).then(function () {
return visible(by.id('loginButton'));
@ -94,7 +111,7 @@ describe('Application life cycle test', function () {
function addSubscription(callback) {
var url = "https://cloudron.io/blog/rss.xml";
browser.get(`https://${app.fqdn}/p/i/?c=subscription`).then(function () {
browser.get(`${baseUrl()}/i/?c=subscription`).then(function () {
return visible(by.xpath('//input[@name="url_rss"]'));
}).then(function () {
return browser.findElement(by.xpath('//input[@name="url_rss"]')).sendKeys(url);
@ -107,10 +124,10 @@ describe('Application life cycle test', function () {
});
}
function addUser(callback) {
function addUser(password, callback) {
var test_username = 'test';
browser.get(`https://${app.fqdn}/p/i/?c=user&a=manage`).then(function () {
browser.get(`${baseUrl()}/i/?c=user&a=manage`).then(function () {
return visible(by.id('new_user_name'));
}).then(function () {
return browser.findElement(by.id('new_user_name')).sendKeys(test_username);
@ -126,7 +143,7 @@ describe('Application life cycle test', function () {
}
function enableApi(callback) {
browser.get('https://' + app.fqdn + '/p/i/?c=auth').then(function () {
browser.get(`${baseUrl()}/i/?c=auth`).then(function () {
return browser.findElement(by.id('api_enabled')).click();
}).then(function () {
return browser.findElement(by.xpath('//button[text()="Submit"]')).submit();
@ -136,7 +153,7 @@ describe('Application life cycle test', function () {
}
function checkApiConfiguration(callback) {
browser.get('https://' + app.fqdn + '/p/api/greader.php/check%2Fcompatibility').then(function () {
browser.get(`${baseUrl()}/api/greader.php/check%2Fcompatibility`).then(function () {
return exists(by.xpath('//pre[text()="PASS"]'));
}).then(function () {
callback();
@ -150,7 +167,7 @@ describe('Application life cycle test', function () {
}
function subscriptionExists(callback) {
browser.get('https://' + app.fqdn + '/p/i/?get=c_1').then(function () {
browser.get(`${baseUrl()}/i/?get=c_1`).then(function () {
return visible(by.xpath('//a[text()="Cloudron.io"]'));
}).then(function () {
callback();
@ -158,7 +175,7 @@ describe('Application life cycle test', function () {
}
function getStaticExtensionFile(callback) {
superagent.get(`https://${app.fqdn}/p/ext.php?f=xExtension-StickyFeeds/static/script.js&t=js`)
superagent.get(`${baseUrl()}/ext.php?f=xExtension-StickyFeeds/static/script.js&t=js`)
.buffer(true)
.end(function (err, res) {
expect(err).to.be(null);
@ -178,9 +195,9 @@ describe('Application life cycle test', function () {
it('can get app information', getAppInfo);
it('can login', login);
it('can login', login.bind(null, password));
it('can subscribe', addSubscription);
it('can add users', addUser);
it('can add users', addUser.bind(null, password));
it('can enable API', enableApi);
it('can check configuration', checkApiConfiguration);
it('subscription exists', subscriptionExists);
@ -195,7 +212,7 @@ describe('Application life cycle test', function () {
execSync('cloudron restore --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
});
it('can login', login);
it('can login', login.bind(null, password));
it('can check configuration', checkApiConfiguration);
it('subscription exists', subscriptionExists);
it('can get static extension file', getStaticExtensionFile);
@ -209,7 +226,7 @@ describe('Application life cycle test', function () {
expect(app).to.be.an('object');
});
it('can login', login);
it('can login', login.bind(null, password));
it('can check configuration', checkApiConfiguration);
it('subscription exists', subscriptionExists);
it('can get static extension file', getStaticExtensionFile);
@ -225,9 +242,9 @@ describe('Application life cycle test', function () {
});
it('can get app information', getAppInfo);
it('can login', login);
it('can login', login.bind(null, 'password'));
it('can subscribe', addSubscription);
it('can add users', addUser);
it('can add users', addUser.bind(null, password));
it('can update', function () {
execSync('cloudron install --wait --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
@ -236,7 +253,7 @@ describe('Application life cycle test', function () {
expect(app).to.be.an('object');
});
it('can login', login);
it('can login', login.bind(null, 'password'));
it('subscription exists', subscriptionExists);
it('can get static extension file', getStaticExtensionFile);