diff --git a/test/test.js b/test/test.js index 31048b2..a341e3d 100755 --- a/test/test.js +++ b/test/test.js @@ -59,6 +59,56 @@ describe('Application life cycle test', function () { }, TIMEOUT); } + function checkRegistration(mode, done) { + return 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); + } + }).then(function () { + done(); + }); + } + + function login(done) { + return browser.get('https://' + app.fqdn).then(function () { + 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); + }).then(function () { + return browser.findElement(by.id('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(); + }).then(function () { + return browser.sleep(2000); + }).then(function () { + return browser.findElement(by.xpath('//span[contains(text(), "Next")]')).click(); + }).then(function () { + return browser.sleep(2000); + }).then(function () { + return browser.findElement(by.xpath('//span[contains(text(), "Finish tutorial!")]')).click(); + }).then(function () { + return browser.sleep(2000); + }).then(function () { + done(); + }); + } + + function checkTimeline(done) { + return 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(); + }); + } + xit('build app', function () { execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); }); @@ -74,19 +124,25 @@ 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 see timeline', checkTimeline); it('backup app', function () { execSync('cloudron backup create --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); }); + it('can see timeline', checkTimeline); it('restore app', function () { execSync('cloudron restore --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); }); + it('can see timeline', checkTimeline); it('can restart app', function (done) { execSync('cloudron restart --wait --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' }); @@ -94,11 +150,33 @@ describe('Application life cycle test', function () { app = inspect.apps.filter(function (a) { return a.location === LOCATION + '2'; })[0]; expect(app).to.be.an('object'); }); + it('can see timeline', checkTimeline); it('uninstall app', function () { execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); }); + // No SSO + it('install app (no sso)', function () { + execSync('cloudron install --new --wait --no-sso --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); + }); + + it('can get app information', function () { + 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('has registration open', checkRegistration); + //it('can login (no sso)', login.bind(null, adminUsername, adminPassword)); + //it('can logout', logout); + + it('uninstall app (no sso)', function () { + execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); + }); + // 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' });