Commit a7317b4b by Johannes Zellner

Fixup tests

1 parent 4d8f08f9
...@@ -26,12 +26,12 @@ ...@@ -26,12 +26,12 @@
<el-dialog title="Login" :visible.sync="ready && !session.valid" width="30%" :close-on-press-escape="false" :show-close="false"> <el-dialog title="Login" :visible.sync="ready && !session.valid" width="30%" :close-on-press-escape="false" :show-close="false">
<el-form :model="loginData" label-position="top" @submit.native.prevent> <el-form :model="loginData" label-position="top" @submit.native.prevent>
<el-form-item label="Username"><el-input v-model="loginData.username" required autofocus :disabled="loginData.busy"></el-input></el-form-item> <el-form-item label="Username"><el-input v-model="loginData.username" id="loginUsernameInput" required autofocus :disabled="loginData.busy"></el-input></el-form-item>
<el-form-item label="Password"><el-input v-model="loginData.password" type="password" required :disabled="loginData.busy"></el-input></el-form-item> <el-form-item label="Password"><el-input v-model="loginData.password" id="loginPasswordInput" type="password" required :disabled="loginData.busy"></el-input></el-form-item>
<input type="submit" @click="onLogin" v-show="false"/> <input type="submit" @click="onLogin" v-show="false"/>
</el-form> </el-form>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button type="primary" @click="onLogin"><i class="el-icon-loading" v-show="loginData.busy"></i><span v-show="!loginData.busy">Login</span></el-button> <el-button type="primary" @click="onLogin" id="loginSubmitButton"><i class="el-icon-loading" v-show="loginData.busy"></i><span v-show="!loginData.busy">Login</span></el-button>
</span> </span>
</el-dialog> </el-dialog>
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
<el-button type="primary" icon="el-icon-plus" size="small" @click="onNewFolder">New Folder</el-button> <el-button type="primary" icon="el-icon-plus" size="small" @click="onNewFolder">New Folder</el-button>
</el-button-group> </el-button-group>
<el-dropdown @command="onOptionsMenu" :hide-on-click="false"> <el-dropdown @command="onOptionsMenu" :hide-on-click="false">
<el-button size="small" icon="el-icon-more"></el-button> <el-button size="small" icon="el-icon-more" id="burgerMenuButton"></el-button>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item disabled>Public Folder Listing</el-dropdown-item> <el-dropdown-item disabled>Public Folder Listing</el-dropdown-item>
<el-dropdown-item command="folderListing"> <el-dropdown-item command="folderListing">
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
</el-switch> </el-switch>
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item command="about" divided><i class="el-icon-info"></i> About</el-dropdown-item> <el-dropdown-item command="about" divided><i class="el-icon-info"></i> About</el-dropdown-item>
<el-dropdown-item command="logout"><i class="el-icon-circle-close"></i> Logout</el-dropdown-item> <el-dropdown-item command="logout" id="logoutButton"><i class="el-icon-circle-close"></i> Logout</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</div> </div>
......
...@@ -1315,12 +1315,6 @@ ...@@ -1315,12 +1315,6 @@
"integrity": "sha1-VjsZx8HeiS4Jv8Ty/DDjwn8JUrk=", "integrity": "sha1-VjsZx8HeiS4Jv8Ty/DDjwn8JUrk=",
"dev": true "dev": true
}, },
"selenium-server-standalone-jar": {
"version": "2.53.1",
"resolved": "https://registry.npmjs.org/selenium-server-standalone-jar/-/selenium-server-standalone-jar-2.53.1.tgz",
"integrity": "sha1-T8P6+ktCaL2tDbst7KCwazT1SK4=",
"dev": true
},
"selenium-webdriver": { "selenium-webdriver": {
"version": "2.53.3", "version": "2.53.3",
"resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-2.53.3.tgz", "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-2.53.3.tgz",
......
...@@ -50,7 +50,6 @@ ...@@ -50,7 +50,6 @@
"devDependencies": { "devDependencies": {
"expect.js": "^0.3.1", "expect.js": "^0.3.1",
"mocha": "^2.4.5", "mocha": "^2.4.5",
"selenium-server-standalone-jar": "^2.52.0",
"selenium-webdriver": "^2.52.0" "selenium-webdriver": "^2.52.0"
} }
} }
...@@ -2,43 +2,44 @@ ...@@ -2,43 +2,44 @@
'use strict'; 'use strict';
/* global describe */
/* global before */
/* global after */
/* global it */
var execSync = require('child_process').execSync, var execSync = require('child_process').execSync,
expect = require('expect.js'), expect = require('expect.js'),
path = require('path'), path = require('path'),
util = require('util'), util = require('util'),
fs = require('fs'),
superagent = require('superagent'), superagent = require('superagent'),
webdriver = require('selenium-webdriver'); webdriver = require('selenium-webdriver');
var by = webdriver.By, var by = webdriver.By,
Keys = webdriver.Key,
until = webdriver.until; until = webdriver.until;
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
if (!process.env.USERNAME || !process.env.PASSWORD) { if (!process.env.USERNAME || !process.env.PASSWORD) {
console.log('USERNAME and PASSWORD env vars need to be set'); console.log('USERNAME and PASSWORD env vars need to be set');
process.exit(1); process.exit(1);
} }
const EXEC_OPTIONS = { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' };
describe('Application life cycle test', function () { describe('Application life cycle test', function () {
this.timeout(0); this.timeout(0);
var chrome = require('selenium-webdriver/chrome'); var browser;
var server, browser = new chrome.Driver();
before(function (done) { before(function (done) {
var seleniumJar= require('selenium-server-standalone-jar'); browser = new webdriver.Builder()
var SeleniumServer = require('selenium-webdriver/remote').SeleniumServer; .forBrowser('chrome')
server = new SeleniumServer(seleniumJar.path, { port: 4444 }); // .setChromeOptions(new chrome.Options().addArguments(['no-sandbox', 'headless']))
server.start(); .build();
done(); done();
}); });
after(function (done) { after(function (done) {
browser.quit(); browser.quit();
server.stop();
done(); done();
}); });
...@@ -48,20 +49,24 @@ describe('Application life cycle test', function () { ...@@ -48,20 +49,24 @@ describe('Application life cycle test', function () {
var TEST_FILE_NAME_1 = 'test.txt'; var TEST_FILE_NAME_1 = 'test.txt';
var app; var app;
function waitForElement(elem) {
return browser.wait(until.elementLocated(elem), TEST_TIMEOUT).then(function () {
return browser.wait(until.elementIsVisible(browser.findElement(elem)), TEST_TIMEOUT);
});
}
// tests which are used more than once // tests which are used more than once
function login(done) { function login(done) {
browser.manage().deleteAllCookies(); browser.manage().deleteAllCookies();
browser.get('https://' + app.fqdn + '/_admin'); browser.get('https://' + app.fqdn + '/_admin');
browser.wait(until.elementLocated(by.id('inputUsername')), TEST_TIMEOUT).then(function () { waitForElement(by.id('loginUsernameInput')).then(function () {
browser.wait(until.elementIsVisible(browser.findElement(by.id('inputUsername'))), TEST_TIMEOUT).then(function () { browser.findElement(by.id('loginUsernameInput')).sendKeys(process.env.USERNAME);
browser.findElement(by.id('inputUsername')).sendKeys(process.env.USERNAME); browser.findElement(by.id('loginPasswordInput')).sendKeys(process.env.PASSWORD);
browser.findElement(by.id('inputPassword')).sendKeys(process.env.PASSWORD); browser.findElement(by.id('loginSubmitButton')).click();
browser.findElement(by.id('loginForm')).submit();
browser.wait(until.elementIsVisible(browser.findElement(by.id('logoutButton'))), TEST_TIMEOUT).then(function () { waitForElement(by.id('burgerMenuButton')).then(function () {
done(); done();
});
}); });
}); });
} }
...@@ -69,11 +74,16 @@ describe('Application life cycle test', function () { ...@@ -69,11 +74,16 @@ describe('Application life cycle test', function () {
function logout(done) { function logout(done) {
browser.get('https://' + app.fqdn + '/_admin'); browser.get('https://' + app.fqdn + '/_admin');
browser.wait(until.elementLocated(by.id('logoutButton')), TEST_TIMEOUT).then(function () { waitForElement(by.id('burgerMenuButton')).then(function () {
browser.wait(until.elementIsVisible(browser.findElement(by.id('logoutButton'))), TEST_TIMEOUT).then(function () { browser.findElement(by.id('burgerMenuButton')).click();
// wait for open animation
browser.sleep(5000);
waitForElement(by.id('logoutButton')).then(function () {
browser.findElement(by.id('logoutButton')).click(); browser.findElement(by.id('logoutButton')).click();
browser.wait(until.elementIsVisible(browser.findElement(by.id('inputPassword'))), TEST_TIMEOUT).then(function () { waitForElement(by.id('loginUsernameInput')).then(function () {
done(); done();
}); });
}); });
...@@ -83,7 +93,7 @@ describe('Application life cycle test', function () { ...@@ -83,7 +93,7 @@ describe('Application life cycle test', function () {
function checkFileIsListed(name, done) { function checkFileIsListed(name, done) {
browser.get('https://' + app.fqdn + '/_admin'); browser.get('https://' + app.fqdn + '/_admin');
browser.wait(until.elementLocated(by.xpath('//*[text()="' + name + '"]')), TEST_TIMEOUT).then(function () { waitForElement(by.xpath('//*[text()="' + name + '"]')).then(function () {
done(); done();
}); });
} }
...@@ -91,7 +101,7 @@ describe('Application life cycle test', function () { ...@@ -91,7 +101,7 @@ describe('Application life cycle test', function () {
function checkFileIsPresent(done) { function checkFileIsPresent(done) {
browser.get('https://' + app.fqdn + '/' + TEST_FILE_NAME_0); browser.get('https://' + app.fqdn + '/' + TEST_FILE_NAME_0);
browser.wait(until.elementLocated(by.xpath('//*[text()="test"]')), TEST_TIMEOUT).then(function () { waitForElement(by.xpath('//*[text()="test"]')).then(function () {
done(); done();
}); });
} }
...@@ -99,7 +109,7 @@ describe('Application life cycle test', function () { ...@@ -99,7 +109,7 @@ describe('Application life cycle test', function () {
function checkIndexFileIsServedUp(done) { function checkIndexFileIsServedUp(done) {
browser.get('https://' + app.fqdn); browser.get('https://' + app.fqdn);
browser.wait(until.elementLocated(by.xpath('//*[text()="test"]')), TEST_TIMEOUT).then(function () { waitForElement(by.xpath('//*[text()="test"]')).then(function () {
done(); done();
}); });
} }
...@@ -107,7 +117,8 @@ describe('Application life cycle test', function () { ...@@ -107,7 +117,8 @@ describe('Application life cycle test', function () {
function checkFileIsGone(name, done) { function checkFileIsGone(name, done) {
superagent.get('https://' + app.fqdn + '/' + name).end(function (error, result) { superagent.get('https://' + app.fqdn + '/' + name).end(function (error, result) {
expect(error).to.be.an('object'); expect(error).to.be.an('object');
expect(result.statusCode).to.equal(404); expect(error.response.status).to.equal(404);
expect(result).to.be.an('object');
done(); done();
}); });
} }
...@@ -125,11 +136,11 @@ describe('Application life cycle test', function () { ...@@ -125,11 +136,11 @@ describe('Application life cycle test', function () {
} }
xit('build app', function () { xit('build app', function () {
execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); execSync('cloudron build', EXEC_OPTIONS);
}); });
it('install app', function () { it('install app', function () {
execSync('cloudron install --new --wait --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); execSync('cloudron install --new --wait --location ' + LOCATION, EXEC_OPTIONS);
}); });
it('can get app information', function () { it('can get app information', function () {
...@@ -156,11 +167,11 @@ describe('Application life cycle test', function () { ...@@ -156,11 +167,11 @@ describe('Application life cycle test', function () {
it('can logout', logout); it('can logout', logout);
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_OPTIONS);
}); });
it('restore app', function () { it('restore app', function () {
execSync('cloudron restore --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); execSync('cloudron restore --app ' + app.id, EXEC_OPTIONS);
}); });
it('can login', login); it('can login', login);
...@@ -170,12 +181,17 @@ describe('Application life cycle test', function () { ...@@ -170,12 +181,17 @@ describe('Application life cycle test', function () {
it('second file is still gone', checkFileIsGone.bind(null, TEST_FILE_NAME_1)); it('second file is still gone', checkFileIsGone.bind(null, TEST_FILE_NAME_1));
it('can logout', logout); it('can logout', logout);
it('move to different location', function () { it('move to different location', function (done) {
browser.manage().deleteAllCookies(); browser.manage().deleteAllCookies();
execSync('cloudron configure --location ' + LOCATION + '2 --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
var inspect = JSON.parse(execSync('cloudron inspect')); // ensure we don't hit NXDOMAIN in the mean time
app = inspect.apps.filter(function (a) { return a.location === LOCATION + '2'; })[0]; browser.get('about:blank').then(function () {
expect(app).to.be.an('object'); execSync('cloudron configure --location ' + LOCATION + '2 --app ' + app.id, EXEC_OPTIONS);
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');
done();
});
}); });
it('can login', login); it('can login', login);
...@@ -184,7 +200,11 @@ describe('Application life cycle test', function () { ...@@ -184,7 +200,11 @@ describe('Application life cycle test', function () {
it('file is served up', checkIndexFileIsServedUp); it('file is served up', checkIndexFileIsServedUp);
it('can logout', logout); it('can logout', logout);
it('uninstall app', function () { it('uninstall app', function (done) {
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); // ensure we don't hit NXDOMAIN in the mean time
browser.get('about:blank').then(function () {
execSync('cloudron uninstall --app ' + app.id, EXEC_OPTIONS);
done();
});
}); });
}); });
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!