Make tests async
This commit is contained in:
parent
be87dfccc4
commit
73e3ad3341
3 changed files with 1710 additions and 218 deletions
1818
test/package-lock.json
generated
1818
test/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -10,9 +10,9 @@
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"expect.js": "^0.3.1",
|
"expect.js": "^0.3.1",
|
||||||
"mocha": "^8.3.2",
|
"mocha": "^9.1.4",
|
||||||
"selenium-server-standalone-jar": "^3.141.59",
|
"selenium-server-standalone-jar": "^3.141.59",
|
||||||
"selenium-webdriver": "^3.6.0",
|
"selenium-webdriver": "^4.1.1",
|
||||||
"chromedriver": "^89.0.0"
|
"chromedriver": "^97.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
104
test/test.js
104
test/test.js
|
@ -11,14 +11,11 @@
|
||||||
|
|
||||||
require('chromedriver');
|
require('chromedriver');
|
||||||
|
|
||||||
var execSync = require('child_process').execSync,
|
const execSync = require('child_process').execSync,
|
||||||
expect = require('expect.js'),
|
expect = require('expect.js'),
|
||||||
path = require('path');
|
path = require('path'),
|
||||||
|
{ Builder, By, Key, until } = require('selenium-webdriver'),
|
||||||
var by = require('selenium-webdriver').By,
|
{ Options } = require('selenium-webdriver/chrome');
|
||||||
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) {
|
if (!process.env.USERNAME || !process.env.PASSWORD || !process.env.EMAIL) {
|
||||||
console.log('USERNAME, PASSWORD and EMAIL env vars need to be set');
|
console.log('USERNAME, PASSWORD and EMAIL env vars need to be set');
|
||||||
|
@ -28,112 +25,89 @@ if (!process.env.USERNAME || !process.env.PASSWORD || !process.env.EMAIL) {
|
||||||
describe('Application life cycle test', function () {
|
describe('Application life cycle test', function () {
|
||||||
this.timeout(0);
|
this.timeout(0);
|
||||||
|
|
||||||
var server, browser = new Builder().forBrowser('chrome').build();
|
let browser, app;
|
||||||
|
const LOCATION = 'test';
|
||||||
|
const EXEC_ARGS = { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' };
|
||||||
|
|
||||||
before(function (done) {
|
before(function () {
|
||||||
var seleniumJar= require('selenium-server-standalone-jar');
|
browser = new Builder().forBrowser('chrome').setChromeOptions(new Options().windowSize({ width: 1280, height: 1024 })).build();
|
||||||
var SeleniumServer = require('selenium-webdriver/remote').SeleniumServer;
|
|
||||||
server = new SeleniumServer(seleniumJar.path, { port: 4444 });
|
|
||||||
server.start();
|
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function (done) {
|
after(function () {
|
||||||
browser.quit();
|
browser.quit();
|
||||||
server.stop();
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function search(done) {
|
async function search() {
|
||||||
browser.get(`https://${app.fqdn}`).then(function () {
|
await browser.get(`https://${app.fqdn}`);
|
||||||
return browser.wait(until.elementLocated(by.id('q')), 5000);
|
await browser.wait(until.elementLocated(By.id('q')), 5000);
|
||||||
}).then(function () {
|
await browser.findElement(By.id('q')).sendKeys('cloudron');
|
||||||
return browser.findElement(by.id('q')).sendKeys('cloudron');
|
await browser.findElement(By.id('q')).sendKeys(Key.RETURN);
|
||||||
}).then(function () {
|
await browser.wait(until.elementLocated(By.xpath('//span[text()="Cloudron"]')), 5000);
|
||||||
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';
|
function getAppInfo() {
|
||||||
var app;
|
const inspect = JSON.parse(execSync('cloudron inspect'));
|
||||||
|
app = inspect.apps.filter(function (a) { return a.location.startsWith(LOCATION); })[0];
|
||||||
|
expect(app).to.be.an('object');
|
||||||
|
}
|
||||||
|
|
||||||
xit('build app', function () {
|
xit('build app', function () {
|
||||||
execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
execSync('cloudron build', EXEC_ARGS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('install app', function () {
|
it('install app', function () {
|
||||||
execSync('cloudron install --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
execSync('cloudron install --location ' + LOCATION, EXEC_ARGS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can get app information', function () {
|
it('can get app information', getAppInfo);
|
||||||
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('can search', search);
|
||||||
|
|
||||||
it('backup app', function () {
|
it('backup app', function () {
|
||||||
execSync('cloudron backup create --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
execSync('cloudron backup create --app ' + app.id, EXEC_ARGS);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('restore app', function () {
|
it('restore app', function () {
|
||||||
const backups = JSON.parse(execSync('cloudron backup list --raw'));
|
const backups = JSON.parse(execSync('cloudron backup list --raw'));
|
||||||
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
execSync('cloudron uninstall --app ' + app.id, EXEC_ARGS);
|
||||||
execSync('cloudron install --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
execSync('cloudron install --location ' + LOCATION, EXEC_ARGS);
|
||||||
var inspect = JSON.parse(execSync('cloudron inspect'));
|
getAppInfo();
|
||||||
app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0];
|
execSync(`cloudron restore --backup ${backups[0].id} --app ${app.id}`, EXEC_ARGS);
|
||||||
execSync(`cloudron restore --backup ${backups[0].id} --app ${app.id}`, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can search', search);
|
it('can search', search);
|
||||||
|
|
||||||
it('can restart app', function (done) {
|
it('can restart app', function () {
|
||||||
execSync('cloudron restart --app ' + app.id);
|
execSync('cloudron restart --app ' + app.id);
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can search', search);
|
it('can search', search);
|
||||||
|
|
||||||
it('move to different location', function (done) {
|
it('move to different location', function () {
|
||||||
execSync('cloudron configure --location ' + LOCATION + '2 --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
execSync('cloudron configure --location ' + LOCATION + '2 --app ' + app.id, EXEC_ARGS);
|
||||||
var inspect = JSON.parse(execSync('cloudron inspect'));
|
getAppInfo();
|
||||||
app = inspect.apps.filter(function (a) { return a.location === LOCATION + '2'; })[0];
|
|
||||||
expect(app).to.be.an('object');
|
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can search', search);
|
it('can search', search);
|
||||||
|
|
||||||
it('uninstall app', function () {
|
it('uninstall app', function () {
|
||||||
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
execSync('cloudron uninstall --app ' + app.id, EXEC_ARGS);
|
||||||
});
|
});
|
||||||
|
|
||||||
// test update
|
// test update
|
||||||
it('can install from appstore', function () {
|
it('can install from appstore', function () {
|
||||||
execSync(`cloudron install --appstore-id ${app.manifest.id} --location ${LOCATION}`, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
execSync(`cloudron install --appstore-id ${app.manifest.id} --location ${LOCATION}`, EXEC_ARGS);
|
||||||
var inspect = JSON.parse(execSync('cloudron inspect'));
|
getAppInfo();
|
||||||
app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0];
|
|
||||||
expect(app).to.be.an('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can update', function () {
|
it('can update', function () {
|
||||||
execSync('cloudron update --app ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
execSync('cloudron update --app ' + LOCATION, EXEC_ARGS);
|
||||||
let inspect = JSON.parse(execSync('cloudron inspect'));
|
getAppInfo();
|
||||||
app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0];
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can search', search);
|
it('can search', search);
|
||||||
|
|
||||||
it('uninstall app', function () {
|
it('uninstall app', function () {
|
||||||
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
execSync('cloudron uninstall --app ' + app.id, EXEC_ARGS);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue