change the selector used to check the loaded app

debug: wait for app scope before executing scripts

debug: drop app check, let fail and output info
This commit is contained in:
Joe Fleming 2015-11-06 16:11:11 -07:00
parent 2632c7479c
commit 62c90e7f62
2 changed files with 26 additions and 14 deletions

View file

@ -68,7 +68,7 @@ define(function (require) {
runScript: function (fn, timeout) {
var self = this;
timeout = timeout || 1000;
timeout = timeout || 2000;
// wait for deps on window before running script
return self.remote
@ -80,8 +80,13 @@ define(function (require) {
if (ready && hasJQuery) {
console.log('doc ready, jquery loaded');
clearInterval(interval);
done();
// var appScope = $('.application').scope();
// if (appScope) {
console.log('app scope found');
clearInterval(interval);
done();
// }
}
}, 10);
}).then(function () {
@ -92,19 +97,26 @@ define(function (require) {
getApp: function () {
return this.runScript(function () {
var $ = window.$;
var $scope = $('nav').scope();
return $scope.chrome.getApp();
// var $scope = $('nav').scope();
var $scope = $('.application').scope();
return $scope ? $scope.chrome.getApp() : {};
});
},
checkForKibanaApp: function () {
var self = this;
self.debug('Checking for kibana app');
return self.getApp()
.then(function (app) {
self.debug('current app: ' + app.id);
return app.id === 'kibana';
var appId = app.id;
self.debug('current application: ' + appId);
return appId === 'kibana';
})
.catch(function (err) {
self.debug('kibana check failed');
self.debug(err);
// not on the kibana app...
return false;
});
},

View file

@ -6,7 +6,7 @@ define(function (require) {
var Common = require('./Common');
var defaultTimeout = 6000;
var defaultTimeout = 5000;
var common;
function SettingsPage(remote) {
@ -55,7 +55,7 @@ define(function (require) {
})
// DEBUGGING
.catch(function (err) {
common.debug('FAILED to creat index patter');
common.debug('selectTimeFieldOption: FAILED to create index pattern');
return common.checkForKibanaApp()
.then(function (onKibana) {
common.debug('onKibana')
@ -142,7 +142,8 @@ define(function (require) {
var selector = 'li.kbn-settings-tab.ng-scope.active a.ng-binding small.ng-binding';
var timeout = defaultTimeout * 2; // takes a little extra time to render
return self.remote.setFindTimeout(timeout).findByCssSelector(selector).getVisibleText()
return self.remote.setFindTimeout(timeout)
.findByCssSelector(selector).getVisibleText()
.then(function (theText) {
// the value has () around it, remove them
return theText.replace(/\((.*)\)/, '$1');
@ -241,8 +242,7 @@ define(function (require) {
},
setPageSize: function setPageSize(size) {
return this.remote
.setFindTimeout(defaultTimeout)
return this.remote.setFindTimeout(defaultTimeout)
.findByCssSelector('form.form-inline.pagination-size.ng-scope.ng-pristine.ng-valid div.form-group option[label="' + size + '"]')
.then(function (button) {
return button.click();
@ -270,7 +270,7 @@ define(function (require) {
})
// DEBUGGING
.catch(function (err) {
common.debug('FAILED to create index pattern');
common.debug('createIndexPattern: FAILED to create index pattern');
return common.checkForKibanaApp()
.then(function (onKibana) {
common.debug('onKibana')