Skip to content

Commit

Permalink
Merge pull request #6032 from LeeDr/expandCollapse
Browse files Browse the repository at this point in the history
6 new Expand collapse Discover tests
  • Loading branch information
LeeDr committed Jan 28, 2016
2 parents 9086f50 + 763c564 commit 140e707
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 0 deletions.
128 changes: 128 additions & 0 deletions test/functional/apps/discover/_collapse_expand.js
Original file line number Diff line number Diff line change
@@ -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));
});

});

});
};
});
3 changes: 3 additions & 0 deletions test/functional/apps/discover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,5 +29,7 @@ define(function (require) {

sharedLinks(bdd, scenarioManager);

collapseExpand(bdd, scenarioManager);

});
});
36 changes: 36 additions & 0 deletions test/support/pages/DiscoverPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

};
Expand Down

0 comments on commit 140e707

Please sign in to comment.