[TSVB] [AT] time series formatter duration (#38256)
* Add new tests for the duration formatter
This commit is contained in:
parent
b2e0527735
commit
a15b15aae3
|
@ -23,6 +23,7 @@ import { FtrProviderContext } from '../../ftr_provider_context';
|
||||||
export default function({ getPageObjects, getService }: FtrProviderContext) {
|
export default function({ getPageObjects, getService }: FtrProviderContext) {
|
||||||
const { visualize, visualBuilder } = getPageObjects(['visualBuilder', 'visualize']);
|
const { visualize, visualBuilder } = getPageObjects(['visualBuilder', 'visualize']);
|
||||||
const retry = getService('retry');
|
const retry = getService('retry');
|
||||||
|
const log = getService('log');
|
||||||
|
|
||||||
describe('visual builder', function describeIndexTests() {
|
describe('visual builder', function describeIndexTests() {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
@ -105,13 +106,22 @@ export default function({ getPageObjects, getService }: FtrProviderContext) {
|
||||||
expect(actualCount).to.be(expectedLegendValue);
|
expect(actualCount).to.be(expectedLegendValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show the correct count in the legend with duration formatter', async () => {
|
it('should show the correct count in the legend with "Human readable" duration formatter', async () => {
|
||||||
const expectedLegendValue = '156.00';
|
|
||||||
|
|
||||||
await visualBuilder.clickSeriesOption();
|
await visualBuilder.clickSeriesOption();
|
||||||
await visualBuilder.changeDataFormatter('Duration');
|
await visualBuilder.changeDataFormatter('Duration');
|
||||||
const actualCount = await visualBuilder.getRhythmChartLegendValue();
|
await visualBuilder.setDurationFormatterSettings({ to: 'Human readable' });
|
||||||
expect(actualCount).to.be(expectedLegendValue);
|
const actualCountDefault = await visualBuilder.getRhythmChartLegendValue();
|
||||||
|
expect(actualCountDefault).to.be('a few seconds');
|
||||||
|
|
||||||
|
log.debug(`to: 'Human readable', from: 'Seconds'`);
|
||||||
|
await visualBuilder.setDurationFormatterSettings({ to: 'Human readable', from: 'Seconds' });
|
||||||
|
const actualCountSec = await visualBuilder.getRhythmChartLegendValue();
|
||||||
|
expect(actualCountSec).to.be('3 minutes');
|
||||||
|
|
||||||
|
log.debug(`to: 'Human readable', from: 'Minutes'`);
|
||||||
|
await visualBuilder.setDurationFormatterSettings({ to: 'Human readable', from: 'Minutes' });
|
||||||
|
const actualCountMin = await visualBuilder.getRhythmChartLegendValue();
|
||||||
|
expect(actualCountMin).to.be('3 hours');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -28,6 +28,19 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro
|
||||||
const comboBox = getService('comboBox');
|
const comboBox = getService('comboBox');
|
||||||
const PageObjects = getPageObjects(['common', 'header', 'visualize', 'timePicker']);
|
const PageObjects = getPageObjects(['common', 'header', 'visualize', 'timePicker']);
|
||||||
|
|
||||||
|
type Duration =
|
||||||
|
| 'Milliseconds'
|
||||||
|
| 'Seconds'
|
||||||
|
| 'Minutes'
|
||||||
|
| 'Hours'
|
||||||
|
| 'Days'
|
||||||
|
| 'Weeks'
|
||||||
|
| 'Months'
|
||||||
|
| 'Years';
|
||||||
|
|
||||||
|
type FromDuration = Duration | 'Picoseconds' | 'Nanoseconds' | 'Microseconds';
|
||||||
|
type ToDuration = Duration | 'Human readable';
|
||||||
|
|
||||||
class VisualBuilderPage {
|
class VisualBuilderPage {
|
||||||
public async resetPage(
|
public async resetPage(
|
||||||
fromTime = '2015-09-19 06:31:44.000',
|
fromTime = '2015-09-19 06:31:44.000',
|
||||||
|
@ -225,10 +238,40 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro
|
||||||
public async changeDataFormatter(
|
public async changeDataFormatter(
|
||||||
formatter: 'Bytes' | 'Number' | 'Percent' | 'Duration' | 'Custom'
|
formatter: 'Bytes' | 'Number' | 'Percent' | 'Duration' | 'Custom'
|
||||||
) {
|
) {
|
||||||
const [formatterEl] = await find.allByCssSelector('.euiComboBox');
|
const formatterEl = await find.byCssSelector('[id$="row"] .euiComboBox');
|
||||||
await comboBox.setElement(formatterEl, formatter);
|
await comboBox.setElement(formatterEl, formatter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set duration formatter additional settings
|
||||||
|
*
|
||||||
|
* @param from start format
|
||||||
|
* @param to end format
|
||||||
|
* @param decimalPlaces decimals count
|
||||||
|
*/
|
||||||
|
public async setDurationFormatterSettings({
|
||||||
|
from,
|
||||||
|
to,
|
||||||
|
decimalPlaces,
|
||||||
|
}: {
|
||||||
|
from?: FromDuration;
|
||||||
|
to?: ToDuration;
|
||||||
|
decimalPlaces?: string;
|
||||||
|
}) {
|
||||||
|
if (from) {
|
||||||
|
const fromCombobox = await find.byCssSelector('[id$="from-row"] .euiComboBox');
|
||||||
|
await comboBox.setElement(fromCombobox, from);
|
||||||
|
}
|
||||||
|
if (to) {
|
||||||
|
const toCombobox = await find.byCssSelector('[id$="to-row"] .euiComboBox');
|
||||||
|
await comboBox.setElement(toCombobox, to);
|
||||||
|
}
|
||||||
|
if (decimalPlaces) {
|
||||||
|
const decimalPlacesInput = await find.byCssSelector('[id$="decimal"]');
|
||||||
|
await decimalPlacesInput.type(decimalPlaces);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* write template for aggregation row in the `option` tab
|
* write template for aggregation row in the `option` tab
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue