From 348a939b5455dfde58978f575289689202a0ebb6 Mon Sep 17 00:00:00 2001 From: Nicolas Bevacqua Date: Wed, 30 Mar 2016 12:45:47 -0300 Subject: [PATCH 1/6] [bugfix] Fix timepicker button behavior in "No Results" page. Fixes #4947. --- src/plugins/kibana/public/discover/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/kibana/public/discover/index.html b/src/plugins/kibana/public/discover/index.html index 7989535a6ed2f..c71c8f9117294 100644 --- a/src/plugins/kibana/public/discover/index.html +++ b/src/plugins/kibana/public/discover/index.html @@ -117,7 +117,7 @@

Shard Failures

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 the time picker in the top right corner of your screen. +

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.

From 4036c46b8fc0980211e720a995e53a787fd1d107 Mon Sep 17 00:00:00 2001 From: Nicolas Bevacqua Date: Wed, 30 Mar 2016 14:08:56 -0300 Subject: [PATCH 2/6] [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 0000000000000..85cffe96ab54d --- /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 c71c8f9117294..36e49c8894c04 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 7d117dc9a22e2..545a1e5398bf7 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 0000000000000..4bc86e5c35a75 --- /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 9cec39dc31caf..3f5c67dbea5cc 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 62604fe27178a..ad839bf13fc51 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); + }, }; From bc0278f26646c55c9977474e57e3044205e9ca75 Mon Sep 17 00:00:00 2001 From: Nicolas Bevacqua Date: Wed, 30 Mar 2016 14:50:32 -0300 Subject: [PATCH 3/6] [test/functional] Add test case for expand/collapse timepicker from discover's "No Results". --- src/plugins/kibana/public/discover/index.html | 2 +- .../public/discover/partials/no_results.html | 2 +- test/functional/apps/discover/_discover.js | 38 ++++++++++++++----- test/support/pages/discover_page.js | 20 ++++++---- test/support/pages/header_page.js | 7 ++++ 5 files changed, 50 insertions(+), 19 deletions(-) diff --git a/src/plugins/kibana/public/discover/index.html b/src/plugins/kibana/public/discover/index.html index 36e49c8894c04..2df1d090c6e28 100644 --- a/src/plugins/kibana/public/discover/index.html +++ b/src/plugins/kibana/public/discover/index.html @@ -94,7 +94,7 @@
- +
diff --git a/src/plugins/kibana/public/discover/partials/no_results.html b/src/plugins/kibana/public/discover/partials/no_results.html index 4bc86e5c35a75..3f8d8b78b8d46 100644 --- a/src/plugins/kibana/public/discover/partials/no_results.html +++ b/src/plugins/kibana/public/discover/partials/no_results.html @@ -1,4 +1,4 @@ -
+

No results found

