From 2a033c1621414e838c2fc7de1710c0fc3ee340e1 Mon Sep 17 00:00:00 2001 From: Marta Bondyra <4283304+mbondyra@users.noreply.github.com> Date: Tue, 27 Aug 2024 22:12:59 +0200 Subject: [PATCH] [Managed Content] fix flaky tests (#191388) ## Summary Fixes https://github.com/elastic/kibana/issues/190227 Fixes https://github.com/elastic/kibana/issues/190737 https://github.com/elastic/kibana/issues/190990 https://github.com/elastic/kibana/issues/190802 https://github.com/elastic/kibana/issues/179307 (couldn't find the rootcause so just decided to align the solution with other files that follow similar path and are not flaky) Fixes https://github.com/elastic/kibana/issues/191151 https://github.com/elastic/kibana/issues/191152 https://github.com/elastic/kibana/issues/191176 https://github.com/elastic/kibana/issues/191177 https://github.com/elastic/kibana/issues/191178 https://github.com/elastic/kibana/issues/191153 https://github.com/elastic/kibana/issues/191238 Fixes https://github.com/elastic/kibana/issues/190711 --- .../apps/lens/group4/show_underlying_data.ts | 3 ++- .../apps/lens/open_in_lens/tsvb/dashboard.ts | 19 ++++++++++++------- .../apps/managed_content/managed_content.ts | 6 ++++-- .../test/functional/page_objects/lens_page.ts | 5 +++++ .../group2/open_in_lens/agg_based/goal.ts | 12 +++++++++--- .../group2/open_in_lens/agg_based/metric.ts | 13 +++++++++++-- .../group3/open_in_lens/tsvb/dashboard.ts | 7 +++++++ 7 files changed, 50 insertions(+), 15 deletions(-) diff --git a/x-pack/test/functional/apps/lens/group4/show_underlying_data.ts b/x-pack/test/functional/apps/lens/group4/show_underlying_data.ts index fee3756e11759f..2d9035238452fc 100644 --- a/x-pack/test/functional/apps/lens/group4/show_underlying_data.ts +++ b/x-pack/test/functional/apps/lens/group4/show_underlying_data.ts @@ -48,7 +48,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await browser.switchToWindow(discoverWindowHandle); await PageObjects.header.waitUntilLoadingHasFinished(); - await testSubjects.existOrFail('unifiedHistogramChart'); + await PageObjects.discover.waitUntilSearchingHasFinished(); + await testSubjects.existOrFail('unifiedDataTableToolbar'); // check the table columns const columns = await PageObjects.discover.getColumnHeaders(); expect(columns).to.eql(['@timestamp', 'extension.raw', 'bytes']); diff --git a/x-pack/test/functional/apps/lens/open_in_lens/tsvb/dashboard.ts b/x-pack/test/functional/apps/lens/open_in_lens/tsvb/dashboard.ts index e61dd9e9ffb97c..880c35c98975e0 100644 --- a/x-pack/test/functional/apps/lens/open_in_lens/tsvb/dashboard.ts +++ b/x-pack/test/functional/apps/lens/open_in_lens/tsvb/dashboard.ts @@ -89,15 +89,20 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await dashboard.waitForRenderComplete(); const originalEmbeddableCount = await canvas.getEmbeddableCount(); - await retry.try(async () => { - await dashboardPanelActions.customizePanel(); - await dashboardCustomizePanel.enableCustomTimeRange(); + + await panelActions.customizePanel(); + await dashboardCustomizePanel.expectCustomizePanelSettingsFlyoutOpen(); + await dashboardCustomizePanel.enableCustomTimeRange(); + await retry.waitFor('quick menu', async () => { await dashboardCustomizePanel.openDatePickerQuickMenu(); - await dashboardCustomizePanel.clickCommonlyUsedTimeRange('Last_30 days'); - await dashboardCustomizePanel.clickSaveButton(); - await dashboard.waitForRenderComplete(); - await dashboardBadgeActions.expectExistsTimeRangeBadgeAction(); + return await testSubjects.exists('superDatePickerCommonlyUsed_Last_30 days'); }); + await dashboardCustomizePanel.clickCommonlyUsedTimeRange('Last_30 days'); + await dashboardCustomizePanel.clickSaveButton(); + await dashboardCustomizePanel.expectCustomizePanelSettingsFlyoutClosed(); + await dashboard.waitForRenderComplete(); + await dashboardBadgeActions.expectExistsTimeRangeBadgeAction(); + await panelActions.openContextMenu(); await panelActions.clickEdit(); diff --git a/x-pack/test/functional/apps/managed_content/managed_content.ts b/x-pack/test/functional/apps/managed_content/managed_content.ts index 24f88fd72dc36e..63ac63e0c7bf6a 100644 --- a/x-pack/test/functional/apps/managed_content/managed_content.ts +++ b/x-pack/test/functional/apps/managed_content/managed_content.ts @@ -112,7 +112,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { it('maps', async () => { await PageObjects.common.navigateToActualUrl( 'maps', - 'map/managed-d7ab-46eb-a807-8fed28ed8566' + 'map/managed-d7ab-46eb-a807-8fed28ed8566', + { ensureCurrentUrl: false } ); await PageObjects.maps.waitForLayerAddPanelClosed(); @@ -120,7 +121,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await PageObjects.common.navigateToActualUrl( 'maps', - 'map/unmanaged-d7ab-46eb-a807-8fed28ed8566' + 'map/unmanaged-d7ab-46eb-a807-8fed28ed8566', + { ensureCurrentUrl: false } ); await PageObjects.maps.waitForLayerAddPanelClosed(); diff --git a/x-pack/test/functional/page_objects/lens_page.ts b/x-pack/test/functional/page_objects/lens_page.ts index 19a80b2dfce7c8..d2228257d2fbae 100644 --- a/x-pack/test/functional/page_objects/lens_page.ts +++ b/x-pack/test/functional/page_objects/lens_page.ts @@ -1380,6 +1380,11 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont }; }, + async hoverOverDimensionButton(index = 0) { + const dimensionButton = (await testSubjects.findAll('lns-dimensionTrigger'))[index]; + await dimensionButton.moveMouseTo(); + }, + async getMetricVisualizationData() { const tiles = await this.getMetricTiles(); const showingBar = Boolean(await findService.existsByCssSelector('.echSingleMetricProgress')); diff --git a/x-pack/test_serverless/functional/test_suites/common/visualizations/group2/open_in_lens/agg_based/goal.ts b/x-pack/test_serverless/functional/test_suites/common/visualizations/group2/open_in_lens/agg_based/goal.ts index 15da3d48d90376..819cf92062cbbe 100644 --- a/x-pack/test_serverless/functional/test_suites/common/visualizations/group2/open_in_lens/agg_based/goal.ts +++ b/x-pack/test_serverless/functional/test_suites/common/visualizations/group2/open_in_lens/agg_based/goal.ts @@ -21,9 +21,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); describe('Goal', function describeIndexTests() { - // fails on MKI, see https://github.com/elastic/kibana/issues/191238 - this.tags(['failsOnMKI']); - const fixture = 'x-pack/test_serverless/functional/fixtures/kbn_archiver/lens/open_in_lens/agg_based/goal.json'; @@ -49,6 +46,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { it('should convert to Lens', async () => { await panelActions.convertToLensByTitle('Goal - Basic'); await lens.waitForVisualization('mtrVis'); + + // hovering over dimension button to make sure neither of metrics are hovered so the color is stable + await lens.hoverOverDimensionButton(); const data = await lens.getMetricVisualizationData(); expect(data.length).to.be.equal(1); expect(data).to.eql([ @@ -76,6 +76,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { expect(await dimensions[0].getVisibleText()).to.be('Average machine.ram'); expect(await dimensions[1].getVisibleText()).to.be('Static value: 1'); + // hovering over dimension button to make sure neither of metrics are hovered so the color is stable + await lens.hoverOverDimensionButton(); const data = await lens.getMetricVisualizationData(); expect(data.length).to.be.equal(1); expect(data).to.eql([ @@ -104,6 +106,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { expect(await dimensions[1].getVisibleText()).to.be('Static value: 1'); expect(await dimensions[2].getVisibleText()).to.be('@timestamp'); + // hovering over dimension button to make sure neither of metrics are hovered so the color is stable + await lens.hoverOverDimensionButton(); const data = await lens.getMetricVisualizationData(); expect(data.length).to.be.equal(1); expect(data).to.eql([ @@ -132,6 +136,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { expect(await dimensions[1].getVisibleText()).to.be('Static value: 13300000000'); expect(await dimensions[2].getVisibleText()).to.be('machine.os.raw: Descending'); + // hovering over dimension button to make sure neither of metrics are hovered so the color is stable + await lens.hoverOverDimensionButton(); const data = await lens.getMetricVisualizationData(); expect(data.length).to.be.equal(6); expect(data).to.eql([ diff --git a/x-pack/test_serverless/functional/test_suites/common/visualizations/group2/open_in_lens/agg_based/metric.ts b/x-pack/test_serverless/functional/test_suites/common/visualizations/group2/open_in_lens/agg_based/metric.ts index 860f7f2cee1c32..213d3b17cea114 100644 --- a/x-pack/test_serverless/functional/test_suites/common/visualizations/group2/open_in_lens/agg_based/metric.ts +++ b/x-pack/test_serverless/functional/test_suites/common/visualizations/group2/open_in_lens/agg_based/metric.ts @@ -20,8 +20,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const panelActions = getService('dashboardPanelActions'); const kibanaServer = getService('kibanaServer'); - // Failing: See https://github.com/elastic/kibana/issues/191153 - describe.skip('Metric', function describeIndexTests() { + describe('Metric', function describeIndexTests() { const fixture = 'x-pack/test_serverless/functional/fixtures/kbn_archiver/lens/open_in_lens/agg_based/metric.json'; @@ -44,6 +43,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await panelActions.convertToLensByTitle('Metric - Basic'); await lens.waitForVisualization('mtrVis'); + // hovering over dimension button to make sure neither of metrics are hovered so the color is stable + await lens.hoverOverDimensionButton(); const data = await lens.getMetricVisualizationData(); expect(data.length).to.be.equal(1); expect(data).to.eql([ @@ -70,6 +71,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { expect(dimensions).to.have.length(1); expect(await dimensions[0].getVisibleText()).to.be('Average machine.ram'); + // hovering over dimension button to make sure neither of metrics are hovered so the color is stable + await lens.hoverOverDimensionButton(); const data = await lens.getMetricVisualizationData(); expect(data.length).to.be.equal(1); expect(data).to.eql([ @@ -97,6 +100,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { expect(await dimensions[0].getVisibleText()).to.be('Overall Max of Count'); expect(await dimensions[1].getVisibleText()).to.be('@timestamp'); + // hovering over dimension button to make sure neither of metrics are hovered so the color is stable + await lens.hoverOverDimensionButton(); const data = await lens.getMetricVisualizationData(); expect(data.length).to.be.equal(1); expect(data).to.eql([ @@ -129,6 +134,10 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { expect(dimensions).to.have.length(2); expect(await dimensions[0].getVisibleText()).to.be('Average machine.ram'); expect(await dimensions[1].getVisibleText()).to.be('machine.os.raw: Descending'); + + // hovering over dimension button to make sure neither of metrics are hovered so the color is stable + await lens.hoverOverDimensionButton(); + const data = await lens.getMetricVisualizationData(); expect(data.length).to.be.equal(6); expect(data).to.eql([ diff --git a/x-pack/test_serverless/functional/test_suites/common/visualizations/group3/open_in_lens/tsvb/dashboard.ts b/x-pack/test_serverless/functional/test_suites/common/visualizations/group3/open_in_lens/tsvb/dashboard.ts index 2569695008ed19..c41bf13a1e6788 100644 --- a/x-pack/test_serverless/functional/test_suites/common/visualizations/group3/open_in_lens/tsvb/dashboard.ts +++ b/x-pack/test_serverless/functional/test_suites/common/visualizations/group3/open_in_lens/tsvb/dashboard.ts @@ -84,11 +84,18 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await dashboard.waitForRenderComplete(); const originalEmbeddableCount = await canvas.getEmbeddableCount(); + await dashboardPanelActions.customizePanel(); + await dashboardCustomizePanel.expectCustomizePanelSettingsFlyoutOpen(); await dashboardCustomizePanel.enableCustomTimeRange(); await dashboardCustomizePanel.openDatePickerQuickMenu(); + await retry.waitFor('quick menu', async () => { + await dashboardCustomizePanel.openDatePickerQuickMenu(); + return await testSubjects.exists('superDatePickerCommonlyUsed_Last_30 days'); + }); await dashboardCustomizePanel.clickCommonlyUsedTimeRange('Last_30 days'); await dashboardCustomizePanel.clickSaveButton(); + await dashboardCustomizePanel.expectCustomizePanelSettingsFlyoutClosed(); await dashboard.waitForRenderComplete(); await dashboardBadgeActions.expectExistsTimeRangeBadgeAction();