Skip to content

Commit

Permalink
[TSVB] Add more functional tests for Table
Browse files Browse the repository at this point in the history
  • Loading branch information
DianaDerevyankina committed Jul 9, 2021
1 parent 0100528 commit b993ffa
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
58 changes: 58 additions & 0 deletions test/functional/apps/visualize/_tsvb_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
}
11 changes: 11 additions & 0 deletions test/functional/page_objects/visual_builder_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit b993ffa

Please sign in to comment.