Fixup tests

This commit is contained in:
Girish Ramakrishnan 2020-01-23 12:56:15 -08:00
parent 5a6abbbe4c
commit eb77f8d155
3 changed files with 1287 additions and 483 deletions

1680
test/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -9,16 +9,16 @@
"author": "",
"license": "ISC",
"devDependencies": {
"ejs": "^2.3.4",
"ejs": "^3.0.1",
"expect.js": "^0.3.1",
"mkdirp": "^0.5.1",
"mocha": "^2.3.4",
"rimraf": "^2.4.4",
"selenium-server-standalone-jar": "^2.53.0",
"selenium-webdriver": "^2.53.3",
"superagent": "^1.4.0"
"mocha": "^7.0.0",
"rimraf": "^3.0.0",
"selenium-server-standalone-jar": "^3.141.59",
"selenium-webdriver": "^3.6.0",
"superagent": "^5.2.1"
},
"dependencies": {
"chromedriver": "^2.37.0"
"chromedriver": "^79.0.0"
}
}

View file

@ -18,17 +18,17 @@ var execSync = require('child_process').execSync,
superagent = require('superagent'),
webdriver = require('selenium-webdriver');
var by = webdriver.By,
Keys = webdriver.Key,
until = webdriver.until;
var by = require('selenium-webdriver').By,
until = require('selenium-webdriver').until,
Builder = require('selenium-webdriver').Builder;
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
describe('Application life cycle test', function () {
this.timeout(0);
var chrome = require('selenium-webdriver/chrome');
var server, browser = new chrome.Driver(), uploadedImageUrl;
var server, browser = new Builder().forBrowser('chrome').build();
var uploadedImageUrl;
var username = process.env.USERNAME, password = process.env.PASSWORD;
before(function (done) {
@ -60,33 +60,37 @@ describe('Application life cycle test', function () {
}
function checkRegistration(mode, done) {
return browser.get('https://' + app.fqdn).then(function () {
browser.get('https://' + app.fqdn).then(function () {
return browser.sleep(2000);
}).then(function () {
if (mode === 'none') {
return browser.wait(until.elementLocated(by.xpath('//button[contains(text(), "is not accepting new members")]')), TIMEOUT);
} else if (mode === 'open') {
return browser.wait(until.elementLocated(by.xpath('//button[contains(text(), "Sign up")]')), TIMEOUT);
}
}).then(function () {
done();
});
}
function login(done) {
return browser.get('https://' + app.fqdn).then(function () {
function login(username, password, done) {
browser.get('https://' + app.fqdn + '/about').then(function () { // there is also separate login page at /users/sign_in
return browser.wait(until.elementLocated(by.xpath('//button[contains(text(), "Log in")]')), TIMEOUT);
}).then(function (done) {
return browser.findElement(by.id('user_email')).sendKeys(username);
return browser.findElement(by.id('login_user_email')).sendKeys(username);
}).then(function () {
return browser.findElement(by.id('user_password')).sendKeys(password);
return browser.findElement(by.id('login_user_password')).sendKeys(password);
}).then(function () {
return browser.findElement(by.xpath('//button[contains(text(), "Log in")]')).click();
}).then(function () {
return browser.sleep(2000);
}).then(function () {
return browser.wait(until.elementLocated(by.xpath('//span[contains(text(), "Welcome to the fediverse")]')), TIMEOUT);
}).then(function () {
return browser.findElement(by.xpath('//span[contains(text(), "Let\'s go")]')).click();
return browser.sleep(3000); // can be wizard or timeline at this point
}).then(function () {
return done();
});
}
function skipTutorial(done) {
browser.findElement(by.xpath('//span[contains(text(), "Let\'s go")]')).click().then(function () {
return browser.sleep(2000);
}).then(function () {
return browser.findElement(by.xpath('//span[contains(text(), "Next")]')).click();
@ -95,14 +99,18 @@ describe('Application life cycle test', function () {
}).then(function () {
return browser.findElement(by.xpath('//span[contains(text(), "Finish tutorial!")]')).click();
}).then(function () {
return browser.sleep(2000);
return browser.sleep(3000);
}).then(function () {
return browser.findElement(by.xpath('//a/span[contains(text(), "the public timeline")]')).click();
}).then(function () {
return browser.sleep(3000);
}).then(function () {
done();
});
}
function checkTimeline(done) {
return browser.get('https://' + app.fqdn + '/web/timelines/home').then(function () {
browser.get('https://' + app.fqdn + '/web/timelines/home').then(function () {
return browser.wait(until.elementLocated(by.xpath('//span[contains(text(), "Your home timeline is empty")]')), TIMEOUT);
}).then(function () {
done();
@ -114,7 +122,7 @@ describe('Application life cycle test', function () {
});
it('install app', function () {
execSync('cloudron install --new --wait --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
execSync('cloudron install --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
});
it('can get app information', function () {
@ -125,7 +133,8 @@ describe('Application life cycle test', function () {
expect(app).to.be.an('object');
});
it('registration is disabled', checkRegistration.bind(null, 'none'));
it('can LDAP login', login);
it('can LDAP login', login.bind(null, username, password));
it('can skip tutorial', skipTutorial);
it('can see timeline', checkTimeline);
it('backup app', function () {
@ -139,17 +148,18 @@ describe('Application life cycle test', function () {
it('can see timeline', checkTimeline);
it('can restart app', function (done) {
execSync('cloudron restart --wait --app ' + app.id);
execSync('cloudron restart --app ' + app.id);
done();
});
it('can see timeline', checkTimeline);
it('move to different location', function () {
execSync('cloudron configure --wait --location ' + LOCATION + '2 --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
execSync('cloudron configure --location ' + LOCATION + '2 --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
var inspect = JSON.parse(execSync('cloudron inspect'));
app = inspect.apps.filter(function (a) { return a.location === LOCATION + '2'; })[0];
expect(app).to.be.an('object');
});
it('can LDAP login', login.bind(null, username, password));
it('can see timeline', checkTimeline);
it('uninstall app', function () {
@ -158,7 +168,7 @@ describe('Application life cycle test', function () {
// No SSO
it('install app (no sso)', function () {
execSync('cloudron install --new --wait --no-sso --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
execSync('cloudron install --no-sso --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
});
it('can get app information', function () {
@ -169,9 +179,19 @@ describe('Application life cycle test', function () {
expect(app).to.be.an('object');
});
//it('has registration open', checkRegistration);
//it('can login (no sso)', login.bind(null, adminUsername, adminPassword));
//it('can logout', logout);
it('has registration open', checkRegistration.bind(null, 'open'));
let testPassword;
it('create a user with CLI', function () {
let output = execSync('cloudron exec --app ' + LOCATION + ' -- bin/tootctl accounts create test --email=test@cloudron.io', { cwd: path.resolve(__dirname, '..'), encoding: 'utf8' });
console.log(output);
testPassword = output.slice(output.indexOf('New password: ') + 'New password: '.length).trim();
console.log(testPassword);
});
it('can login (no sso)', (done) => login('test@cloudron.io', testPassword, done));
it('shows confirmation page', function () {
return browser.wait(until.elementLocated(by.xpath('//span[contains(text(), "Waiting for e-mail confirmation to be completed")]')), TIMEOUT);
});
it('uninstall app (no sso)', function () {
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
@ -179,14 +199,16 @@ describe('Application life cycle test', function () {
// test update
it('can install app', function () {
execSync('cloudron install --new --wait --appstore-id ' + app.manifest.id + ' --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
execSync('cloudron install --appstore-id ' + app.manifest.id + ' --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
var inspect = JSON.parse(execSync('cloudron inspect'));
app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0];
expect(app).to.be.an('object');
});
it('can LDAP login', login.bind(null, username, password));
it('can update', function () {
execSync('cloudron install --wait --app ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
execSync('cloudron update --app ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
});
it('can LDAP login', login.bind(null, username, password));
it('uninstall app', function () {
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });