Skip to content

Commit

Permalink
Merge pull request #5488 from w33ble/tryfortime
Browse files Browse the repository at this point in the history
Make tryForTime return the resolved value
  • Loading branch information
jbudz committed Nov 24, 2015
2 parents cc11123 + 4e9b1d3 commit cfd8dea
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
10 changes: 4 additions & 6 deletions test/functional/apps/discover/_discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,10 @@ define(function (require) {
bdd.it('load query should show query name', function () {
return discoverPage.loadSavedSearch(queryName1)
.then(function () {
return common.tryForTime(15000, function () {
return discoverPage.getCurrentQueryName()
.then(function (actualQueryNameString) {
expect(actualQueryNameString).to.be(queryName1);
});
});
return discoverPage.getCurrentQueryName();
})
.then(function (actualQueryNameString) {
expect(actualQueryNameString).to.be(queryName1);
})
.catch(common.handleError(this));
});
Expand Down
9 changes: 4 additions & 5 deletions test/support/pages/Common.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,13 @@ define(function (require) {
self.debug(msg);
throw new Error(msg);
}

return currentUrl;
});
});
};

return doNavigation(appUrl)
.then(function () {
return self.remote.getCurrentUrl();
})
.then(function (currentUrl) {
var lastUrl = currentUrl;
return self.tryForTime(defaultTimeout, function () {
Expand Down Expand Up @@ -148,9 +147,9 @@ define(function (require) {

return Promise
.try(block)
.then(function tryForTimeSuccess() {
.then(function tryForTimeSuccess(resolved) {
self.debug('tryForTime success in about ' + (lastTry - start) + ' ms');
return (lastTry - start);
return resolved;
})
.catch(function tryForTimeCatch(err) {
self.debug('tryForTime failure, retry in ' + retryDelay + 'ms - ' + err.message);
Expand Down
11 changes: 6 additions & 5 deletions test/support/pages/DiscoverPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ define(function (require) {
// at runtime
var Common = require('./Common');

var defaultTimeout = 20000;
var defaultTimeout = 60000;
var common;
var thisTime;

Expand Down Expand Up @@ -76,10 +76,11 @@ define(function (require) {
},

getCurrentQueryName: function getCurrentQueryName() {
return thisTime
.findByCssSelector('span.discover-info-title')
// .findByCssSelector('span[bo-bind="opts.savedSearch.title"]')
.getVisibleText();
return common.tryForTime(defaultTimeout, function () {
return thisTime
.findByCssSelector('span.discover-info-title')
.getVisibleText();
});
},

getBarChartData: function getBarChartData() {
Expand Down
6 changes: 3 additions & 3 deletions test/support/pages/HeaderPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ define(function (require) {
common = new Common(this.remote);
}

var defaultTimeout = 5000;
var defaultTimeout = 60000;

HeaderPage.prototype = {
constructor: HeaderPage,

clickSelector: function (selector) {
var self = this.remote;
return common.tryForTime(5000, function () {
return common.tryForTime(defaultTimeout, function () {
return self.setFindTimeout(defaultTimeout)
.findByCssSelector(selector)
.then(function (tab) {
Expand Down Expand Up @@ -111,7 +111,7 @@ define(function (require) {

waitForToastMessageGone: function waitForToastMessageGone() {
var self = this;
return common.tryForTime(defaultTimeout * 5, function tryingForTime() {
return common.tryForTime(defaultTimeout * 2, function () {
return self.remote.setFindTimeout(1000)
.findAllByCssSelector('kbn-truncated.toast-message.ng-isolate-scope')
.then(function toastMessage(messages) {
Expand Down

0 comments on commit cfd8dea

Please sign in to comment.