diff --git a/src/plugins/vis_type_timeseries/public/application/components/aggs/filter_ratio.js b/src/plugins/vis_type_timeseries/public/application/components/aggs/filter_ratio.js index c380b0e09e7d3..90a5633926c88 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/aggs/filter_ratio.js +++ b/src/plugins/vis_type_timeseries/public/application/components/aggs/filter_ratio.js @@ -106,6 +106,7 @@ export const FilterRatioAgg = (props) => { query={model.numerator} onChange={handleNumeratorQueryChange} indexPatterns={[indexPattern]} + data-test-subj="filterRatioNumeratorInput" /> @@ -124,6 +125,7 @@ export const FilterRatioAgg = (props) => { query={model.denominator} onChange={handleDenominatorQueryChange} indexPatterns={[indexPattern]} + data-test-subj="filterRatioDenominatorInput" /> diff --git a/src/plugins/vis_type_timeseries/public/application/components/query_bar_wrapper.tsx b/src/plugins/vis_type_timeseries/public/application/components/query_bar_wrapper.tsx index a3817503d24f1..215640c30f3c4 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/query_bar_wrapper.tsx +++ b/src/plugins/vis_type_timeseries/public/application/components/query_bar_wrapper.tsx @@ -18,9 +18,15 @@ import { fetchIndexPattern, isStringTypeIndexPattern } from '../../../common/ind type QueryBarWrapperProps = Pick & { indexPatterns: IndexPatternValue[]; + 'data-test-subj'?: string; }; -export function QueryBarWrapper({ query, onChange, indexPatterns }: QueryBarWrapperProps) { +export function QueryBarWrapper({ + query, + onChange, + indexPatterns, + 'data-test-subj': dataTestSubj, +}: QueryBarWrapperProps) { const { indexPatterns: indexPatternsService } = getDataStart(); const [indexes, setIndexes] = useState([]); @@ -58,6 +64,7 @@ export function QueryBarWrapper({ query, onChange, indexPatterns }: QueryBarWrap onChange={onChange} indexPatterns={indexes} {...coreStartContext} + dataTestSubj={dataTestSubj} /> ); } diff --git a/test/functional/apps/visualize/_tsvb_table.ts b/test/functional/apps/visualize/_tsvb_table.ts index de0771d3c8ec5..a29d8825068af 100644 --- a/test/functional/apps/visualize/_tsvb_table.ts +++ b/test/functional/apps/visualize/_tsvb_table.ts @@ -78,6 +78,62 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const tableData = await visualBuilder.getViewTable(); expect(tableData).to.be(EXPECTED); }); + + it('should display correct values for variance aggregation', async () => { + const EXPECTED = + 'OS Variance of bytes\nwin 8 2,707,941.822\nwin xp 2,595,612.24\nwin 7 16,055,541.306\nios 6,505,206.56\nosx 1,016,620.667'; + await visualBuilder.selectAggType('Variance'); + await visualBuilder.setFieldForAggregation('bytes'); + + const tableData = await visualBuilder.getViewTable(); + expect(tableData).to.be(EXPECTED); + }); + + it('should display correct values for filter ratio aggregation with numerator and denominator', async () => { + const EXPECTED = 'OS Filter Ratio\nwin 8 2\nwin xp 0\nwin 7 3\nios 0\nosx 0'; + await visualBuilder.selectAggType('Filter Ratio'); + await visualBuilder.setFilterRatioOption('Numerator', 'extension.raw : "css"'); + await visualBuilder.setFilterRatioOption('Denominator', 'bytes <= 3000'); + await visChart.waitForVisualizationRenderingStabilized(); + + const tableData = await visualBuilder.getViewTable(); + expect(tableData).to.be(EXPECTED); + }); + + it('should display correct values for average aggregation with last value time range mode', async () => { + const EXPECTED = + 'OS Average of machine.ram\nwin 8 13,958,643,712\nwin xp 14,602,888,806.4\nwin 7 14,048,122,197.333\nios 11,166,914,969.6\nosx 20,401,094,656'; + await visualBuilder.selectAggType('Average'); + await visualBuilder.setFieldForAggregation('machine.ram'); + + const tableData = await visualBuilder.getViewTable(); + expect(tableData).to.be(EXPECTED); + }); + + it('should display correct values for sum aggregation with entire time range mode', async () => { + const EXPECTED = + 'OS Sum of memory\nwin 8 1,121,160\nwin xp 1,182,800\nwin 7 1,443,600\nios 971,360\nosx 858,480'; + await visualBuilder.selectAggType('Sum'); + await visualBuilder.setFieldForAggregation('memory'); + await visualBuilder.clickPanelOptions('table'); + await visualBuilder.setMetricsDataTimerangeMode('Entire time range'); + + const tableData = await visualBuilder.getViewTable(); + expect(tableData).to.be(EXPECTED); + }); + + it('should display correct values for math aggregation', async () => { + const EXPECTED = 'OS Math\nwin 8 2,937\nwin xp 460\nwin 7 2,997\nios 1,095\nosx 1,724'; + await visualBuilder.selectAggType('Min'); + await visualBuilder.setFieldForAggregation('bytes'); + await visualBuilder.createNewAgg(); + await visualBuilder.selectAggType('math', 1); + await visualBuilder.fillInVariable('test', 'Min'); + await visualBuilder.fillInExpression('params.test + 1'); + + const tableData = await visualBuilder.getViewTable(); + expect(tableData).to.be(EXPECTED); + }); }); }); } diff --git a/test/functional/page_objects/visual_builder_page.ts b/test/functional/page_objects/visual_builder_page.ts index fd89a88658b3a..7018fd68971c5 100644 --- a/test/functional/page_objects/visual_builder_page.ts +++ b/test/functional/page_objects/visual_builder_page.ts @@ -727,4 +727,9 @@ export class VisualBuilderPageObject extends FtrService { await this.comboBox.set('topHitOrderByFieldSelect', timeField); }); } + + public async setFilterRatioOption(optionType: 'Numerator' | 'Denominator', query: string) { + const optionInput = await this.testSubjects.find(`filterRatio${optionType}Input`); + await optionInput.type(query); + } }