Added tests
This commit is contained in:
parent
b700f42b17
commit
f51c71c9ef
|
@ -15,7 +15,7 @@
|
|||
"tcpPorts": {
|
||||
"PORT": {
|
||||
"title": "Port",
|
||||
"description": "Port over which syncthing will exchange data",
|
||||
"description": "Port over which syncthing will exchange data (do not disable)",
|
||||
"defaultValue": 22000,
|
||||
"containerPort": 22000
|
||||
}
|
||||
|
|
|
@ -32,6 +32,6 @@ cd syncthing-app/test
|
|||
|
||||
npm install
|
||||
export PATH=$PATH:node_modules/.bin
|
||||
mocha --bail test.js
|
||||
USERNAME=user PASSWORD=password mocha --bail test.js
|
||||
```
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ daemon off;
|
|||
# Send logs to stderr
|
||||
error_log /dev/stderr warn;
|
||||
|
||||
|
||||
events {
|
||||
worker_connections 768;
|
||||
}
|
||||
|
@ -24,20 +25,23 @@ http {
|
|||
fastcgi_temp_path /tmp/fastcgi_temp 1 2;
|
||||
uwsgi_temp_path /tmp/uwsgi_temp 1 2;
|
||||
scgi_temp_path /tmp/scgi_temp 1 2;
|
||||
proxy_buffering off;
|
||||
proxy_cache_path /tmp/proxy_cache levels=1:2 keys_zone=my_cache:10m max_size=100m inactive=60m use_temp_path=off;
|
||||
proxy_cache my_cache;
|
||||
|
||||
server {
|
||||
error_log /dev/stderr warn;
|
||||
listen 8000 default_server;
|
||||
server_name _;
|
||||
proxy_set_header Authorization "Basic YWRtaW46YWRtaW4=";
|
||||
proxy_read_timeout 120s;
|
||||
location /check {
|
||||
proxy_pass http://localhost:3000/syncthing/app.js;
|
||||
proxy_set_header Authorization "Basic YWRtaW46YWRtaW4=";
|
||||
}
|
||||
location / {
|
||||
auth_ldap "Forbidden";
|
||||
auth_ldap_servers cloudron;
|
||||
proxy_pass http://localhost:3000;
|
||||
proxy_set_header Authorization "Basic YWRtaW46YWRtaW4=";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
109
test/test.js
109
test/test.js
|
@ -19,12 +19,17 @@ var bucket_prefix = 'bucket',
|
|||
|
||||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
||||
|
||||
if (!process.env.USERNAME || !process.env.PASSWORD) {
|
||||
console.log('USERNAME and PASSWORD env vars need to be set');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
describe('Application life cycle test', function () {
|
||||
this.timeout(0);
|
||||
|
||||
var chrome = require('selenium-webdriver/chrome');
|
||||
var server, browser = new chrome.Driver();
|
||||
var username = process.env.USERNAME, password = process.env.PASSWORD;
|
||||
|
||||
before(function (done) {
|
||||
var seleniumJar= require('selenium-server-standalone-jar');
|
||||
|
@ -41,14 +46,13 @@ describe('Application life cycle test', function () {
|
|||
done();
|
||||
});
|
||||
|
||||
var LOCATION = 'minio-test';
|
||||
var TEST_TIMEOUT = 10000;
|
||||
var LOCATION = 'syncthing-test';
|
||||
var TEST_TIMEOUT = 30000;
|
||||
var SYNC_PORT = 22001;
|
||||
var app;
|
||||
|
||||
function pageLoaded(callback) {
|
||||
return browser.wait(until.elementLocated(by.className('page-load pl-0 pl-1')), TEST_TIMEOUT).then(function () {
|
||||
callback();
|
||||
});
|
||||
browser.wait(until.titleMatches(/[0-9a-f]{12} \| Syncthing/), TEST_TIMEOUT).then(callback);
|
||||
}
|
||||
|
||||
function visible(selector, callback) {
|
||||
|
@ -59,67 +63,47 @@ describe('Application life cycle test', function () {
|
|||
});
|
||||
}
|
||||
|
||||
function login(callback) {
|
||||
function loadPage(callback) {
|
||||
browser.manage().deleteAllCookies();
|
||||
browser.get('https://' + app.fqdn);
|
||||
|
||||
visible(by.id('accessKey'), function () {
|
||||
browser.findElement(by.id('accessKey')).sendKeys(accessKey);
|
||||
browser.findElement(by.id('secretKey')).sendKeys(secretKey);
|
||||
browser.findElement(by.className('lw-btn')).click();
|
||||
browser.wait(until.elementLocated(by.id('top-right-menu')), TEST_TIMEOUT).then(function () { callback(); });
|
||||
browser.get('https://' + username + ':' + password + '@' + app.fqdn);
|
||||
pageLoaded(function() {
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
function logout(callback) {
|
||||
browser.get('https://' + app.fqdn);
|
||||
|
||||
function addFolder(callback) {
|
||||
pageLoaded(function() {
|
||||
visible(by.id('top-right-menu'), function () {
|
||||
browser.findElement(by.id('top-right-menu')).click();
|
||||
visible(by.xpath('//*[text()="Sign Out "]'), function () {
|
||||
browser.findElement(by.xpath('//*[text()="Sign Out "]')).click();
|
||||
|
||||
browser.wait(until.elementLocated(by.id('accessKey')), TEST_TIMEOUT).then(function () { callback(); });
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function addBucket(callback) {
|
||||
bucket_id = bucket_id + 1;
|
||||
bucket = bucket_prefix + bucket_id;
|
||||
browser.get('https://' + app.fqdn);
|
||||
|
||||
pageLoaded(function () {
|
||||
visible(by.className('fa fa-plus'), function () {
|
||||
browser.findElement(by.className('fa fa-plus')).click();
|
||||
visible(by.className('fa fa-hdd-o'), function () {
|
||||
browser.findElement(by.className('fa fa-hdd-o')).click();
|
||||
visible(by.xpath('//*[@class="modal-body"]/form/div/input'), function() {
|
||||
browser.findElement(by.xpath('//*[@class="modal-body"]/form/div/input')).sendKeys(bucket);
|
||||
browser.findElement(by.xpath('//*[@class="modal-body"]/form')).submit();
|
||||
visible(by.xpath('//*[@class="main"]/a[text()="' + bucket + '"]'), function() {
|
||||
browser.findElement(by.css('[ng-click*=addFolder]')).click();
|
||||
visible(by.id('folderPath'), function() {
|
||||
browser.findElement(by.id('folderLabel')).sendKeys('test').then(function() {
|
||||
browser.findElement(by.id('folderPath')).sendKeys('/app/data/test').then(function() {
|
||||
//Clear and re-enter the folder to avoid race with auto-completion
|
||||
browser.findElement(by.id('folderPath')).clear().then(function() {
|
||||
browser.findElement(by.id('folderPath')).sendKeys('/app/data/test').then(function() {
|
||||
browser.findElement(by.css('[ng-click*=saveFolder]')).click().then(function() {
|
||||
browser.wait(until.elementLocated(by.css('#folders .panel-status span[ng-switch-when=unshared]')), TEST_TIMEOUT).then(function() {
|
||||
callback();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function openSettings(callback) {
|
||||
browser.get('https://' + app.fqdn);
|
||||
|
||||
function removeFolder(callback) {
|
||||
pageLoaded(function() {
|
||||
visible(by.id('top-right-menu'), function () {
|
||||
browser.findElement(by.id('top-right-menu')).click();
|
||||
visible(by.xpath('//*[text()="Settings "]'), function () {
|
||||
browser.findElement(by.xpath('//*[text()="Settings "]')).click();
|
||||
|
||||
browser.wait(until.elementLocated(by.xpath('//*[text()="Generate"]')), TEST_TIMEOUT).then(function () { callback(); });
|
||||
});
|
||||
browser.findElement(by.css('#folders button')).click();
|
||||
setTimeout(function() {
|
||||
browser.findElement(by.css('#folder-0 button[ng-click*=editFolder]')).click();
|
||||
setTimeout(function() {
|
||||
browser.findElement(by.css('[ng-click*=deleteFolder]')).click().then(function() {
|
||||
setTimeout(callback, 500); //This needs to run for some time
|
||||
});
|
||||
}, 500); //No way to check for visibility of angular-js components
|
||||
}, 500); //No way to check for visibility of angular-js components
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -128,7 +112,7 @@ describe('Application life cycle test', function () {
|
|||
});
|
||||
|
||||
it('install app', function () {
|
||||
execSync('cloudron install --new --wait --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
execSync('cloudron install --new --wait --port-bindings PORT=' + SYNC_PORT + ' --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
});
|
||||
|
||||
it('can get app information', function () {
|
||||
|
@ -139,10 +123,9 @@ describe('Application life cycle test', function () {
|
|||
expect(app).to.be.an('object');
|
||||
});
|
||||
|
||||
it('can login', login);
|
||||
it('can add buckets', addBucket);
|
||||
it('can open settings', openSettings);
|
||||
it('can logout', logout);
|
||||
it('can load page', loadPage);
|
||||
it('can add folder', addFolder);
|
||||
it('can remove folder', removeFolder);
|
||||
|
||||
it('backup app', function () {
|
||||
execSync('cloudron backup create --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
|
@ -152,10 +135,9 @@ describe('Application life cycle test', function () {
|
|||
execSync('cloudron restore --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
});
|
||||
|
||||
it('can login', login);
|
||||
it('can add buckets', addBucket);
|
||||
it('can open settings', openSettings);
|
||||
it('can logout', logout);
|
||||
it('can load page', loadPage);
|
||||
it('can add folder', addFolder);
|
||||
it('can remove folder', removeFolder);
|
||||
|
||||
it('move to different location', function () {
|
||||
browser.manage().deleteAllCookies();
|
||||
|
@ -165,10 +147,9 @@ describe('Application life cycle test', function () {
|
|||
expect(app).to.be.an('object');
|
||||
});
|
||||
|
||||
it('can login', login);
|
||||
it('can add buckets', addBucket);
|
||||
it('can open settings', openSettings);
|
||||
it('can logout', logout);
|
||||
it('can load page', loadPage);
|
||||
it('can add folder', addFolder);
|
||||
it('can remove folder', removeFolder);
|
||||
|
||||
it('uninstall app', function () {
|
||||
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
|
|
Loading…
Reference in New Issue