Fix tests

This commit is contained in:
Girish Ramakrishnan 2023-10-11 10:47:49 +05:30
parent 83578811b0
commit 4e734b3323
1 changed files with 24 additions and 20 deletions

View File

@ -14,21 +14,21 @@ const execSync = require('child_process').execSync,
expect = require('expect.js'), expect = require('expect.js'),
superagent = require('superagent'), superagent = require('superagent'),
path = require('path'), path = require('path'),
timers = require('timers/promises'),
{ Builder, By, Key, until } = require('selenium-webdriver'), { Builder, By, Key, until } = require('selenium-webdriver'),
{ Options } = require('selenium-webdriver/chrome'); { Options } = require('selenium-webdriver/chrome');
describe('Application life cycle test', function () { describe('Application life cycle test', function () {
this.timeout(0); this.timeout(0);
var LOCATION = 'test'; const LOCATION = 'test';
var TEST_TIMEOUT = 30000; const TEST_TIMEOUT = 30000;
var FOLDER = 'xmf'; // keep this small. long folder names fail in automation, not sure why const FOLDER = 'xmf'; // keep this small. long folder names fail in automation, not sure why
var SYNC_PORT = 22001; const SYNC_PORT = 22001;
var EXEC_ARGS = { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }; const EXEC_ARGS = { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' };
var browser; let browser, app;
var app; const username = 'admin', password = 'changeme';
var username = 'admin', password = 'changeme';
before(function () { before(function () {
browser = new Builder().forBrowser('chrome').setChromeOptions(new Options().windowSize({ width: 1280, height: 1024 })).build(); browser = new Builder().forBrowser('chrome').setChromeOptions(new Options().windowSize({ width: 1280, height: 1024 })).build();
@ -39,7 +39,7 @@ describe('Application life cycle test', function () {
}); });
function getAppInfo() { function getAppInfo() {
var inspect = JSON.parse(execSync('cloudron inspect')); const inspect = JSON.parse(execSync('cloudron inspect'));
app = inspect.apps.filter(function (a) { return a.location.indexOf(LOCATION) === 0; })[0]; app = inspect.apps.filter(function (a) { return a.location.indexOf(LOCATION) === 0; })[0];
expect(app).to.be.an('object'); expect(app).to.be.an('object');
} }
@ -136,34 +136,36 @@ describe('Application life cycle test', function () {
xit('build app', function () { execSync('cloudron build', EXEC_ARGS); }); xit('build app', function () { execSync('cloudron build', EXEC_ARGS); });
it('install app', function () { execSync('cloudron install --port-bindings SYNC_PORT=' + SYNC_PORT + ' --location ' + LOCATION, EXEC_ARGS); }); it('install app', async function () {
execSync('cloudron install --port-bindings SYNC_PORT=' + SYNC_PORT + ' --location ' + LOCATION, EXEC_ARGS);
await timers.setTimeout(30000);
});
it('can get app information', getAppInfo); it('can get app information', getAppInfo);
it('wait', wait);
it('fails with invalid password', invalidPassword); it('fails with invalid password', invalidPassword);
it('can load page', loadPage); it('can load page', loadPage);
it('can add folder', addFolder); it('can add folder', addFolder);
it('backup app', function () { execSync('cloudron backup create --app ' + app.id, EXEC_ARGS); }); it('backup app', async function () {
execSync('cloudron backup create --app ' + app.id, EXEC_ARGS);
await timers.setTimeout(30000);
});
it('restore app', async function () { it('restore app', async function () {
await browser.get('about:blank'); await browser.get('about:blank');
execSync('cloudron restore --app ' + app.id, EXEC_ARGS); execSync('cloudron restore --app ' + app.id, EXEC_ARGS);
await timers.setTimeout(30000);
}); });
it('wait', wait);
it('can load page', loadPage); it('can load page', loadPage);
it('can check folder', checkFolder); it('can check folder', checkFolder);
it('move to different location', async function () { it('move to different location', async function () {
await browser.get('about:blank'); await browser.get('about:blank');
execSync(`cloudron configure --location ${LOCATION}2 --app ${app.id}`, EXEC_ARGS); execSync(`cloudron configure --location ${LOCATION}2 --app ${app.id}`, EXEC_ARGS);
await timers.setTimeout(30000);
}); });
it('can get app information', getAppInfo); it('can get app information', getAppInfo);
it('wait', wait);
it('can load page', loadPage); it('can load page', loadPage);
it('can check folder', checkFolder); it('can check folder', checkFolder);
it('can remove folder', removeFolder); it('can remove folder', removeFolder);
@ -174,16 +176,18 @@ describe('Application life cycle test', function () {
}); });
// test update // test update
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 install app', async function () {
execSync('cloudron install --port-bindings SYNC_PORT=' + SYNC_PORT + ' --appstore-id net.syncthing.cloudronapp2 --location ' + LOCATION, EXEC_ARGS);
await timers.setTimeout(30000);
});
it('can get app information', getAppInfo); it('can get app information', getAppInfo);
it('wait', wait);
it('can load page', loadPage); it('can load page', loadPage);
it('can add folder', addFolder); it('can add folder', addFolder);
it('can update', async function () { it('can update', async function () {
await browser.get('about:blank'); await browser.get('about:blank');
execSync('cloudron update --app ' + LOCATION, EXEC_ARGS); execSync('cloudron update --app ' + LOCATION, EXEC_ARGS);
await timers.setTimeout(30000);
}); });
it('wait', wait);
it('can check folder', checkFolder); it('can check folder', checkFolder);
it('uninstall app', async function () { it('uninstall app', async function () {