From b2947207fb8e9f85ead5bed6702ae1caea9999cc Mon Sep 17 00:00:00 2001 From: ppisljar Date: Tue, 11 Sep 2018 10:57:49 +0200 Subject: [PATCH 1/2] fixing sorting of terms bucket --- src/ui/public/agg_types/buckets/terms.js | 2 +- src/ui/public/vis/agg_configs.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/public/agg_types/buckets/terms.js b/src/ui/public/agg_types/buckets/terms.js index 3317707e736bc..5306eca67d2a8 100644 --- a/src/ui/public/agg_types/buckets/terms.js +++ b/src/ui/public/agg_types/buckets/terms.js @@ -147,7 +147,7 @@ export const termsBucketAgg = new BucketAggType({ makeOrderAgg: function (termsAgg, state) { state = state || {}; state.schema = orderAggSchema; - const orderAgg = this.aggConfigs.createAggConfig(state); + const orderAgg = termsAgg.aggConfigs.createAggConfig(state, { addToAggConfigs: false }); orderAgg.id = termsAgg.id + '-orderAgg'; return orderAgg; }, diff --git a/src/ui/public/vis/agg_configs.js b/src/ui/public/vis/agg_configs.js index c61fae5ec740b..6aebeabd08159 100644 --- a/src/ui/public/vis/agg_configs.js +++ b/src/ui/public/vis/agg_configs.js @@ -96,7 +96,7 @@ class AggConfigs extends IndexedArray { updateAggTimeRange(param); } }); - if (agg.type.name === 'date_histogram') { + if (_.get(agg, 'type.name') === 'date_histogram') { agg.params.timeRange = timeRange; } }; From fec6c65a7cb7c039550124c4c945231bfe98449f Mon Sep 17 00:00:00 2001 From: ppisljar Date: Tue, 11 Sep 2018 11:46:21 +0200 Subject: [PATCH 2/2] adding selenium test --- src/ui/public/agg_types/controls/order_agg.html | 5 +++-- test/functional/apps/visualize/_vertical_bar_chart.js | 11 +++++++++++ test/functional/page_objects/visualize_page.js | 11 +++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/ui/public/agg_types/controls/order_agg.html b/src/ui/public/agg_types/controls/order_agg.html index 4d600c75fd594..3dc09c56dd35f 100644 --- a/src/ui/public/agg_types/controls/order_agg.html +++ b/src/ui/public/agg_types/controls/order_agg.html @@ -10,14 +10,15 @@ - - diff --git a/test/functional/apps/visualize/_vertical_bar_chart.js b/test/functional/apps/visualize/_vertical_bar_chart.js index 28d97c2367104..a623a3e2e3261 100644 --- a/test/functional/apps/visualize/_vertical_bar_chart.js +++ b/test/functional/apps/visualize/_vertical_bar_chart.js @@ -208,6 +208,17 @@ export default function ({ getService, getPageObjects }) { const legendEntries = await PageObjects.visualize.getLegendEntries(); expect(legendEntries).to.eql(expectedEntries); }); + + it('should allow custom sorting of series', async () => { + await PageObjects.visualize.toggleOpenEditor(1, 'false'); + await PageObjects.visualize.selectCustomSortMetric(3, 'Min', 'bytes'); + await PageObjects.visualize.clickGo(); + await PageObjects.header.waitUntilLoadingHasFinished(); + + const expectedEntries = ['404', '200', '503']; + const legendEntries = await PageObjects.visualize.getLegendEntries(); + expect(legendEntries).to.eql(expectedEntries); + }); }); describe('vertical bar with multiple splits', function () { diff --git a/test/functional/page_objects/visualize_page.js b/test/functional/page_objects/visualize_page.js index b772266976145..d182025363035 100644 --- a/test/functional/page_objects/visualize_page.js +++ b/test/functional/page_objects/visualize_page.js @@ -1132,6 +1132,17 @@ export function VisualizePageProvider({ getService, getPageObjects }) { const pieSlices = await this.getAllPieSlices(name); return await Promise.all(pieSlices.map(async pieSlice => await pieSlice.getAttribute('style'))); } + + async selectSortMetric(agg, metric) { + const sortMetric = await find.byCssSelector(`[data-test-subj="visEditorOrder${agg}-${metric}"]`); + return await sortMetric.click(); + } + + async selectCustomSortMetric(agg, metric, field) { + await this.selectSortMetric(agg, 'custom'); + await this.selectAggregation(metric, 'groupName'); + await this.selectField(field, 'groupName'); + } } return new VisualizePage();