|
@@ -0,0 +1,113 @@
|
|
|
+#!/usr/bin/env node
|
|
|
+
|
|
|
+'use strict';
|
|
|
+
|
|
|
+var execSync = require('child_process').execSync,
|
|
|
+ expect = require('expect.js'),
|
|
|
+ path = require('path'),
|
|
|
+ superagent = require('superagent'),
|
|
|
+ webdriver = require('selenium-webdriver');
|
|
|
+
|
|
|
+var by = webdriver.By,
|
|
|
+ Keys = webdriver.Key,
|
|
|
+ until = webdriver.until;
|
|
|
+
|
|
|
+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 username = 'admin', password = 'changeme';
|
|
|
+
|
|
|
+ before(function (done) {
|
|
|
+ var seleniumJar= require('selenium-server-standalone-jar');
|
|
|
+ var SeleniumServer = require('selenium-webdriver/remote').SeleniumServer;
|
|
|
+ server = new SeleniumServer(seleniumJar.path, { port: 4444 });
|
|
|
+ server.start();
|
|
|
+
|
|
|
+ done();
|
|
|
+ });
|
|
|
+
|
|
|
+ after(function (done) {
|
|
|
+ browser.quit();
|
|
|
+ server.stop();
|
|
|
+ done();
|
|
|
+ });
|
|
|
+
|
|
|
+ var LOCATION = 'nodebbtest';
|
|
|
+ var TEST_TIMEOUT = parseInt(process.env.TEST_TIMEOUT, 10) || 5000;
|
|
|
+ var app;
|
|
|
+ var email, token;
|
|
|
+
|
|
|
+ function login(done) {
|
|
|
+ browser.manage().deleteAllCookies();
|
|
|
+ browser.get('https://' + app.fqdn + '/login');
|
|
|
+ browser.executeScript('localStorage.clear();')
|
|
|
+
|
|
|
+ browser.get('https://' + app.fqdn + '/login');
|
|
|
+ browser.wait(until.elementLocated(by.id('username')), TEST_TIMEOUT).then(function () {
|
|
|
+ browser.findElement(by.id('username')).sendKeys(username);
|
|
|
+ browser.findElement(by.id('password')).sendKeys(password);
|
|
|
+ browser.findElement(by.id('login')).click();
|
|
|
+ browser.wait(until.elementLocated(by.xpath('//a[contains(text(), "Announcements")]')), TEST_TIMEOUT).then(function () { done(); });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ xit('build app', function () {
|
|
|
+ execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
+ });
|
|
|
+
|
|
|
+ it('install app', function () {
|
|
|
+ execSync('cloudron install --new --wait --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('can login', function (done) {
|
|
|
+ login(done);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('backup app', function () {
|
|
|
+ execSync('cloudron backup --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
+ });
|
|
|
+
|
|
|
+ it('restore app', function () {
|
|
|
+ execSync('cloudron restore --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
+ });
|
|
|
+
|
|
|
+ it('can login', function (done) {
|
|
|
+ login(done);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('can restart app', function (done) {
|
|
|
+ execSync('cloudron restart');
|
|
|
+ done();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('can login', function (done) {
|
|
|
+ login(done);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('move to different location', function () {
|
|
|
+ execSync('cloudron install --wait --location ' + LOCATION + '2', { 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 login', function (done) {
|
|
|
+ login(done);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('uninstall app', function () {
|
|
|
+ execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
+ });
|
|
|
+});
|