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] [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); },