fixing field formatters for gauge (#15145) (#15244)

* fixing field formatters for gauge
This commit is contained in:
Peter Pisljar 2017-11-29 16:09:57 +01:00 committed by GitHub
parent 23f1872b3f
commit f781d8c2e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 6 deletions

View file

@ -263,8 +263,9 @@ export function MeterGaugeProvider() {
const percentage = Math.round(100 * (d.y - min) / (max - min));
return `${percentage}%`;
}
if (d.aggConfig) {
return d.aggConfig.fieldFormatter('text')(d.y);
if (_.has(d, 'aggConfigResult.aggConfig')) {
const fieldFormatter = d.aggConfigResult.aggConfig.fieldFormatter('text');
return fieldFormatter(d.y);
}
return d.y;
})

View file

@ -218,8 +218,9 @@ export function SimpleGaugeProvider() {
const percentage = Math.round(100 * (d.y - min) / (max - min));
return `${percentage}%`;
}
if (d.aggConfig) {
return d.aggConfig.fieldFormatter('text')(d.y);
if (_.has(d, 'aggConfigResult.aggConfig')) {
const fieldFormatter = d.aggConfigResult.aggConfig.fieldFormatter('text');
return fieldFormatter(d.y);
}
return d.y;
})

View file

@ -70,8 +70,8 @@ export default function ({ getService, getPageObjects }) {
it('should show correct data, take screenshot', function () {
const expectedChartData = [
'0', '2,088', '2,000', '2,748', '4,000', '2,707', '6,000', '2,876',
'8,000', '2,863', '10,000', '147', '12,000', '148', '14,000', '129', '16,000', '161', '18,000', '137'
'0B', '2,088', '1.953KB', '2,748', '3.906KB', '2,707', '5.859KB', '2,876', '7.813KB',
'2,863', '9.766KB', '147', '11.719KB', '148', '13.672KB', '129', '15.625KB', '161', '17.578KB', '137'
];
return retry.try(function () {

View file

@ -67,6 +67,29 @@ export default function ({ getService, getPageObjects }) {
});
});
it('should show correct values for fields with fieldFormatters', async function () {
const expectedTexts = [ '2,904\nwin 8: Count', '5.528KB' ];
await PageObjects.visualize.clickMetricEditor();
await PageObjects.visualize.clickBucket('Split Group');
await PageObjects.visualize.selectAggregation('Terms');
await PageObjects.visualize.selectField('machine.os.raw');
await PageObjects.visualize.setSize('1');
await PageObjects.visualize.clickAddMetric();
await PageObjects.visualize.clickBucket('Metric');
await PageObjects.visualize.selectAggregation('Average', 'metrics');
await PageObjects.visualize.selectField('bytes', 'metrics');
await PageObjects.visualize.clickGo();
return retry.try(function tryingForTime() {
return PageObjects.visualize.getGaugeValue()
.then(function (metricValue) {
expect(expectedTexts).to.eql(metricValue);
});
});
});
});
});
}

View file

@ -288,6 +288,12 @@ export function VisualizePageProvider({ getService, getPageObjects }) {
await input.type(newValue);
}
async setSize(newValue) {
const input = await find.byCssSelector('input[name="size"]');
await input.clearValue();
await input.type(newValue);
}
async clickGo() {
await testSubjects.click('visualizeEditorRenderButton');
await PageObjects.header.waitUntilLoadingHasFinished();