var execSync = require('child_process').execSync,
expect = require('expect.js'),
path = require('path'),
+ util = require('util'),
fs = require('fs'),
superagent = require('superagent'),
webdriver = require('selenium-webdriver');
describe('Application life cycle test', function () {
this.timeout(0);
- var firefox = require('selenium-webdriver/firefox');
- var server, browser = new firefox.Driver();
+ var chrome = require('selenium-webdriver/chrome');
+ var server, browser = new chrome.Driver();
before(function (done) {
var seleniumJar= require('selenium-server-standalone-jar');
done();
});
- var LOCATION = 'rctest';
+ var LOCATION = 'test';
var TEST_TIMEOUT = 10000;
var TEST_FILE_NAME_0 = 'index.html';
var TEST_FILE_NAME_1 = 'test.txt';
});
}
+ function cliLogin(done) {
+ execSync(util.format('%s login %s --username %s --password %s', path.join(__dirname, '/../cli/surfer.js'), app.fqdn, process.env.USERNAME, process.env.PASSWORD), { stdio: 'inherit' } );
+ done();
+ }
+
function uploadFile(name, done) {
// File upload can't be tested with selenium, since the file input is not visible and thus can't be interacted with :-(
- fs.writeFileSync(process.env.HOME + '/.surfer.json', JSON.stringify({ server: 'https://' + app.fqdn, username: process.env.USERNAME, password: process.env.PASSWORD }));
execSync(path.join(__dirname, '/../cli/surfer.js') + ' put ' + path.join(__dirname, name), { stdio: 'inherit' } );
done();
}
- it('build app', function () {
+ xit('build app', function () {
execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
});
});
it('can login', login);
+ it('can cli login', cliLogin);
it('can upload file', uploadFile.bind(null, TEST_FILE_NAME_0));
it('file is listed', checkFileIsListed.bind(null, TEST_FILE_NAME_0));
it('file is served up', checkFileIsPresent);
it('can upload second file', uploadFile.bind(null, TEST_FILE_NAME_1));
it('file is listed', checkFileIsListed.bind(null, TEST_FILE_NAME_1));
it('can delete second file with cli', function (done) {
- fs.writeFileSync(process.env.HOME + '/.surfer.json', JSON.stringify({ server: 'https://' + app.fqdn, username: process.env.USERNAME, password: process.env.PASSWORD }));
execSync(path.join(__dirname, '/../cli/surfer.js') + ' del ' + TEST_FILE_NAME_1, { stdio: 'inherit' } );
done();
});
it('move to different location', function () {
browser.manage().deleteAllCookies();
- execSync('cloudron install --location ' + LOCATION + '2', { 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');