[test/functional] Add test case for expand/collapse timepicker from discover's "No Results".

This commit is contained in:
Nicolas Bevacqua 2016-03-30 14:50:32 -03:00
parent 4036c46b8f
commit bc0278f266
5 changed files with 50 additions and 19 deletions

View file

@ -94,7 +94,7 @@
<div class="discover-wrapper col-md-10">
<div class="discover-content">
<discover-no-results></discover-no-results>
<discover-no-results ng-show="resultState === 'none'"></discover-no-results>
<!-- loading -->
<div ng-show="resultState === 'loading'">

View file

@ -1,4 +1,4 @@
<div ng-show="resultState === 'none'" data-test-subj="discoverNoResults">
<div data-test-subj="discoverNoResults">
<div class="col-md-10 col-md-offset-1">
<h1>No results found <i aria-hidden="true" class="fa fa-meh-o"></i></h1>

View file

@ -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();
});
}
});
});

View file

@ -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;

View file

@ -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();