Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Visualize] Add missing advanced settings and custom label for pipeline aggs #69688

Merged
merged 6 commits into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function DefaultEditorAggGroup({
<EuiSpacer size="s" />
{bucketsError && (
<>
<EuiFormErrorText>{bucketsError}</EuiFormErrorText>
<EuiFormErrorText data-test-subj="bucketsError">{bucketsError}</EuiFormErrorText>
<EuiSpacer size="s" />
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ function getAggParamsToRender({
const aggType = agg.type.type;
const aggName = agg.type.name;
const aggParams = get(aggParamsMap, [aggType, aggName], {});
paramEditor = get(aggParams, param.name) || get(aggParamsMap, ['common', param.type]);
paramEditor = get(aggParams, param.name);
}

if (!paramEditor) {
paramEditor = get(aggParamsMap, ['common', param.type]);
}

// show params with an editor component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ function SubMetricParamEditor({
defaultMessage: 'Bucket',
});
const type = aggParam.name;
const isCustomMetric = type === 'customMetric';

const aggTitle = type === 'customMetric' ? metricTitle : bucketTitle;
const aggGroup = type === 'customMetric' ? AggGroupNames.Metrics : AggGroupNames.Buckets;
const aggTitle = isCustomMetric ? metricTitle : bucketTitle;
const aggGroup = isCustomMetric ? AggGroupNames.Metrics : AggGroupNames.Buckets;

useMount(() => {
if (agg.params[type]) {
Expand Down Expand Up @@ -87,7 +88,7 @@ function SubMetricParamEditor({
setValidity={setValidity}
setTouched={setTouched}
schemas={schemas}
hideCustomLabel={true}
hideCustomLabel={!isCustomMetric}
/>
</>
);
Expand Down
74 changes: 74 additions & 0 deletions test/functional/apps/visualize/_line_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,5 +279,79 @@ export default function ({ getService, getPageObjects }) {
expect(labels).to.eql(expectedLabels);
});
});

describe('pipeline aggregations', () => {
before(async () => {
log.debug('navigateToApp visualize');
await PageObjects.visualize.navigateToNewVisualization();
log.debug('clickLineChart');
await PageObjects.visualize.clickLineChart();
await PageObjects.visualize.clickNewSearch();
await PageObjects.timePicker.setDefaultAbsoluteRange();
});

describe('parent pipeline', () => {
it('should have an error if bucket is not selected', async () => {
await PageObjects.visEditor.clickMetricEditor();
log.debug('Metrics agg = Serial diff');
await PageObjects.visEditor.selectAggregation('Serial diff', 'metrics');
await testSubjects.existOrFail('bucketsError');
});

it('should apply with selected bucket', async () => {
log.debug('Bucket = X-axis');
await PageObjects.visEditor.clickBucket('X-axis');
log.debug('Aggregation = Date Histogram');
await PageObjects.visEditor.selectAggregation('Date Histogram');
await PageObjects.visEditor.clickGo();
const title = await PageObjects.visChart.getYAxisTitle();
expect(title).to.be('Serial Diff of Count');
});

it('should change y-axis label to custom', async () => {
log.debug('set custom label of y-axis to "Custom"');
await PageObjects.visEditor.setCustomLabel('Custom', 1);
await PageObjects.visEditor.clickGo();
const title = await PageObjects.visChart.getYAxisTitle();
expect(title).to.be('Custom');
});

it('should have advanced accordion and json input', async () => {
await testSubjects.click('advancedParams-1');
await testSubjects.existOrFail('advancedParams-1 > codeEditorContainer');
});
});

describe('sibling pipeline', () => {
it('should apply with selected bucket', async () => {
log.debug('Metrics agg = Average Bucket');
await PageObjects.visEditor.selectAggregation('Average Bucket', 'metrics');
await PageObjects.visEditor.clickGo();
const title = await PageObjects.visChart.getYAxisTitle();
expect(title).to.be('Overall Average of Count');
});

it('should change sub metric custom label and calculate y-axis title', async () => {
log.debug('set custom label of sub metric to "Cats"');
await PageObjects.visEditor.setCustomLabel('Cats', '1-metric');
await PageObjects.visEditor.clickGo();
const title = await PageObjects.visChart.getYAxisTitle();
expect(title).to.be('Overall Average of Cats');
});

it('should outer custom label', async () => {
log.debug('set custom label to "Custom"');
await PageObjects.visEditor.setCustomLabel('Custom', 1);
await PageObjects.visEditor.clickGo();
const title = await PageObjects.visChart.getYAxisTitle();
expect(title).to.be('Custom');
});

it('should have advanced accordion and json input', async () => {
await testSubjects.click('advancedParams-1');
await testSubjects.existOrFail('advancedParams-1 > codeEditorContainer');
});
});
});
});
}