138 lines
4.6 KiB
JavaScript
138 lines
4.6 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
/* jslint node:true */
|
|
/* global it:false */
|
|
/* global xit:false */
|
|
/* global describe:false */
|
|
/* global before:false */
|
|
/* global after:false */
|
|
|
|
'use strict';
|
|
|
|
require('chromedriver');
|
|
|
|
var execSync = require('child_process').execSync,
|
|
expect = require('expect.js'),
|
|
path = require('path'),
|
|
webdriver = require('selenium-webdriver');
|
|
|
|
var by = require('selenium-webdriver').By,
|
|
until = require('selenium-webdriver').until,
|
|
Key = require('selenium-webdriver').Key,
|
|
Builder = require('selenium-webdriver').Builder;
|
|
|
|
if (!process.env.USERNAME || !process.env.PASSWORD || !process.env.EMAIL) {
|
|
console.log('USERNAME, PASSWORD and EMAIL env vars need to be set');
|
|
process.exit(1);
|
|
}
|
|
|
|
describe('Application life cycle test', function () {
|
|
this.timeout(0);
|
|
|
|
var server, browser = new Builder().forBrowser('chrome').build();
|
|
var username = process.env.USERNAME, password = process.env.PASSWORD;
|
|
var email = process.env.EMAIL;
|
|
|
|
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();
|
|
});
|
|
|
|
function search(done) {
|
|
browser.get(`https://${app.fqdn}`).then(function () {
|
|
return browser.wait(until.elementLocated(by.id('q')), 5000);
|
|
}).then(function () {
|
|
return browser.findElement(by.id('q')).sendKeys('cloudron');
|
|
}).then(function () {
|
|
return browser.findElement(by.id('q')).sendKeys(Key.RETURN);
|
|
}).then(function () {
|
|
return browser.wait(until.elementLocated(by.xpath('//span[text()="Cloudron"]')), 5000);
|
|
}).then(function () {
|
|
return done();
|
|
});
|
|
}
|
|
|
|
var LOCATION = 'test';
|
|
var TEST_TIMEOUT = parseInt(process.env.TIMEOUT, 10) || 30000;
|
|
var app;
|
|
|
|
xit('build app', function () {
|
|
execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
});
|
|
|
|
it('install app', function () {
|
|
execSync('cloudron install --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 search', search);
|
|
|
|
it('backup app', function () {
|
|
execSync('cloudron backup create --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 search', search);
|
|
|
|
it('can restart app', function (done) {
|
|
execSync('cloudron restart --app ' + app.id);
|
|
done();
|
|
});
|
|
|
|
it('can search', search);
|
|
|
|
it('move to different location', function (done) {
|
|
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');
|
|
|
|
done();
|
|
});
|
|
|
|
it('can search', search);
|
|
|
|
it('uninstall app', function () {
|
|
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
});
|
|
|
|
// test update
|
|
it('can install from appstore', function () {
|
|
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 update', function () {
|
|
execSync('cloudron update --app ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
let inspect = JSON.parse(execSync('cloudron inspect'));
|
|
app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0];
|
|
});
|
|
|
|
it('can search', search);
|
|
|
|
it('uninstall app', function () {
|
|
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
});
|
|
});
|