Fixed tests
This commit is contained in:
parent
b5aadcde74
commit
13de61d86e
56
test/test.js
56
test/test.js
|
@ -51,61 +51,49 @@ describe('Application life cycle test', function () {
|
||||||
var SYNC_PORT = 22001;
|
var SYNC_PORT = 22001;
|
||||||
var app;
|
var app;
|
||||||
|
|
||||||
function pageLoaded(callback) {
|
function pageLoaded() {
|
||||||
browser.wait(until.titleMatches(/[0-9a-f]{12} \| Syncthing/), TEST_TIMEOUT).then(callback);
|
return browser.wait(until.titleMatches(/[0-9a-f]{12} \| Syncthing/), TEST_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
function visible(selector, callback) {
|
function visible(selector) {
|
||||||
return browser.wait(until.elementLocated(selector), TEST_TIMEOUT).then(function () {
|
return browser.wait(until.elementLocated(selector), TEST_TIMEOUT).then(function () {
|
||||||
browser.wait(until.elementIsVisible(browser.findElement(selector)), TEST_TIMEOUT).then(function () {
|
return browser.wait(until.elementIsVisible(browser.findElement(selector)), TEST_TIMEOUT);
|
||||||
callback();
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadPageWait(callback) {
|
|
||||||
browser.manage().deleteAllCookies();
|
|
||||||
setTimeout(function() {
|
|
||||||
browser.get('https://' + username + ':' + password + '@' + app.fqdn);
|
|
||||||
pageLoaded(function() {
|
|
||||||
callback();
|
|
||||||
});
|
|
||||||
}, 60000); //Timeout since, reconfigure lacks health-check
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadPage(callback) {
|
function loadPage(callback) {
|
||||||
browser.manage().deleteAllCookies();
|
browser.manage().deleteAllCookies();
|
||||||
browser.get('https://' + username + ':' + password + '@' + app.fqdn);
|
browser.get('https://' + username + ':' + password + '@' + app.fqdn);
|
||||||
pageLoaded(function() {
|
return pageLoaded().then(function() {
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function addFolder(callback) {
|
function addFolder(callback) {
|
||||||
pageLoaded(function() {
|
return pageLoaded().then(function() {
|
||||||
browser.findElement(by.css('[ng-click*=addFolder]')).click();
|
browser.findElement(by.css('[ng-click*=addFolder]')).click();
|
||||||
visible(by.id('folderPath'), function() {
|
return visible(by.id('folderPath')).then(function() {
|
||||||
browser.findElement(by.id('folderLabel')).sendKeys('test').then(function() {
|
return browser.findElement(by.id('folderLabel')).sendKeys('test');
|
||||||
browser.findElement(by.id('folderPath')).sendKeys('/app/data/test').then(function() {
|
}).then(function() {
|
||||||
|
return browser.findElement(by.id('folderPath')).sendKeys('/app/data/test');
|
||||||
|
}).then(function() {
|
||||||
//Clear and re-enter the folder to avoid race with auto-completion
|
//Clear and re-enter the folder to avoid race with auto-completion
|
||||||
browser.findElement(by.id('folderPath')).clear().then(function() {
|
return browser.findElement(by.id('folderPath')).clear();
|
||||||
browser.findElement(by.id('folderPath')).sendKeys('/app/data/test').then(function() {
|
}).then(function() {
|
||||||
browser.findElement(by.css('[ng-click*=saveFolder]')).click().then(function() {
|
return browser.findElement(by.id('folderPath')).sendKeys('/app/data/test');
|
||||||
browser.wait(until.elementLocated(by.css('#folders .panel-status span[ng-switch-when=unshared]')), TEST_TIMEOUT).then(function() {
|
}).then(function() {
|
||||||
|
return browser.findElement(by.css('[ng-click*=saveFolder]')).click();
|
||||||
|
}).then(function() {
|
||||||
|
return browser.wait(until.elementLocated(by.css('#folders .panel-status span[ng-switch-when=unshared]')), TEST_TIMEOUT);
|
||||||
|
}).then(function() {
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeFolder(callback) {
|
function removeFolder(callback) {
|
||||||
browser.get('https://' + username + ':' + password + '@' + app.fqdn);
|
browser.get('https://' + username + ':' + password + '@' + app.fqdn);
|
||||||
pageLoaded(function() {
|
return pageLoaded().then(function() {
|
||||||
browser.findElement(by.css('#folders button')).click();
|
browser.findElement(by.css('#folders button')).click();
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
browser.findElement(by.css('#folder-0 button[ng-click*=editFolder]')).click();
|
browser.findElement(by.css('#folder-0 button[ng-click*=editFolder]')).click();
|
||||||
|
@ -152,13 +140,13 @@ describe('Application life cycle test', function () {
|
||||||
|
|
||||||
it('move to different location', function () {
|
it('move to different location', function () {
|
||||||
browser.manage().deleteAllCookies();
|
browser.manage().deleteAllCookies();
|
||||||
execSync('cloudron configure --location ' + LOCATION + '2', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
execSync('cloudron configure --wait --location ' + LOCATION + '2', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||||
var inspect = JSON.parse(execSync('cloudron inspect'));
|
var inspect = JSON.parse(execSync('cloudron inspect'));
|
||||||
app = inspect.apps.filter(function (a) { return a.location === LOCATION + '2'; })[0];
|
app = inspect.apps.filter(function (a) { return a.location === LOCATION + '2'; })[0];
|
||||||
expect(app).to.be.an('object');
|
expect(app).to.be.an('object');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can load page', loadPageWait);
|
it('can load page', loadPage);
|
||||||
it('can add folder', addFolder);
|
it('can add folder', addFolder);
|
||||||
it('can remove folder', removeFolder);
|
it('can remove folder', removeFolder);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue