From aa08669ca3bf21a8b8d5f15927cbfcb7acc23918 Mon Sep 17 00:00:00 2001 From: Dmitry Lemeshko Date: Wed, 10 Apr 2019 21:07:38 +0200 Subject: [PATCH] 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 1023db4fb9d893f91fc56e1681a0a7b0310eab47. * [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 a04ed5510381b80230ca146ded622c435b8b0a52. * Revert "[TSVB] [Performance]request for api/metrics/fields triggered after all UI changes" This reverts commit 040f0b106b64fec61d23f78d01bb3efaea09eefa. * Revert "run ciGroup12 x60 times" This reverts commit c38427f67f17fa37fd49fd28e8af08e6963e13a4. * rename dataTestSubj --- .../metrics/public/components/vis_editor.js | 2 +- .../public/visualizations/components/gauge.js | 1 + .../public/visualizations/components/top_n.js | 2 +- test/functional/apps/visualize/_tsvb_chart.ts | 129 ++++++------------ .../page_objects/visual_builder_page.ts | 40 ++++-- 5 files changed, 72 insertions(+), 102 deletions(-) diff --git a/src/legacy/core_plugins/metrics/public/components/vis_editor.js b/src/legacy/core_plugins/metrics/public/components/vis_editor.js index e8f4857cac87..16ac703f4a4f 100644 --- a/src/legacy/core_plugins/metrics/public/components/vis_editor.js +++ b/src/legacy/core_plugins/metrics/public/components/vis_editor.js @@ -132,7 +132,7 @@ class VisEditor extends Component { if (model) { return ( -
+
diff --git a/src/legacy/core_plugins/metrics/public/visualizations/components/gauge.js b/src/legacy/core_plugins/metrics/public/visualizations/components/gauge.js index 93041931d284..abac92a218e6 100644 --- a/src/legacy/core_plugins/metrics/public/visualizations/components/gauge.js +++ b/src/legacy/core_plugins/metrics/public/visualizations/components/gauge.js @@ -172,6 +172,7 @@ class Gauge extends Component {
this.resize = el} className={`tvbVisGauge__resize`} + data-test-subj="tvbVisGaugeContainer" > { metrics } diff --git a/src/legacy/core_plugins/metrics/public/visualizations/components/top_n.js b/src/legacy/core_plugins/metrics/public/visualizations/components/top_n.js index 379c4e9dd7ee..8761dba34cca 100644 --- a/src/legacy/core_plugins/metrics/public/visualizations/components/top_n.js +++ b/src/legacy/core_plugins/metrics/public/visualizations/components/top_n.js @@ -119,7 +119,7 @@ class TopN extends Component { return (
- +
{ rows } diff --git a/test/functional/apps/visualize/_tsvb_chart.ts b/test/functional/apps/visualize/_tsvb_chart.ts index c89c5f7d0459..8a1f82323970 100644 --- a/test/functional/apps/visualize/_tsvb_chart.ts +++ b/test/functional/apps/visualize/_tsvb_chart.ts @@ -25,82 +25,47 @@ export default function({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const log = getService('log'); const inspector = getService('inspector'); - const retry = getService('retry'); const kibanaServer = getService('kibanaServer'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects([ - 'common', - 'visualize', - 'header', - 'settings', - 'visualBuilder', - 'timePicker', - ]); + const PageObjects = getPageObjects(['visualize', 'visualBuilder', 'timePicker']); + + describe('visual builder', function describeIndexTests() { + beforeEach(async () => { + await PageObjects.visualize.navigateToNewVisualization(); + await PageObjects.visualize.clickVisualBuilder(); + 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', () => { - before(async () => { + beforeEach(async () => { await PageObjects.visualBuilder.resetPage(); }); it('should show the correct count in the legend', async () => { - await retry.try(async () => { - await PageObjects.header.waitUntilLoadingHasFinished(); - const actualCount = await PageObjects.visualBuilder.getRhythmChartLegendValue(); - 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 () => { await PageObjects.visualBuilder.clickSeriesOption(); await PageObjects.visualBuilder.enterOffsetSeries('2h'); - await PageObjects.header.waitUntilLoadingHasFinished(); const actualCount = await PageObjects.visualBuilder.getRhythmChartLegendValue(); expect(actualCount).to.be('293'); }); it('should show the correct count in the legend with -2h offset', async () => { + await PageObjects.visualBuilder.clickSeriesOption(); await PageObjects.visualBuilder.enterOffsetSeries('-2h'); - await PageObjects.header.waitUntilLoadingHasFinished(); const actualCount = await PageObjects.visualBuilder.getRhythmChartLegendValue(); 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', () => { - before(async () => { + beforeEach(async () => { await PageObjects.visualBuilder.resetPage(); await PageObjects.visualBuilder.clickMetric(); + await PageObjects.visualBuilder.checkMetricTabIsPresent(); }); it('should not have inspector enabled', async () => { @@ -108,74 +73,66 @@ export default function({ getService, getPageObjects }: FtrProviderContext) { }); it('should show correct data', async () => { - const expectedMetricValue = '156'; - await PageObjects.visualize.waitForVisualization(); const value = await PageObjects.visualBuilder.getMetricValue(); - log.debug(`metric value: ${value}`); - expect(value).to.eql(expectedMetricValue); + expect(value).to.eql('156'); + }); + + 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', () => { - before(async () => { + beforeEach(async () => { await PageObjects.visualBuilder.resetPage(); await PageObjects.visualBuilder.clickGauge(); - log.debug('clicked on Gauge'); + await PageObjects.visualBuilder.checkGaugeTabIsPresent(); }); it('should verify gauge label and count display', async () => { - await retry.try(async () => { - await PageObjects.visualize.waitForVisualization(); - const labelString = await PageObjects.visualBuilder.getGaugeLabel(); - expect(labelString).to.be('Count'); - const gaugeCount = await PageObjects.visualBuilder.getGaugeCount(); - expect(gaugeCount).to.be('156'); - }); + await PageObjects.visualize.waitForVisualizationRenderingStabilized(); + const labelString = await PageObjects.visualBuilder.getGaugeLabel(); + expect(labelString).to.be('Count'); + const gaugeCount = await PageObjects.visualBuilder.getGaugeCount(); + expect(gaugeCount).to.be('156'); }); }); - // add a top N test describe('topN', () => { - before(async () => { + beforeEach(async () => { await PageObjects.visualBuilder.resetPage(); await PageObjects.visualBuilder.clickTopN(); - log.debug('clicked on TopN'); + await PageObjects.visualBuilder.checkTopNTabIsPresent(); }); it('should verify topN label and count display', async () => { - await retry.try(async () => { - await PageObjects.visualize.waitForVisualization(); - const labelString = await PageObjects.visualBuilder.getTopNLabel(); - expect(labelString).to.be('Count'); - const gaugeCount = await PageObjects.visualBuilder.getTopNCount(); - expect(gaugeCount).to.be('156'); - }); + await PageObjects.visualize.waitForVisualizationRenderingStabilized(); + const labelString = await PageObjects.visualBuilder.getTopNLabel(); + expect(labelString).to.be('Count'); + const gaugeCount = await PageObjects.visualBuilder.getTopNCount(); + expect(gaugeCount).to.be('156'); }); }); - // add a table sanity timestamp describe('table', () => { - before(async () => { - await PageObjects.visualBuilder.resetPage(); - await PageObjects.visualBuilder.clickTable(); - await PageObjects.timePicker.setAbsoluteRange( + beforeEach(async () => { + await PageObjects.visualBuilder.resetPage( '2015-09-22 06: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.setLabelValue('OS'); - await PageObjects.header.waitUntilLoadingHasFinished(); - log.debug('finished setting field and column name'); - }); - - it('should be able verify that values are displayed in the table', async () => { + await PageObjects.visualize.waitForVisualizationRenderingStabilized(); 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'; expect(tableData).to.be(expectedData); }); diff --git a/test/functional/page_objects/visual_builder_page.ts b/test/functional/page_objects/visual_builder_page.ts index bd2f219486bf..338469fc9935 100644 --- a/test/functional/page_objects/visual_builder_page.ts +++ b/test/functional/page_objects/visual_builder_page.ts @@ -33,27 +33,46 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro fromTime = '2015-09-19 06:31:44.000', toTime = '2015-09-22 18:31:44.000' ) { - log.debug('navigateToApp visualize'); - await PageObjects.visualize.navigateToNewVisualization(); - log.debug('clickVisualBuilderChart'); - await PageObjects.visualize.clickVisualBuilder(); + await PageObjects.common.navigateToUrl('visualize', 'create?type=metrics'); log.debug('Set absolute time range from "' + fromTime + '" to "' + 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() { const button = await testSubjects.find('metricTsvbTypeBtn'); await button.click(); - await PageObjects.header.waitUntilLoadingHasFinished(); } public async clickMarkdown() { const button = await testSubjects.find('markdownTsvbTypeBtn'); await button.click(); - await PageObjects.header.waitUntilLoadingHasFinished(); } public async getMetricValue() { + await PageObjects.visualize.waitForVisualizationRenderingStabilized(); const metricValue = await find.byCssSelector('.tvbVisMetric__value--primary'); return metricValue.getVisibleText(); } @@ -61,10 +80,8 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro public async enterMarkdown(markdown: string) { const input = await find.byCssSelector('.tvbMarkdownEditor__editor textarea'); await this.clearMarkdown(); - const prevRenderingCount = await PageObjects.visualize.getVisualizationRenderingCount(); await input.type(markdown); await PageObjects.visualize.waitForVisualizationRenderingStabilized(); - await PageObjects.visualize.waitForRenderingCount(prevRenderingCount + 1); } public async clearMarkdown() { @@ -159,23 +176,21 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro public async clickSeriesOption(nth = 0) { const el = await testSubjects.findAll('seriesOptions'); await el[nth].click(); - await PageObjects.common.sleep(500); } public async clearOffsetSeries() { const el = await testSubjects.find('offsetTimeSeries'); await el.clearValue(); - await PageObjects.header.waitUntilLoadingHasFinished(); } public async enterOffsetSeries(value: string) { const el = await testSubjects.find('offsetTimeSeries'); await el.clearValue(); await el.type(value); - await PageObjects.header.waitUntilLoadingHasFinished(); } public async getRhythmChartLegendValue() { + await PageObjects.visualize.waitForVisualizationRenderingStabilized(); const metricValue = await find.byCssSelector('.tvbLegend__itemValue'); await metricValue.moveMouseTo(); return await metricValue.getVisibleText(); @@ -183,7 +198,6 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro public async clickGauge() { await testSubjects.click('gaugeTsvbTypeBtn'); - await PageObjects.header.waitUntilLoadingHasFinished(); } public async getGaugeLabel() { @@ -198,7 +212,6 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro public async clickTopN() { await testSubjects.click('top_nTsvbTypeBtn'); - await PageObjects.header.waitUntilLoadingHasFinished(); } public async getTopNLabel() { @@ -213,7 +226,6 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro public async clickTable() { await testSubjects.click('tableTsvbTypeBtn'); - await PageObjects.header.waitUntilLoadingHasFinished(); } public async createNewAgg(nth = 0) {