Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TSVB] Add more functional tests for Table #105060

Merged
56 changes: 56 additions & 0 deletions test/functional/apps/visualize/_tsvb_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.setFilterRatioNumerator('extension.raw : "css"');
await visualBuilder.setFilterRatioDenominator('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);
});
});
});
}
14 changes: 14 additions & 0 deletions test/functional/page_objects/visual_builder_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -727,4 +727,18 @@ export class VisualBuilderPageObject extends FtrService {
await this.comboBox.set('topHitOrderByFieldSelect', timeField);
});
}

public async setFilterRatioNumerator(numerator: string) {
const numeratorInput = await this.find.byCssSelector(
'.tvbAggRow [data-test-subj="queryInput"]'
);
await numeratorInput.type(numerator);
}

public async setFilterRatioDenominator(denominator: string) {
const [, denominatorInput] = await this.find.allByCssSelector(
'.tvbAggRow [data-test-subj="queryInput"]'
);
await denominatorInput.type(denominator);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we create private function with common logic and in these methods just return needed input?

}
}