Fixup tests

This commit is contained in:
Johannes Zellner 2020-05-05 12:42:59 +02:00
parent def7b55560
commit 46177b5ad6
1 changed files with 41 additions and 50 deletions

View File

@ -2,6 +2,11 @@
'use strict';
/* global describe */
/* global before */
/* global after */
/* global it */
require('chromedriver');
var execSync = require('child_process').execSync,
@ -15,15 +20,6 @@ var by = require('selenium-webdriver').By,
Key = require('selenium-webdriver').Key,
Builder = require('selenium-webdriver').Builder;
var accessKey = 'admin',
secretKey = 'secretkey';
var bucket_prefix = 'bucket',
bucket_id = 0,
bucket;
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
describe('Application life cycle test', function () {
this.timeout(0);
@ -49,10 +45,14 @@ describe('Application life cycle test', function () {
var TEST_TIMEOUT = 30000;
var FOLDER = 'xmf'; // keep this small. long folder names fail in automation, not sure why
var SYNC_PORT = 22001;
var EXEC_ARGS = { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' };
var app;
function installApp() {
execSync('cloudron install --port-bindings SYNC_PORT=' + SYNC_PORT + ' --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
function getAppInfo() {
var inspect = JSON.parse(execSync('cloudron inspect'));
app = inspect.apps.filter(function (a) { return a.location === LOCATION || a.location === LOCATION + '2'; })[0];
expect(app).to.be.an('object');
}
function pageLoaded() {
@ -75,6 +75,8 @@ describe('Application life cycle test', function () {
function loadPage(callback) {
browser.manage().deleteAllCookies().then(function () {
return browser.sleep(10000);
}).then(function() {
return browser.get('https://' + username + ':' + encodeURIComponent(password) + '@' + app.fqdn).then(function () {
return browser.get('https://' + app.fqdn);
});
@ -139,65 +141,54 @@ describe('Application life cycle test', function () {
});
}
xit('build app', function () {
execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
});
xit('build app', function () { execSync('cloudron build', EXEC_ARGS); });
it('install app', installApp);
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('install app', function () { execSync('cloudron install --port-bindings SYNC_PORT=' + SYNC_PORT + ' --location ' + LOCATION, EXEC_ARGS); });
it('can get app information', getAppInfo);
it('fails with invalid password', invalidPassword);
it('can load page', loadPage);
it('can add folder', addFolder);
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('backup app', function () { execSync('cloudron backup create --app ' + app.id, EXEC_ARGS); });
it('restore app', function () { execSync('cloudron restore --app ' + app.id, EXEC_ARGS); });
it('can load page', loadPage);
it('can check folder', checkFolder);
it('move to different location', function () {
browser.manage().deleteAllCookies();
execSync('cloudron configure --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('move to different location', function (done) {
// ensure we don't hit NXDOMAIN in the mean time
browser.get('about:blank').then(function () {
execSync(`cloudron configure --location ${LOCATION}2 --app ${app.id}`, EXEC_ARGS);
done();
});
});
it('can get app information', getAppInfo);
it('can load page', loadPage);
it('can check folder', checkFolder);
it('can remove folder', removeFolder);
it('uninstall app', function () {
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
it('uninstall app', function (done) {
browser.get('about:blank').then(function () {
execSync('cloudron uninstall --app ' + app.id, EXEC_ARGS);
done();
});
});
// test update
it('can install app', function () {
execSync('cloudron install --appstore-id net.syncthing.cloudronapp2 --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 install app', function () { execSync('cloudron install --port-bindings SYNC_PORT=' + SYNC_PORT + ' --appstore-id net.syncthing.cloudronapp2 --location ' + LOCATION, EXEC_ARGS); });
it('can get app information', getAppInfo);
it('can load page', loadPage);
it('can add folder', addFolder);
it('can update', function () {
execSync('cloudron update --app ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
});
it('can update', function () { execSync('cloudron update --app ' + LOCATION, EXEC_ARGS); });
it('wait for app to startup fully', function (done) { setTimeout(done, 10000); });
it('can check folder', checkFolder);
it('uninstall app', function () {
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
it('uninstall app', function (done) {
browser.get('about:blank').then(function () {
execSync('cloudron uninstall --app ' + app.id, EXEC_ARGS);
done();
});
});
});