From 4036c46b8fc0980211e720a995e53a787fd1d107 Mon Sep 17 00:00:00 2001 From: Nicolas Bevacqua Date: Wed, 30 Mar 2016 14:08:56 -0300 Subject: [PATCH] [test/functional] Functional tests covering new "No Results" partial directive and time picker. --- .../public/discover/directives/no_results.js | 13 +++++ src/plugins/kibana/public/discover/index.html | 53 +------------------ src/plugins/kibana/public/discover/index.js | 1 + .../public/discover/partials/no_results.html | 51 ++++++++++++++++++ test/functional/apps/discover/_discover.js | 29 ++++++++++ test/support/pages/discover_page.js | 16 +++++- 6 files changed, 110 insertions(+), 53 deletions(-) create mode 100644 src/plugins/kibana/public/discover/directives/no_results.js create mode 100644 src/plugins/kibana/public/discover/partials/no_results.html diff --git a/src/plugins/kibana/public/discover/directives/no_results.js b/src/plugins/kibana/public/discover/directives/no_results.js new file mode 100644 index 000000000000..85cffe96ab54 --- /dev/null +++ b/src/plugins/kibana/public/discover/directives/no_results.js @@ -0,0 +1,13 @@ +import _ from 'lodash'; +import $ from 'jquery'; +import uiModules from 'ui/modules'; +import noResultsTemplate from '../partials/no_results.html'; + +uiModules +.get('apps/discover') +.directive('discoverNoResults', function () { + return { + restrict: 'E', + template: noResultsTemplate + }; +}); diff --git a/src/plugins/kibana/public/discover/index.html b/src/plugins/kibana/public/discover/index.html index c71c8f911729..36e49c8894c0 100644 --- a/src/plugins/kibana/public/discover/index.html +++ b/src/plugins/kibana/public/discover/index.html @@ -94,58 +94,7 @@
- -
-
- -

No results found

- -

- Unfortunately I could not find any results matching your search. I tried really hard. I looked all over the place and frankly, I just couldn't find anything good. Help me, help you. Here are some ideas: -

- -
-

Shard Failures

-

The following shard failures ocurred:

-
    -
  • Index: {{failure.index}} Shard: {{failure.shard}} Reason: {{failure.reason}}
  • -
- Show More - Show Less -
- -
-

-

Expand your time range

-

I see you are looking at an index with a date field. It is possible your query does not match anything in the current time range, or that there is no data at all in the currently selected time range. Click the button below to open the time picker. For future reference you can open the time picker by clicking on the time picker button in the top right corner of your screen. -

-
- -

Refine your query

-

- The search bar at the top uses Elasticsearch's support for Lucene Query String syntax. Let's say we're searching web server logs that have been parsed into a few fields. -

- -

-

Examples:

- Find requests that contain the number 200, in any field: -
200
- - Or we can search in a specific field. Find 200 in the status field: -
status:200
- - Find all status codes between 400-499: -
status:[400 TO 499]
- - Find status codes 400-499 with the extension php: -
status:[400 TO 499] AND extension:PHP
- - Or HTML -
status:[400 TO 499] AND (extension:php OR extension:html)
-

- -
-
+
diff --git a/src/plugins/kibana/public/discover/index.js b/src/plugins/kibana/public/discover/index.js index 7d117dc9a22e..545a1e5398bf 100644 --- a/src/plugins/kibana/public/discover/index.js +++ b/src/plugins/kibana/public/discover/index.js @@ -1,4 +1,5 @@ import 'plugins/kibana/discover/saved_searches/saved_searches'; +import 'plugins/kibana/discover/directives/no_results'; import 'plugins/kibana/discover/directives/timechart'; import 'ui/navbar'; import 'ui/collapsible_sidebar'; diff --git a/src/plugins/kibana/public/discover/partials/no_results.html b/src/plugins/kibana/public/discover/partials/no_results.html new file mode 100644 index 000000000000..4bc86e5c35a7 --- /dev/null +++ b/src/plugins/kibana/public/discover/partials/no_results.html @@ -0,0 +1,51 @@ +
+
+ +

No results found

+ +

+ Unfortunately I could not find any results matching your search. I tried really hard. I looked all over the place and frankly, I just couldn't find anything good. Help me, help you. Here are some ideas: +

+ +
+

Shard Failures

+

The following shard failures ocurred:

+
    +
  • Index: {{failure.index}} Shard: {{failure.shard}} Reason: {{failure.reason}}
  • +
+ Show More + Show Less +
+ +
+

+

Expand your time range

+

I see you are looking at an index with a date field. It is possible your query does not match anything in the current time range, or that there is no data at all in the currently selected time range. Click the button below to open the time picker. For future reference you can open the time picker by clicking on the time picker button in the top right corner of your screen. +

+
+ +

Refine your query

+

+ The search bar at the top uses Elasticsearch's support for Lucene Query String syntax. Let's say we're searching web server logs that have been parsed into a few fields. +

+ +

+

Examples:

+ Find requests that contain the number 200, in any field: +
200
+ + Or we can search in a specific field. Find 200 in the status field: +
status:200
+ + Find all status codes between 400-499: +
status:[400 TO 499]
+ + Find status codes 400-499 with the extension php: +
status:[400 TO 499] AND extension:PHP
+ + Or HTML +
status:[400 TO 499] AND (extension:php OR extension:html)
+

+ +
+
diff --git a/test/functional/apps/discover/_discover.js b/test/functional/apps/discover/_discover.js index 9cec39dc31ca..3f5c67dbea5c 100644 --- a/test/functional/apps/discover/_discover.js +++ b/test/functional/apps/discover/_discover.js @@ -245,6 +245,11 @@ define(function (require) { .catch(common.handleError(this)); }); + bdd.it('should not show "no results"', () => { + discoverPage.hasNoResults().then(noResults => { + expect(noResults).to.be(false); + }); + }); function verifyChartData(expectedBarChartData) { return common.tryForTime(20 * 1000, function tryingForTime() { @@ -274,6 +279,30 @@ define(function (require) { } }); + + + bdd.describe('query #2, which has an empty time range', function () { + var fromTime = '1999-06-11 09:22:11.000'; + var toTime = '1999-06-12 11:21:04.000'; + + bdd.before(() => { + common.debug('setAbsoluteRangeForAnotherQuery'); + return headerPage.setAbsoluteRange(fromTime, toTime); + }); + + bdd.it('should show "no results"', () => { + discoverPage.hasNoResults().then(noResults => { + expect(noResults).to.not.be(true); + }); + }); + + bdd.it('should suggest a new time range is picked', () => { + discoverPage.hasNoResultsTimepicker().then(hasTimepicker => { + expect(hasTimepicker).to.be(true); + }); + }); + }); + }); }; }); diff --git a/test/support/pages/discover_page.js b/test/support/pages/discover_page.js index 62604fe27178..ad839bf13fc5 100644 --- a/test/support/pages/discover_page.js +++ b/test/support/pages/discover_page.js @@ -218,7 +218,21 @@ define(function (require) { return thisTime .findByClassName('sidebar-list') .getProperty('clientWidth'); - } + }, + + hasNoResults: function hasNoResults() { + return thisTime + .findByCssSelector('[data-test-subj="discoverNoResults"]') + .getVisibleText() + .then(text => text.length > 0); + }, + + hasNoResultsTimepicker: function hasNoResults() { + return thisTime + .findByCssSelector('[data-test-subj="discoverNoResultsTimefilter"]') + .getVisibleText() + .then(text => text.length > 0); + }, };