Skip to content

Commit

Permalink
Make sub metric in sibling pipeline to have custom label
Browse files Browse the repository at this point in the history
  • Loading branch information
sulemanof committed Jun 26, 2020
1 parent 5b0823f commit 6e642d1
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 29 deletions.
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
85 changes: 59 additions & 26 deletions test/functional/apps/visualize/_line_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,34 +290,67 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.timePicker.setDefaultAbsoluteRange();
});

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');
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');
});
});

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 "test"');
await PageObjects.visEditor.setCustomLabel('test', 1);
await PageObjects.visEditor.clickGo();
const title = await PageObjects.visChart.getYAxisTitle();
expect(title).to.be('test');
});

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');
});
});
});
});
Expand Down

0 comments on commit 6e642d1

Please sign in to comment.