From b993ffa0f78531492353f5bd7c23aa5ca2e4796d Mon Sep 17 00:00:00 2001 From: Diana Derevyankina Date: Fri, 9 Jul 2021 16:21:45 +0300 Subject: [PATCH] [TSVB] Add more functional tests for Table --- test/functional/apps/visualize/_tsvb_table.ts | 58 +++++++++++++++++++ .../page_objects/visual_builder_page.ts | 11 ++++ 2 files changed, 69 insertions(+) diff --git a/test/functional/apps/visualize/_tsvb_table.ts b/test/functional/apps/visualize/_tsvb_table.ts index abe3b799e4711..9a6d69c5b9204 100644 --- a/test/functional/apps/visualize/_tsvb_table.ts +++ b/test/functional/apps/visualize/_tsvb_table.ts @@ -63,6 +63,64 @@ export default function ({ getPageObjects }: 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.setFilterRatioNumeratorDenominator( + 'extension.raw : "css"', + '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 ea11560e37b6f..c3371459c68c3 100644 --- a/test/functional/page_objects/visual_builder_page.ts +++ b/test/functional/page_objects/visual_builder_page.ts @@ -654,4 +654,15 @@ export class VisualBuilderPageObject extends FtrService { const dataTimeRangeMode = await this.testSubjects.find('dataTimeRangeMode'); return await this.comboBox.isOptionSelected(dataTimeRangeMode, value); } + + public async setFilterRatioNumeratorDenominator( + numerator: string = '', + denominator: string = '' + ) { + const [numeratorInput, denominatorInput] = await this.find.allByCssSelector( + '.tvbAggRow [data-test-subj="queryInput"]' + ); + await numeratorInput.type(numerator); + await denominatorInput.type(denominator); + } }