diff --git a/test/functional/apps/discover/_collapse_expand.js b/test/functional/apps/discover/_collapse_expand.js new file mode 100644 index 0000000000000..25f4260b3e35f --- /dev/null +++ b/test/functional/apps/discover/_collapse_expand.js @@ -0,0 +1,128 @@ +define(function (require) { + var Common = require('../../../support/pages/Common'); + var HeaderPage = require('../../../support/pages/HeaderPage'); + var SettingsPage = require('../../../support/pages/settings_page'); + var DiscoverPage = require('../../../support/pages/DiscoverPage'); + var expect = require('intern/dojo/node!expect.js'); + + return function (bdd, scenarioManager) { + bdd.describe('discover tab', function describeIndexTests() { + var common; + var headerPage; + var settingsPage; + var discoverPage; + var baseUrl; + + bdd.before(function () { + common = new Common(this.remote); + headerPage = new HeaderPage(this.remote); + settingsPage = new SettingsPage(this.remote); + discoverPage = new DiscoverPage(this.remote); + + baseUrl = common.getHostPort(); + + var fromTime = '2015-09-19 06:31:44.000'; + var toTime = '2015-09-23 18:31:44.000'; + + // start each test with an empty kibana index + return scenarioManager.reload('emptyKibana') + // and load a set of makelogs data + .then(function loadIfEmptyMakelogs() { + return scenarioManager.loadIfEmpty('logstashFunctional'); + }) + .then(function (navigateTo) { + common.debug('navigateTo'); + return settingsPage.navigateTo(); + }) + .then(function () { + common.debug('createIndexPattern'); + return settingsPage.createIndexPattern(); + }) + .then(function () { + common.debug('discover'); + return common.navigateToApp('discover'); + }) + .then(function () { + common.debug('setAbsoluteRange'); + return headerPage.setAbsoluteRange(fromTime, toTime); + }) + .catch(common.handleError(this)); + }); + + + bdd.describe('legend', function () { + + bdd.it('should initially be collapsed', function () { + return discoverPage.getLegendWidth() + .then(function (actualwidth) { + common.debug('collapsed legend width = ' + actualwidth); + expect(actualwidth < 20).to.be(true); + }) + .catch(common.handleError(this)); + }); + + bdd.it('should expand when clicked', function () { + return discoverPage.clickLegendExpand() + .then(function () { + return discoverPage.getLegendWidth(); + }) + .then(function (actualwidth) { + common.debug('expanded legend width = ' + actualwidth); + expect(actualwidth > 140).to.be(true); + }) + .catch(common.handleError(this)); + }); + + bdd.it('should collapse when clicked', function () { + return discoverPage.clickLegendCollapse() + .then(function () { + return discoverPage.getLegendWidth(); + }) + .then(function (actualwidth) { + expect(actualwidth < 20).to.be(true); + }) + .catch(common.handleError(this)); + }); + + }); + + bdd.describe('field data', function () { + + bdd.it('should initially be expanded', function () { + return discoverPage.getSidebarWidth() + .then(function (actualwidth) { + common.debug('expanded sidebar width = ' + actualwidth); + expect(actualwidth > 180).to.be(true); + }) + .catch(common.handleError(this)); + }); + + bdd.it('should collapse when clicked', function () { + return discoverPage.clickSidebarCollapse() + .then(function () { + return discoverPage.getSidebarWidth(); + }) + .then(function (actualwidth) { + common.debug('collapsed sidebar width = ' + actualwidth); + expect(actualwidth < 20).to.be(true); + }) + .catch(common.handleError(this)); + }); + + bdd.it('should expand when clicked', function () { + return discoverPage.clickSidebarExpand() + .then(function () { + return discoverPage.getSidebarWidth(); + }) + .then(function (actualwidth) { + common.debug('expanded sidebar width = ' + actualwidth); + expect(actualwidth > 180).to.be(true); + }) + .catch(common.handleError(this)); + }); + + }); + + }); + }; +}); diff --git a/test/functional/apps/discover/index.js b/test/functional/apps/discover/index.js index c7885133e7e89..176d6cacbc2b6 100644 --- a/test/functional/apps/discover/index.js +++ b/test/functional/apps/discover/index.js @@ -6,6 +6,7 @@ define(function (require) { var discoverTest = require('./_discover'); var fieldData = require('./_field_data'); var sharedLinks = require('./_shared_links'); + var collapseExpand = require('./_collapse_expand'); bdd.describe('discover app', function () { var scenarioManager; @@ -28,5 +29,7 @@ define(function (require) { sharedLinks(bdd, scenarioManager); + collapseExpand(bdd, scenarioManager); + }); }); diff --git a/test/support/pages/DiscoverPage.js b/test/support/pages/DiscoverPage.js index 3dcf3f55fbf1c..84b887b77ea17 100644 --- a/test/support/pages/DiscoverPage.js +++ b/test/support/pages/DiscoverPage.js @@ -211,6 +211,42 @@ define(function (require) { return thisTime .findByCssSelector('.url') .getProperty('value'); + }, + + clickLegendExpand: function clickLegendExpand() { + return thisTime + .findByCssSelector('.fa-chevron-left') + .click(); + }, + + clickLegendCollapse: function clickLegendCollapse() { + return thisTime + .findByCssSelector('div.legend-toggle > i.fa-chevron-right') + .click(); + }, + + getLegendWidth: function getLegendWidth() { + return thisTime + .findByCssSelector('.legend-col-wrapper') + .getProperty('clientWidth'); + }, + + clickSidebarExpand: function clickSidebarExpand() { + return thisTime + .findByCssSelector('.chevron-cont') + .click(); + }, + + clickSidebarCollapse: function clickSidebarCollapse() { + return thisTime + .findByCssSelector('.chevron-cont') + .click(); + }, + + getSidebarWidth: function getSidebarWidth() { + return thisTime + .findByCssSelector('.sidebar-list') + .getProperty('clientWidth'); } };