diff --git a/test/functional/apps/discover/_discover.js b/test/functional/apps/discover/_discover.js index 3f5c67dbea5cc..6209b1a9df329 100644 --- a/test/functional/apps/discover/_discover.js +++ b/test/functional/apps/discover/_discover.js @@ -246,8 +246,8 @@ define(function (require) { }); bdd.it('should not show "no results"', () => { - discoverPage.hasNoResults().then(noResults => { - expect(noResults).to.be(false); + discoverPage.hasNoResults().then(visible => { + expect(visible).to.be(false); }); }); @@ -287,19 +287,39 @@ define(function (require) { bdd.before(() => { common.debug('setAbsoluteRangeForAnotherQuery'); - return headerPage.setAbsoluteRange(fromTime, toTime); + return headerPage + .setAbsoluteRange(fromTime, toTime) + .catch(common.handleError(this)); }); bdd.it('should show "no results"', () => { - discoverPage.hasNoResults().then(noResults => { - expect(noResults).to.not.be(true); - }); + discoverPage.hasNoResults().then(visible => { + expect(visible).to.be(true); + }) + .catch(common.handleError(this)); }); bdd.it('should suggest a new time range is picked', () => { - discoverPage.hasNoResultsTimepicker().then(hasTimepicker => { - expect(hasTimepicker).to.be(true); - }); + discoverPage.hasNoResultsTimepicker().then(visible => { + expect(visible).to.be(true); + }) + .catch(common.handleError(this)); + }); + + bdd.it('should open and close the time picker', () => { + isTimepickerOpen(false) + .click() + .then(() => isTimepickerOpen(true)) + .click() + .then(() => isTimepickerOpen(false)) + .catch(common.handleError(this)); + + function isTimepickerOpen(expected) { + return headerPage.isTimepickerOpen().then(shown => { + expect(shown).to.be(expected); + return discoverPage.getNoResultsTimepicker(); + }); + } }); }); diff --git a/test/support/pages/discover_page.js b/test/support/pages/discover_page.js index ad839bf13fc51..91d435c01435d 100644 --- a/test/support/pages/discover_page.js +++ b/test/support/pages/discover_page.js @@ -222,18 +222,22 @@ define(function (require) { hasNoResults: function hasNoResults() { return thisTime - .findByCssSelector('[data-test-subj="discoverNoResults"]') - .getVisibleText() - .then(text => text.length > 0); + .findTestSubject('discoverNoResult') + .then(() => true) + .catch(() => false); }, - hasNoResultsTimepicker: function hasNoResults() { - return thisTime - .findByCssSelector('[data-test-subj="discoverNoResultsTimefilter"]') - .getVisibleText() - .then(text => text.length > 0); + getNoResultsTimepicker: function getNoResultsTimepicker() { + return thisTime.findTestSubject('discoverNoResultsTimefilter'); }, + hasNoResultsTimepicker: function hasNoResultsTimepicker() { + return this + .getNoResultsTimepicker() + .then(() => true) + .catch(() => false); + } + }; return DiscoverPage; diff --git a/test/support/pages/header_page.js b/test/support/pages/header_page.js index b87c29095bc21..44719712dd5f5 100644 --- a/test/support/pages/header_page.js +++ b/test/support/pages/header_page.js @@ -54,6 +54,13 @@ define(function (require) { .findDisplayedByClassName('navbar-timepicker-time-desc').click(); }, + isTimepickerOpen: function isTimepickerOpen() { + return this.remote.setFindTimeout(defaultTimeout) + .findDisplayedByClassName('config') + .then(() => true) + .catch(() => false); + }, + clickAbsoluteButton: function clickAbsoluteButton() { return this.remote.setFindTimeout(defaultTimeout) .findByLinkText('Absolute').click(); From 50581a86ababf06f3d70ab9bd47d9e20a4acf65b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Bevacqua?= Date: Fri, 20 May 2016 17:39:56 -0300 Subject: [PATCH 4/6] [test] Fix test cases for No Results page. --- test/support/pages/discover_page.js | 4 ++-- test/support/pages/header_page.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/support/pages/discover_page.js b/test/support/pages/discover_page.js index eb64ee0b43594..7141bc1f415e0 100644 --- a/test/support/pages/discover_page.js +++ b/test/support/pages/discover_page.js @@ -214,14 +214,14 @@ export default (function () { }, hasNoResults: function hasNoResults() { - return thisTime + return common .findTestSubject('discoverNoResult') .then(() => true) .catch(() => false); }, getNoResultsTimepicker: function getNoResultsTimepicker() { - return thisTime.findTestSubject('discoverNoResultsTimefilter'); + return common.findTestSubject('discoverNoResultsTimefilter'); }, hasNoResultsTimepicker: function hasNoResultsTimepicker() { diff --git a/test/support/pages/header_page.js b/test/support/pages/header_page.js index 3e99648352dad..54401ab024582 100644 --- a/test/support/pages/header_page.js +++ b/test/support/pages/header_page.js @@ -49,7 +49,7 @@ export default (function () { }, isTimepickerOpen: function isTimepickerOpen() { - return this.remote.setFindTimeout(defaultTimeout) + return this.remote.setFindTimeout(defaultFindTimeout) .findDisplayedByClassName('config') .then(() => true) .catch(() => false); From b3b31288e6b1947adb8560b1dcd69dcac1d8b902 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Bevacqua?= Date: Thu, 26 May 2016 18:00:52 -0300 Subject: [PATCH 5/6] [test] Return all the Promises. --- test/functional/apps/discover/_discover.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/functional/apps/discover/_discover.js b/test/functional/apps/discover/_discover.js index 232fbc522416f..ed604a094bbbd 100644 --- a/test/functional/apps/discover/_discover.js +++ b/test/functional/apps/discover/_discover.js @@ -242,7 +242,7 @@ import { }); bdd.it('should not show "no results"', () => { - discoverPage.hasNoResults().then(visible => { + return discoverPage.hasNoResults().then(visible => { expect(visible).to.be(false); }); }); @@ -289,21 +289,21 @@ import { }); bdd.it('should show "no results"', () => { - discoverPage.hasNoResults().then(visible => { + return discoverPage.hasNoResults().then(visible => { expect(visible).to.be(true); }) .catch(common.handleError(this)); }); bdd.it('should suggest a new time range is picked', () => { - discoverPage.hasNoResultsTimepicker().then(visible => { + return discoverPage.hasNoResultsTimepicker().then(visible => { expect(visible).to.be(true); }) .catch(common.handleError(this)); }); bdd.it('should open and close the time picker', () => { - isTimepickerOpen(false) + return isTimepickerOpen(false) .click() .then(() => isTimepickerOpen(true)) .click() From 496b8a998eb1a9e37d199066d0cc17bd6ffe9e91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Bevacqua?= Date: Tue, 31 May 2016 18:49:12 -0300 Subject: [PATCH 6/6] [test] Fix test fixtures. --- .../public/discover/partials/no_results.html | 6 ++-- test/functional/apps/discover/_discover.js | 34 +++++++++++++++---- test/support/pages/discover_page.js | 2 +- test/support/pages/header_page.js | 2 +- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/plugins/kibana/public/discover/partials/no_results.html b/src/plugins/kibana/public/discover/partials/no_results.html index 3f8d8b78b8d46..eb3b434baebb4 100644 --- a/src/plugins/kibana/public/discover/partials/no_results.html +++ b/src/plugins/kibana/public/discover/partials/no_results.html @@ -1,5 +1,5 @@ -
-
+
+

No results found

@@ -20,7 +20,7 @@

Shard Failures

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. +

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.

diff --git a/test/functional/apps/discover/_discover.js b/test/functional/apps/discover/_discover.js index ed604a094bbbd..8809183b60ef9 100644 --- a/test/functional/apps/discover/_discover.js +++ b/test/functional/apps/discover/_discover.js @@ -244,7 +244,8 @@ import { bdd.it('should not show "no results"', () => { return discoverPage.hasNoResults().then(visible => { expect(visible).to.be(false); - }); + }) + .catch(common.handleError(this)); }); function verifyChartData(expectedBarChartData) { @@ -303,17 +304,36 @@ import { }); bdd.it('should open and close the time picker', () => { - return isTimepickerOpen(false) - .click() - .then(() => isTimepickerOpen(true)) - .click() - .then(() => isTimepickerOpen(false)) - .catch(common.handleError(this)); + let i = 0; + + return closeTimepicker() // close + .then(() => isTimepickerOpen(false) + .then(el => el.click()) // open + .then(() => isTimepickerOpen(true)) + .then(el => el.click()) // close + .then(() => isTimepickerOpen(false)) + .catch(common.handleError(this)) + ); + + function closeTimepicker() { + return headerPage.isTimepickerOpen().then(shown => { + if (!shown) { + return; + } + return discoverPage + .getNoResultsTimepicker() + .click(); // close + }); + } function isTimepickerOpen(expected) { return headerPage.isTimepickerOpen().then(shown => { + common.debug(`expect (#${++i}) timepicker to be ${peek(expected)} (is ${peek(shown)}).`); expect(shown).to.be(expected); return discoverPage.getNoResultsTimepicker(); + function peek(state) { + return state ? 'open' : 'closed'; + } }); } }); diff --git a/test/support/pages/discover_page.js b/test/support/pages/discover_page.js index 7141bc1f415e0..bfc5b63dc7bba 100644 --- a/test/support/pages/discover_page.js +++ b/test/support/pages/discover_page.js @@ -215,7 +215,7 @@ export default (function () { hasNoResults: function hasNoResults() { return common - .findTestSubject('discoverNoResult') + .findTestSubject('discoverNoResults') .then(() => true) .catch(() => false); }, diff --git a/test/support/pages/header_page.js b/test/support/pages/header_page.js index 54401ab024582..8fda774024d5e 100644 --- a/test/support/pages/header_page.js +++ b/test/support/pages/header_page.js @@ -50,7 +50,7 @@ export default (function () { isTimepickerOpen: function isTimepickerOpen() { return this.remote.setFindTimeout(defaultFindTimeout) - .findDisplayedByClassName('config') + .findDisplayedByCssSelector('.kbn-timepicker') .then(() => true) .catch(() => false); },