Fix visualize tests (#34390)

* wait for rendering

* run ciGroup12 x60 times

* [visualize/_tsvb_chart] redesign tests

* wait for viz initial loading before navigation

* [visualize/_tsvb_chart] assert tab is loaded

* Revert "wait for viz initial loading before navigation"

This reverts commit 1023db4fb9.

* [TSVB] [Performance]request for api/metrics/fields triggered after all UI changes

Fix: #34433

* [TSVB] [Performance]request for api/metrics/fields triggered after all UI changes - prevent reRender in case of no changes

Fix: #34433

* improve tests

* Revert "[TSVB] [Performance]request for api/metrics/fields triggered after all UI changes - prevent reRender in case of no changes"

This reverts commit a04ed55103.

* Revert "[TSVB] [Performance]request for api/metrics/fields triggered after all UI changes"

This reverts commit 040f0b106b.

* Revert "run ciGroup12 x60 times"

This reverts commit c38427f67f.

* rename dataTestSubj
This commit is contained in:
Dmitry Lemeshko 2019-04-10 21:07:38 +02:00 committed by GitHub
parent 34cd8a3c67
commit aa08669ca3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 72 additions and 102 deletions

View file

@ -132,7 +132,7 @@ class VisEditor extends Component {
if (model) { if (model) {
return ( return (
<div className="tvbEditor"> <div className="tvbEditor" data-test-subj="tvbVisEditor">
<div className="tvbEditor--hideForReporting"> <div className="tvbEditor--hideForReporting">
<VisPicker model={model} onChange={this.handleChange}/> <VisPicker model={model} onChange={this.handleChange}/>
</div> </div>

View file

@ -172,6 +172,7 @@ class Gauge extends Component {
<div <div
ref={(el) => this.resize = el} ref={(el) => this.resize = el}
className={`tvbVisGauge__resize`} className={`tvbVisGauge__resize`}
data-test-subj="tvbVisGaugeContainer"
> >
{ metrics } { metrics }
<GaugeVis {...gaugeProps}/> <GaugeVis {...gaugeProps}/>

View file

@ -119,7 +119,7 @@ class TopN extends Component {
return ( return (
<div className={className}> <div className={className}>
<table className="tvbVisTopN__table" ref={this.tableRef}> <table className="tvbVisTopN__table" data-test-subj="tvbVisTopNTable" ref={this.tableRef}>
<tbody> <tbody>
{ rows } { rows }
</tbody> </tbody>

View file

@ -25,82 +25,47 @@ export default function({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver'); const esArchiver = getService('esArchiver');
const log = getService('log'); const log = getService('log');
const inspector = getService('inspector'); const inspector = getService('inspector');
const retry = getService('retry');
const kibanaServer = getService('kibanaServer'); const kibanaServer = getService('kibanaServer');
const testSubjects = getService('testSubjects'); const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects([ const PageObjects = getPageObjects(['visualize', 'visualBuilder', 'timePicker']);
'common',
'visualize', describe('visual builder', function describeIndexTests() {
'header', beforeEach(async () => {
'settings', await PageObjects.visualize.navigateToNewVisualization();
'visualBuilder', await PageObjects.visualize.clickVisualBuilder();
'timePicker', await PageObjects.visualBuilder.checkVisualBuilderIsPresent();
]); });
// FAILING: https://github.com/elastic/kibana/issues/34299
// FAILING: https://github.com/elastic/kibana/issues/34292
describe.skip('visual builder', function describeIndexTests() {
describe('Time Series', () => { describe('Time Series', () => {
before(async () => { beforeEach(async () => {
await PageObjects.visualBuilder.resetPage(); await PageObjects.visualBuilder.resetPage();
}); });
it('should show the correct count in the legend', async () => { it('should show the correct count in the legend', async () => {
await retry.try(async () => { const actualCount = await PageObjects.visualBuilder.getRhythmChartLegendValue();
await PageObjects.header.waitUntilLoadingHasFinished(); expect(actualCount).to.be('156');
const actualCount = await PageObjects.visualBuilder.getRhythmChartLegendValue();
expect(actualCount).to.be('156');
});
}); });
it('should show the correct count in the legend with 2h offset', async () => { it('should show the correct count in the legend with 2h offset', async () => {
await PageObjects.visualBuilder.clickSeriesOption(); await PageObjects.visualBuilder.clickSeriesOption();
await PageObjects.visualBuilder.enterOffsetSeries('2h'); await PageObjects.visualBuilder.enterOffsetSeries('2h');
await PageObjects.header.waitUntilLoadingHasFinished();
const actualCount = await PageObjects.visualBuilder.getRhythmChartLegendValue(); const actualCount = await PageObjects.visualBuilder.getRhythmChartLegendValue();
expect(actualCount).to.be('293'); expect(actualCount).to.be('293');
}); });
it('should show the correct count in the legend with -2h offset', async () => { it('should show the correct count in the legend with -2h offset', async () => {
await PageObjects.visualBuilder.clickSeriesOption();
await PageObjects.visualBuilder.enterOffsetSeries('-2h'); await PageObjects.visualBuilder.enterOffsetSeries('-2h');
await PageObjects.header.waitUntilLoadingHasFinished();
const actualCount = await PageObjects.visualBuilder.getRhythmChartLegendValue(); const actualCount = await PageObjects.visualBuilder.getRhythmChartLegendValue();
expect(actualCount).to.be('53'); expect(actualCount).to.be('53');
}); });
after(async () => {
// set back to no offset for the next test, an empty string didn't seem to work here
await PageObjects.visualBuilder.enterOffsetSeries('0h');
});
});
describe('Math Aggregation', () => {
before(async () => {
await PageObjects.visualBuilder.resetPage();
await PageObjects.visualBuilder.clickMetric();
await PageObjects.visualBuilder.createNewAgg();
await PageObjects.visualBuilder.selectAggType('math', 1);
await PageObjects.visualBuilder.fillInVariable();
await PageObjects.visualBuilder.fillInExpression('params.test + 1');
});
it('should not have inspector enabled', async () => {
await inspector.expectIsNotEnabled();
});
it('should show correct data', async () => {
const expectedMetricValue = '157';
const value = await PageObjects.visualBuilder.getMetricValue();
log.debug(`metric value: ${JSON.stringify(value)}`);
log.debug(`metric value: ${value}`);
expect(value).to.eql(expectedMetricValue);
});
}); });
describe('metric', () => { describe('metric', () => {
before(async () => { beforeEach(async () => {
await PageObjects.visualBuilder.resetPage(); await PageObjects.visualBuilder.resetPage();
await PageObjects.visualBuilder.clickMetric(); await PageObjects.visualBuilder.clickMetric();
await PageObjects.visualBuilder.checkMetricTabIsPresent();
}); });
it('should not have inspector enabled', async () => { it('should not have inspector enabled', async () => {
@ -108,74 +73,66 @@ export default function({ getService, getPageObjects }: FtrProviderContext) {
}); });
it('should show correct data', async () => { it('should show correct data', async () => {
const expectedMetricValue = '156';
await PageObjects.visualize.waitForVisualization();
const value = await PageObjects.visualBuilder.getMetricValue(); const value = await PageObjects.visualBuilder.getMetricValue();
log.debug(`metric value: ${value}`); expect(value).to.eql('156');
expect(value).to.eql(expectedMetricValue); });
it('should show correct data with Math Aggregation', async () => {
await PageObjects.visualBuilder.createNewAgg();
await PageObjects.visualBuilder.selectAggType('math', 1);
await PageObjects.visualBuilder.fillInVariable();
await PageObjects.visualBuilder.fillInExpression('params.test + 1');
const value = await PageObjects.visualBuilder.getMetricValue();
expect(value).to.eql('157');
}); });
}); });
// add a gauge test
describe('gauge', () => { describe('gauge', () => {
before(async () => { beforeEach(async () => {
await PageObjects.visualBuilder.resetPage(); await PageObjects.visualBuilder.resetPage();
await PageObjects.visualBuilder.clickGauge(); await PageObjects.visualBuilder.clickGauge();
log.debug('clicked on Gauge'); await PageObjects.visualBuilder.checkGaugeTabIsPresent();
}); });
it('should verify gauge label and count display', async () => { it('should verify gauge label and count display', async () => {
await retry.try(async () => { await PageObjects.visualize.waitForVisualizationRenderingStabilized();
await PageObjects.visualize.waitForVisualization(); const labelString = await PageObjects.visualBuilder.getGaugeLabel();
const labelString = await PageObjects.visualBuilder.getGaugeLabel(); expect(labelString).to.be('Count');
expect(labelString).to.be('Count'); const gaugeCount = await PageObjects.visualBuilder.getGaugeCount();
const gaugeCount = await PageObjects.visualBuilder.getGaugeCount(); expect(gaugeCount).to.be('156');
expect(gaugeCount).to.be('156');
});
}); });
}); });
// add a top N test
describe('topN', () => { describe('topN', () => {
before(async () => { beforeEach(async () => {
await PageObjects.visualBuilder.resetPage(); await PageObjects.visualBuilder.resetPage();
await PageObjects.visualBuilder.clickTopN(); await PageObjects.visualBuilder.clickTopN();
log.debug('clicked on TopN'); await PageObjects.visualBuilder.checkTopNTabIsPresent();
}); });
it('should verify topN label and count display', async () => { it('should verify topN label and count display', async () => {
await retry.try(async () => { await PageObjects.visualize.waitForVisualizationRenderingStabilized();
await PageObjects.visualize.waitForVisualization(); const labelString = await PageObjects.visualBuilder.getTopNLabel();
const labelString = await PageObjects.visualBuilder.getTopNLabel(); expect(labelString).to.be('Count');
expect(labelString).to.be('Count'); const gaugeCount = await PageObjects.visualBuilder.getTopNCount();
const gaugeCount = await PageObjects.visualBuilder.getTopNCount(); expect(gaugeCount).to.be('156');
expect(gaugeCount).to.be('156');
});
}); });
}); });
// add a table sanity timestamp
describe('table', () => { describe('table', () => {
before(async () => { beforeEach(async () => {
await PageObjects.visualBuilder.resetPage(); await PageObjects.visualBuilder.resetPage(
await PageObjects.visualBuilder.clickTable();
await PageObjects.timePicker.setAbsoluteRange(
'2015-09-22 06:00:00.000', '2015-09-22 06:00:00.000',
'2015-09-22 11:00:00.000' '2015-09-22 11:00:00.000'
); );
log.debug('clicked on Table'); await PageObjects.visualBuilder.clickTable();
}); });
it('should be able to set values for group by field and column name', async () => { it('should display correct values on changing group by field and column name', async () => {
await PageObjects.visualBuilder.selectGroupByField('machine.os.raw'); await PageObjects.visualBuilder.selectGroupByField('machine.os.raw');
await PageObjects.visualBuilder.setLabelValue('OS'); await PageObjects.visualBuilder.setLabelValue('OS');
await PageObjects.header.waitUntilLoadingHasFinished(); await PageObjects.visualize.waitForVisualizationRenderingStabilized();
log.debug('finished setting field and column name');
});
it('should be able verify that values are displayed in the table', async () => {
const tableData = await PageObjects.visualBuilder.getViewTable(); const tableData = await PageObjects.visualBuilder.getViewTable();
log.debug(`Values on ${tableData}`);
const expectedData = 'OS Count\nwin 8 13\nwin xp 10\nwin 7 12\nios 5\nosx 3'; const expectedData = 'OS Count\nwin 8 13\nwin xp 10\nwin 7 12\nios 5\nosx 3';
expect(tableData).to.be(expectedData); expect(tableData).to.be(expectedData);
}); });

View file

@ -33,27 +33,46 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro
fromTime = '2015-09-19 06:31:44.000', fromTime = '2015-09-19 06:31:44.000',
toTime = '2015-09-22 18:31:44.000' toTime = '2015-09-22 18:31:44.000'
) { ) {
log.debug('navigateToApp visualize'); await PageObjects.common.navigateToUrl('visualize', 'create?type=metrics');
await PageObjects.visualize.navigateToNewVisualization();
log.debug('clickVisualBuilderChart');
await PageObjects.visualize.clickVisualBuilder();
log.debug('Set absolute time range from "' + fromTime + '" to "' + toTime + '"'); log.debug('Set absolute time range from "' + fromTime + '" to "' + toTime + '"');
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);
} }
public async checkTabIsLoaded(testSubj: string, name: string) {
const isPresent = await testSubjects.exists(testSubj, { timeout: 5000 });
if (!isPresent) {
throw new Error(`TSVB ${name} tab is not loaded`);
}
}
public async checkVisualBuilderIsPresent() {
await this.checkTabIsLoaded('tvbVisEditor', 'Time Series');
}
public async checkMetricTabIsPresent() {
await this.checkTabIsLoaded('tsvbMetricValue', 'Metric');
}
public async checkGaugeTabIsPresent() {
await this.checkTabIsLoaded('tvbVisGaugeContainer', 'Gauge');
}
public async checkTopNTabIsPresent() {
await this.checkTabIsLoaded('tvbVisTopNTable', 'TopN');
}
public async clickMetric() { public async clickMetric() {
const button = await testSubjects.find('metricTsvbTypeBtn'); const button = await testSubjects.find('metricTsvbTypeBtn');
await button.click(); await button.click();
await PageObjects.header.waitUntilLoadingHasFinished();
} }
public async clickMarkdown() { public async clickMarkdown() {
const button = await testSubjects.find('markdownTsvbTypeBtn'); const button = await testSubjects.find('markdownTsvbTypeBtn');
await button.click(); await button.click();
await PageObjects.header.waitUntilLoadingHasFinished();
} }
public async getMetricValue() { public async getMetricValue() {
await PageObjects.visualize.waitForVisualizationRenderingStabilized();
const metricValue = await find.byCssSelector('.tvbVisMetric__value--primary'); const metricValue = await find.byCssSelector('.tvbVisMetric__value--primary');
return metricValue.getVisibleText(); return metricValue.getVisibleText();
} }
@ -61,10 +80,8 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro
public async enterMarkdown(markdown: string) { public async enterMarkdown(markdown: string) {
const input = await find.byCssSelector('.tvbMarkdownEditor__editor textarea'); const input = await find.byCssSelector('.tvbMarkdownEditor__editor textarea');
await this.clearMarkdown(); await this.clearMarkdown();
const prevRenderingCount = await PageObjects.visualize.getVisualizationRenderingCount();
await input.type(markdown); await input.type(markdown);
await PageObjects.visualize.waitForVisualizationRenderingStabilized(); await PageObjects.visualize.waitForVisualizationRenderingStabilized();
await PageObjects.visualize.waitForRenderingCount(prevRenderingCount + 1);
} }
public async clearMarkdown() { public async clearMarkdown() {
@ -159,23 +176,21 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro
public async clickSeriesOption(nth = 0) { public async clickSeriesOption(nth = 0) {
const el = await testSubjects.findAll('seriesOptions'); const el = await testSubjects.findAll('seriesOptions');
await el[nth].click(); await el[nth].click();
await PageObjects.common.sleep(500);
} }
public async clearOffsetSeries() { public async clearOffsetSeries() {
const el = await testSubjects.find('offsetTimeSeries'); const el = await testSubjects.find('offsetTimeSeries');
await el.clearValue(); await el.clearValue();
await PageObjects.header.waitUntilLoadingHasFinished();
} }
public async enterOffsetSeries(value: string) { public async enterOffsetSeries(value: string) {
const el = await testSubjects.find('offsetTimeSeries'); const el = await testSubjects.find('offsetTimeSeries');
await el.clearValue(); await el.clearValue();
await el.type(value); await el.type(value);
await PageObjects.header.waitUntilLoadingHasFinished();
} }
public async getRhythmChartLegendValue() { public async getRhythmChartLegendValue() {
await PageObjects.visualize.waitForVisualizationRenderingStabilized();
const metricValue = await find.byCssSelector('.tvbLegend__itemValue'); const metricValue = await find.byCssSelector('.tvbLegend__itemValue');
await metricValue.moveMouseTo(); await metricValue.moveMouseTo();
return await metricValue.getVisibleText(); return await metricValue.getVisibleText();
@ -183,7 +198,6 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro
public async clickGauge() { public async clickGauge() {
await testSubjects.click('gaugeTsvbTypeBtn'); await testSubjects.click('gaugeTsvbTypeBtn');
await PageObjects.header.waitUntilLoadingHasFinished();
} }
public async getGaugeLabel() { public async getGaugeLabel() {
@ -198,7 +212,6 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro
public async clickTopN() { public async clickTopN() {
await testSubjects.click('top_nTsvbTypeBtn'); await testSubjects.click('top_nTsvbTypeBtn');
await PageObjects.header.waitUntilLoadingHasFinished();
} }
public async getTopNLabel() { public async getTopNLabel() {
@ -213,7 +226,6 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro
public async clickTable() { public async clickTable() {
await testSubjects.click('tableTsvbTypeBtn'); await testSubjects.click('tableTsvbTypeBtn');
await PageObjects.header.waitUntilLoadingHasFinished();
} }
public async createNewAgg(nth = 0) { public async createNewAgg(nth = 0) {