Skip to content

Commit

Permalink
[Tests] Fixing tests and also some code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
panda01 committed Mar 31, 2016
1 parent 5678d4d commit 9c0b65a
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/plugins/kibana/public/dashboard/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

<div ng-show="!state.panels.length" class="text-center start-screen">
<h2>Ready to get started?</h2>
<p>Click the <a class="btn btn-xs navbtn-inverse" ng-click="kbnTopNavbar.open('pickVis'); toggleAddVisualization = !toggleAddVisualization" aria-label="Add visualization"><i aria-hidden="true" class="fa fa-plus-circle"></i></a> button in the menu bar above to add a visualization to the dashboard. <br/>If you haven't setup a visualization yet visit the <a href="#/visualize" title="Visualize">"Visualize"</a> tab to create your first visualization.</p>
<p>Click the <a class="btn btn-xs navbtn-inverse" ng-click="kbnTopNav.open('pickVis'); toggleAddVisualization = !toggleAddVisualization" aria-label="Add visualization"><i aria-hidden="true" class="fa fa-plus-circle"></i></a> button in the menu bar above to add a visualization to the dashboard. <br/>If you haven't setup a visualization yet visit the <a href="#/visualize" title="Visualize">"Visualize"</a> tab to create your first visualization.</p>
</div>

<dashboard-grid></dashboard-grid>
Expand Down
8 changes: 6 additions & 2 deletions src/plugins/kibana/public/dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ app.directive('dashboardApp', function (Notifier, courier, AppState, timefilter,
key: 'share',
description: 'Share Dashboard',
template: require('plugins/kibana/dashboard/partials/share.html')
}, 'timepicker'];
}, {
key: 'pickVis',
description: 'Add Visualization',
template: require('plugins/kibana/dashboard/partials/pick_visualization.html')
}];

$scope.refresh = _.bindKey(courier, 'fetch');

