mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Simplify NoResultsTimefilter link test
This reformulates the test case to a simple sequence of actions and assertions to improve maintainability.
This commit is contained in:
parent
db775687f2
commit
88c0b7b75e
1 changed files with 7 additions and 31 deletions
|
@ -237,39 +237,15 @@ bdd.describe('discover app', function describeIndexTests() {
|
|||
expect(isVisible).to.be(true);
|
||||
});
|
||||
|
||||
bdd.it('should open and close the time picker', () => {
|
||||
let i = 0;
|
||||
bdd.it('should have a link that opens and closes the time picker', async function() {
|
||||
var noResultsTimepickerLink = await PageObjects.discover.getNoResultsTimepicker();
|
||||
expect(await PageObjects.header.isTimepickerOpen()).to.be(false);
|
||||
|
||||
return closeTimepicker() // close
|
||||
.then(() => isTimepickerOpen(false)
|
||||
.then(el => el.click()) // open
|
||||
.then(() => isTimepickerOpen(true))
|
||||
.then(el => el.click()) // close
|
||||
.then(() => isTimepickerOpen(false))
|
||||
.catch(PageObjects.common.createErrorHandler(this))
|
||||
);
|
||||
await noResultsTimepickerLink.click();
|
||||
expect(await PageObjects.header.isTimepickerOpen()).to.be(true);
|
||||
|
||||
function closeTimepicker() {
|
||||
return PageObjects.header.isTimepickerOpen().then(shown => {
|
||||
if (!shown) {
|
||||
return;
|
||||
}
|
||||
return PageObjects.discover
|
||||
.getNoResultsTimepicker()
|
||||
.click(); // close
|
||||
});
|
||||
}
|
||||
|
||||
function isTimepickerOpen(expected) {
|
||||
return PageObjects.header.isTimepickerOpen().then(shown => {
|
||||
PageObjects.common.debug(`expect (#${++i}) timepicker to be ${peek(expected)} (is ${peek(shown)}).`);
|
||||
expect(shown).to.be(expected);
|
||||
return PageObjects.discover.getNoResultsTimepicker();
|
||||
function peek(state) {
|
||||
return state ? 'open' : 'closed';
|
||||
}
|
||||
});
|
||||
}
|
||||
await noResultsTimepickerLink.click();
|
||||
expect(await PageObjects.header.isTimepickerOpen()).to.be(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue