cloudron-e2e-test/test/app-update-test.js

90 lines
2.6 KiB
JavaScript

/*
* This tests an app update and then a restore on the cloudron. There are
* two versions of haste in the staging appstore
*/
'use strict';
var AppStore = require('../appstore.js'),
assert = require('assert'),
Cloudron = require('../cloudron.js'),
common = require('../common.js');
require('colors');
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
var BOX_VERSION = process.env.BOX_VERSION;
var APP_ID = 'com.hastebin.cloudronapp', APP_OLD_VERSION = '0.4.0', APP_NEW_VERSION = '0.4.1';
describe('Application update test', function () {
this.timeout(0);
var appStore = new AppStore('https://api.staging.cloudron.io');
var owner = common.getOwner();
var admin = common.getAdmin();
var cloudron, appId, box;
it('can login to the store', function () {
var accessToken = appStore.getAccessToken(owner);
appStore.setCredentials(owner.password, accessToken);
var adminAccessToken = appStore.getAccessToken(admin);
appStore.setAdminCredentials(admin.password, adminAccessToken);
});
it('can create a cloudron', function () {
box = appStore.createCloudron({
domain: common.cloudronDomain(__filename),
region: 'sfo1',
size: '1gb',
version: BOX_VERSION
});
box = appStore.waitForCloudron(box.id);
cloudron = new Cloudron(box);
});
it('can activate the box', function () {
cloudron.activate(owner);
});
it('can login to the box', function () {
var token = cloudron.getOauthToken(owner);
cloudron.setCredentials(owner.password, token);
});
it('can enable email', function () {
cloudron.setEmailEnabled(true);
});
var location = 'test' + (Math.random() * 10000).toFixed();
it('can install app', function () {
appId = cloudron.installApp(location, APP_ID + '@' + APP_OLD_VERSION);
});
it('update the app', function () {
cloudron.updateApp(appId, APP_ID + '@' + APP_NEW_VERSION);
});
var backups;
it('can list the backups', function () {
backups = cloudron.listAppBackups(appId, APP_ID + '@' + APP_NEW_VERSION);
assert.strictEqual(backups.length, 1);
assert.strictEqual(backups[0].version, APP_OLD_VERSION);
});
it('can restore app to previous version', function () {
cloudron.restoreApp(appId, backups[0]);
});
it('can uninstall app', function () {
cloudron.uninstallApp(appId);
});
it('can delete the cloudron', function () {
appStore.deleteCloudron(box);
});
});