fix promise usage

This commit is contained in:
Girish Ramakrishnan 2017-07-20 10:11:35 -07:00
parent b413b5d43a
commit 06a75583e8
1 changed files with 37 additions and 29 deletions

View File

@ -62,19 +62,23 @@ describe('Application life cycle test', function () {
}
function loadPage(callback) {
browser.manage().deleteAllCookies();
browser.get('https://' + username + ':' + password + '@' + app.fqdn);
pageLoaded().then(function() {
browser.manage().deleteAllCookies().then(function () {
return browser.get('https://' + username + ':' + password + '@' + app.fqdn);
}).then(function () {
return pageLoaded();
}).then(function () {
callback();
});
}
function addFolder(callback) {
pageLoaded().then(function() {
browser.findElement(by.css('[ng-click*=addFolder]')).click();
return visible(by.id('folderPath')).then(function() {
return browser.findElement(by.id('folderLabel')).sendKeys('test');
return browser.findElement(by.css('[ng-click*=addFolder]')).click();
}).then(function () {
return visible(by.id('folderPath'));
}).then(function() {
return browser.findElement(by.id('folderLabel')).sendKeys('test');
}).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
@ -88,21 +92,25 @@ describe('Application life cycle test', function () {
}).then(function() {
callback();
});
});
}
function removeFolder(callback) {
browser.get('https://' + username + ':' + password + '@' + app.fqdn);
pageLoaded().then(function() {
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, 1000); //This needs to run for some time
});
}, 1000); //No way to check for visibility of angular-js components
}, 1000); //No way to check for visibility of angular-js components
browser.get('https://' + username + ':' + password + '@' + app.fqdn).then(function () {
return pageLoaded();
}).then(function() {
return browser.findElement(by.css('#folders button')).click();
}).then(function () {
return browser.sleep(1000); //No way to check for visibility of angular-js components
}).then(function () {
return browser.findElement(by.css('#folder-0 button[ng-click*=editFolder]')).click();
}).then(function () {
return browser.sleep(1000); //No way to check for visibility of angular-js components
}).then(function () {
return browser.findElement(by.css('[ng-click*=deleteFolder]')).click();
}).then(function () {
return browser.sleep(1000); //This needs to run for some time
}).then(function () {
callback();
});
}