Skip to content

Commit 97fbd07

Browse files
[Visualize] Add missing advanced settings and custom label for pipeline aggs (#69688)
* Show advanced settings in pipeline aggs * Add functional tests * Make sub metric in sibling pipeline to have custom label Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent c43dfaa commit 97fbd07

4 files changed

Lines changed: 84 additions & 5 deletions

File tree

src/plugins/vis_default_editor/public/components/agg_group.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ function DefaultEditorAggGroup({
152152
<EuiSpacer size="s" />
153153
{bucketsError && (
154154
<>
155-
<EuiFormErrorText>{bucketsError}</EuiFormErrorText>
155+
<EuiFormErrorText data-test-subj="bucketsError">{bucketsError}</EuiFormErrorText>
156156
<EuiSpacer size="s" />
157157
</>
158158
)}

src/plugins/vis_default_editor/public/components/agg_params_helper.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ function getAggParamsToRender({
111111
const aggType = agg.type.type;
112112
const aggName = agg.type.name;
113113
const aggParams = get(aggParamsMap, [aggType, aggName], {});
114-
paramEditor = get(aggParams, param.name) || get(aggParamsMap, ['common', param.type]);
114+
paramEditor = get(aggParams, param.name);
115+
}
116+
117+
if (!paramEditor) {
118+
paramEditor = get(aggParamsMap, ['common', param.type]);
115119
}
116120

117121
// show params with an editor component

src/plugins/vis_default_editor/public/components/controls/sub_metric.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ function SubMetricParamEditor({
4545
defaultMessage: 'Bucket',
4646
});
4747
const type = aggParam.name;
48+
const isCustomMetric = type === 'customMetric';
4849

49-
const aggTitle = type === 'customMetric' ? metricTitle : bucketTitle;
50-
const aggGroup = type === 'customMetric' ? AggGroupNames.Metrics : AggGroupNames.Buckets;
50+
const aggTitle = isCustomMetric ? metricTitle : bucketTitle;
51+
const aggGroup = isCustomMetric ? AggGroupNames.Metrics : AggGroupNames.Buckets;
5152

5253
useMount(() => {
5354
if (agg.params[type]) {
@@ -87,7 +88,7 @@ function SubMetricParamEditor({
8788
setValidity={setValidity}
8889
setTouched={setTouched}
8990
schemas={schemas}
90-
hideCustomLabel={true}
91+
hideCustomLabel={!isCustomMetric}
9192
/>
9293
</>
9394
);

test/functional/apps/visualize/_line_chart.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,5 +279,79 @@ export default function ({ getService, getPageObjects }) {
279279
expect(labels).to.eql(expectedLabels);
280280
});
281281
});
282+
283+
describe('pipeline aggregations', () => {
284+
before(async () => {
285+
log.debug('navigateToApp visualize');
286+
await PageObjects.visualize.navigateToNewVisualization();
287+
log.debug('clickLineChart');
288+
await PageObjects.visualize.clickLineChart();
289+
await PageObjects.visualize.clickNewSearch();
290+
await PageObjects.timePicker.setDefaultAbsoluteRange();
291+
});
292+
293+
describe('parent pipeline', () => {
294+
it('should have an error if bucket is not selected', async () => {
295+
await PageObjects.visEditor.clickMetricEditor();
296+
log.debug('Metrics agg = Serial diff');
297+
await PageObjects.visEditor.selectAggregation('Serial diff', 'metrics');
298+
await testSubjects.existOrFail('bucketsError');
299+
});
300+
301+
it('should apply with selected bucket', async () => {
302+
log.debug('Bucket = X-axis');
303+
await PageObjects.visEditor.clickBucket('X-axis');
304+
log.debug('Aggregation = Date Histogram');
305+
await PageObjects.visEditor.selectAggregation('Date Histogram');
306+
await PageObjects.visEditor.clickGo();
307+
const title = await PageObjects.visChart.getYAxisTitle();
308+
expect(title).to.be('Serial Diff of Count');
309+
});
310+
311+
it('should change y-axis label to custom', async () => {
312+
log.debug('set custom label of y-axis to "Custom"');
313+
await PageObjects.visEditor.setCustomLabel('Custom', 1);
314+
await PageObjects.visEditor.clickGo();
315+
const title = await PageObjects.visChart.getYAxisTitle();
316+
expect(title).to.be('Custom');
317+
});
318+
319+
it('should have advanced accordion and json input', async () => {
320+
await testSubjects.click('advancedParams-1');
321+
await testSubjects.existOrFail('advancedParams-1 > codeEditorContainer');
322+
});
323+
});
324+
325+
describe('sibling pipeline', () => {
326+
it('should apply with selected bucket', async () => {
327+
log.debug('Metrics agg = Average Bucket');
328+
await PageObjects.visEditor.selectAggregation('Average Bucket', 'metrics');
329+
await PageObjects.visEditor.clickGo();
330+
const title = await PageObjects.visChart.getYAxisTitle();
331+
expect(title).to.be('Overall Average of Count');
332+
});
333+
334+
it('should change sub metric custom label and calculate y-axis title', async () => {
335+
log.debug('set custom label of sub metric to "Cats"');
336+
await PageObjects.visEditor.setCustomLabel('Cats', '1-metric');
337+
await PageObjects.visEditor.clickGo();
338+
const title = await PageObjects.visChart.getYAxisTitle();
339+
expect(title).to.be('Overall Average of Cats');
340+
});
341+
342+
it('should outer custom label', async () => {
343+
log.debug('set custom label to "Custom"');
344+
await PageObjects.visEditor.setCustomLabel('Custom', 1);
345+
await PageObjects.visEditor.clickGo();
346+
const title = await PageObjects.visChart.getYAxisTitle();
347+
expect(title).to.be('Custom');
348+
});
349+
350+
it('should have advanced accordion and json input', async () => {
351+
await testSubjects.click('advancedParams-1');
352+
await testSubjects.existOrFail('advancedParams-1 > codeEditorContainer');
353+
});
354+
});
355+
});
282356
});
283357
}

0 commit comments

Comments
 (0)