Expand Down Expand Up @@ -205,7 +209,7 @@ app.directive('dashboardApp', function (Notifier, courier, AppState, timefilter,

dash.save()
.then(function (id) {
$scope.kbnTopNavbar.close('save');
$scope.kbnTopNav.close('save');
if (id) {
notify.info('Saved Dashboard as "' + dash.title + '"');
if (dash.id !== $routeParams.id) {
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/kibana/public/discover/controllers/discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,18 @@ app.controller('discover', function ($scope, config, courier, $route, $window, N
$scope.topNavMenu = [{
key: 'new',
description: 'New Search',
run: function () { kbnUrl.change('/discover') }
run: function () { kbnUrl.change('/discover'); }
}, {
key: 'save',
description: 'Save Search',
template: require('plugins/kibana/discover/partials/save_search.html')
}, {
key: 'open',
description: 'Open Saved Search',
description: 'Load Saved Search',
template: require('plugins/kibana/discover/partials/load_search.html')
}, {
key: 'share',
description: 'Share Saved Search',
description: 'Share Search',
template: require('plugins/kibana/discover/partials/share_search.html')
}];
$scope.timefilter = timefilter;
Expand Down Expand Up @@ -295,7 +295,7 @@ app.controller('discover', function ($scope, config, courier, $route, $window, N

return savedSearch.save()
.then(function (id) {
$scope.kbnTopNavbar.close('save');
$scope.kbnTopNav.close('save');

if (id) {
notify.info('Saved Data Source "' + savedSearch.title + '"');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<input id="SaveSearch" ng-model="opts.savedSearch.title" input-focus="select" class="form-control" placeholder="Name this search...">
</div>
<div class="form-group">
<button ng-disabled="!opts.savedSearch.title" type="submit" class="btn btn-primary">
<button ng-disabled="!opts.savedSearch.title" data-test-subj="discover-save-search-btn" type="submit" class="btn btn-primary">
Save
</button>
</div>
Expand Down
8 changes: 6 additions & 2 deletions src/plugins/kibana/public/visualize/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,15 @@ uiModules
}, {
key: 'load',
template: require('plugins/kibana/visualize/editor/panels/load.html'),
description: 'Load Visualization',
description: 'Load Saved Visualization',
}, {
key: 'share',
template: require('plugins/kibana/visualize/editor/panels/share.html'),
description: 'Share Visualization'
}, {
key: 'refresh',
description: 'Refresh',
run: function () { $scope.fetch(); }
}];

if (savedVis.id) {
Expand Down Expand Up @@ -242,7 +246,7 @@ uiModules

savedVis.save()
.then(function (id) {
$scope.kbnTopNavbar.close('save');
$scope.kbnTopNav.close('save');

if (id) {
notify.info('Saved Visualization "' + savedVis.title + '"');
Expand Down
12 changes: 6 additions & 6 deletions src/ui/public/directives/__tests__/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('Config Directive', function () {
beforeEach(ngMock.inject(function ($compile, $rootScope) {

build = function (scopeVars) {
var $el = $('<config>');
var $el = $('<kbn-top-nav>');
$testScope = $rootScope.$new();
assign($testScope, scopeVars || {});
$compile($el)($testScope);
Expand All @@ -32,11 +32,11 @@ describe('Config Directive', function () {

}));

it('sets the proper functions on the kbnTopNavbar prop on scope', function () {
it('sets the proper functions on the kbnTopNav prop on scope', function () {
var $config = build();
expect($testScope.kbnTopNavbar.open).to.be.a(Function);
expect($testScope.kbnTopNavbar.close).to.be.a(Function);
expect($testScope.kbnTopNavbar.is).to.be.a(Function);
expect($testScope.kbnTopNavbar.toggle).to.be.a(Function);
expect($testScope.kbnTopNav.open).to.be.a(Function);
expect($testScope.kbnTopNav.close).to.be.a(Function);
expect($testScope.kbnTopNav.is).to.be.a(Function);
expect($testScope.kbnTopNav.toggle).to.be.a(Function);
});
});
8 changes: 4 additions & 4 deletions src/ui/public/directives/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var module = uiModules.get('kibana');

module.directive('kbnTopNav', function (Private) {
const filterTemplate = require('ui/chrome/config/filter.html');
const intervalTemplate = require('ui/chrome/config/interval.html')
const intervalTemplate = require('ui/chrome/config/interval.html');
function optionsNormalizer(defaultFunction, opt) {
if (!opt.key) {
return false;
Expand Down Expand Up @@ -52,9 +52,9 @@ module.directive('kbnTopNav', function (Private) {
<div class="button-group kibana-nav-actions" role="toolbar">
<button
ng-repeat="menuItem in kbnTopNav.menuItems"
area-label="menuItem.description"
aria-haspopup="menuItem.hasFunction"
aria-expanded="kbnTopNav.is(menuItem.key)"
aria-label="{{::menuItem.description}}"
aria-haspopup="{{!menuItem.hasFunction}}"
aria-expanded="{{kbnTopNav.is(menuItem.key)}}"
ng-class="{active: kbnTopNav.is(menuItem.key)}"
ng-click="menuItem.run(menuItem)"
ng-bind="menuItem.label">
Expand Down
4 changes: 4 additions & 0 deletions src/ui/public/styles/base.less
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ a {
padding-bottom: 0;
padding-right: 0px;

kbn-global-timepicker {
line-height: 20px;
}

.kibana-nav-actions {
margin-left: auto;
padding-right: 0;
Expand Down
8 changes: 3 additions & 5 deletions test/support/pages/discover_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ define(function (require) {
})
.then(function clickSave() {
common.debug('--find save button');
return thisTime
.findDisplayedByCssSelector('button[ng-disabled="!opts.savedSearch.title"]')
.click();
return common.findTestSubject('discover-save-search-btn').click();
})
.catch(common.handleError(this));
},
Expand All @@ -76,13 +74,13 @@ define(function (require) {

clickLoadSavedSearchButton: function clickLoadSavedSearchButton() {
return thisTime
.findByCssSelector('button[aria-label="Load Saved Search"]')
.findDisplayedByCssSelector('button[aria-label="Load Saved Search"]')
.click();
},

getCurrentQueryName: function getCurrentQueryName() {
return thisTime
.findByCssSelector('span.kibana-nav-info-title')
.findByCssSelector('span.kibana-nav-info-title span')
.getVisibleText();
},

Expand Down
1 change: 1 addition & 0 deletions test/support/pages/visualize_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ define(function (require) {
})
// // click save button
.then(function () {
common.debug('click submit button');
return self.remote
.setFindTimeout(defaultTimeout)
.findByCssSelector('.config button[type="submit"]')
Expand Down

0 comments on commit 9c0b65a

Please sign in to comment.