From d680d2d45de4d9b87a79b4ff1f3ce3e060c2685f Mon Sep 17 00:00:00 2001 From: Marco Liberati Date: Thu, 4 Apr 2024 11:24:20 +0200 Subject: [PATCH] Unskip TSVB to Lens functional test (#179858) ## Summary Fixes #179307 and speeds up a bit the `resetPage` method when possible via click on the `Visualize list` navigation breadcrumb on the top left: Screenshot 2024-04-04 at 09 56 37 The work on `navigateToNewVisualization` (function called by `resetPage`) had some side effects for some tests where a uiSettings changes were used as shortcut for the time picker: in such case a `forceRefresh` option has been provided now to cover it, but I may suggest to reduce the usage as much as possible. The new change lead to an average of ~5 minutes saving only within the `open_in_lens/tsvb` test suite, but it is a rough number as the average between the savings on the CI on the flaky runner. Probably there's an extra saving on other test suites as well. Flaky runner for the `Open in Lens/TSVB` test suite (50x runs): https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5604 Flaky runner for the `Lens - Group5` test suite (50x runs): https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5606#_ ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --- .../functional/page_objects/visualize_page.ts | 40 ++++++++++++++++--- .../functional/apps/lens/group5/geo_field.ts | 3 +- .../apps/lens/open_in_lens/tsvb/dashboard.ts | 3 +- .../apps/lens/open_in_lens/tsvb/index.ts | 5 ++- 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/test/functional/page_objects/visualize_page.ts b/test/functional/page_objects/visualize_page.ts index ceae95f637493..521d2afe578c4 100644 --- a/test/functional/page_objects/visualize_page.ts +++ b/test/functional/page_objects/visualize_page.ts @@ -66,8 +66,30 @@ export class VisualizePageObject extends FtrService { }); } - public async gotoVisualizationLandingPage() { - await this.common.navigateToApp('visualize'); + /** + * Try to speed resets a bit if the Visualize Library breadcrumb is available + */ + private async clickOnVisualizeLibraryBreadcrumb() { + // Try to navigate to the Visualize Listing page from breadcrumb if available + const selector = '[data-test-subj="breadcrumb first"][title="Visualize Library"]'; + const visualizeLibraryBreadcrumb = await this.find.existsByCssSelector(selector); + if (visualizeLibraryBreadcrumb) { + await this.find.clickByCssSelector(selector); + // Lens offers a last modal before leaving the page for unsaved charts + // so close it as quick as possible + if (await this.testSubjects.exists('confirmModalConfirmButton')) { + await this.testSubjects.click('confirmModalConfirmButton'); + return true; + } + } + } + + public async gotoVisualizationLandingPage( + { forceRefresh }: { forceRefresh: boolean } = { forceRefresh: false } + ) { + if (forceRefresh || !(await this.clickOnVisualizeLibraryBreadcrumb())) { + await this.common.navigateToApp('visualize'); + } } public async selectVisualizationsTab() { @@ -142,8 +164,15 @@ export class VisualizePageObject extends FtrService { }); } - public async navigateToNewVisualization() { - await this.gotoVisualizationLandingPage(); + /** + * Navigation now happens without URL refresh by default + * so a new "forceRefresh" option has been passed in order to + * address those scenarios where a full refresh is required (i.e. changing default settings) + */ + public async navigateToNewVisualization( + options: { forceRefresh: boolean } = { forceRefresh: false } + ) { + await this.gotoVisualizationLandingPage(options); await this.header.waitUntilLoadingHasFinished(); await this.clickNewVisualization(); await this.waitForGroupsSelectPage(); @@ -158,8 +187,7 @@ export class VisualizePageObject extends FtrService { } public async navigateToLensFromAnotherVisualization() { - const button = await this.testSubjects.find('visualizeEditInLensButton'); - await button.click(); + await this.testSubjects.click('visualizeEditInLensButton'); } public async hasNavigateToLensButton() { diff --git a/x-pack/test/functional/apps/lens/group5/geo_field.ts b/x-pack/test/functional/apps/lens/group5/geo_field.ts index 790160a4b1bba..98008e3b7bb12 100644 --- a/x-pack/test/functional/apps/lens/group5/geo_field.ts +++ b/x-pack/test/functional/apps/lens/group5/geo_field.ts @@ -30,7 +30,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should visualize geo fields in maps', async () => { - await PageObjects.visualize.navigateToNewVisualization(); + // as navigation does not happen via URL refresh by default, force a reset via URL navigation + await PageObjects.visualize.navigateToNewVisualization({ forceRefresh: true }); await PageObjects.visualize.clickVisType('lens'); await PageObjects.lens.switchDataPanelIndexPattern('logstash-*'); await PageObjects.header.waitUntilLoadingHasFinished(); 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 e5a2a8f6a8971..24fac3f726bc9 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 @@ -28,8 +28,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const dashboardAddPanel = getService('dashboardAddPanel'); const filterBar = getService('filterBar'); - // FLAKY: https://github.com/elastic/kibana/issues/179307 - describe.skip('Dashboard to TSVB to Lens', function describeIndexTests() { + describe('Dashboard to TSVB to Lens', function describeIndexTests() { before(async () => { await visualize.initTests(); }); diff --git a/x-pack/test/functional/apps/lens/open_in_lens/tsvb/index.ts b/x-pack/test/functional/apps/lens/open_in_lens/tsvb/index.ts index 90b0eb2c88186..b48211b1af938 100644 --- a/x-pack/test/functional/apps/lens/open_in_lens/tsvb/index.ts +++ b/x-pack/test/functional/apps/lens/open_in_lens/tsvb/index.ts @@ -52,11 +52,12 @@ export default function ({ loadTestFile, getService, getPageObjects }: FtrProvid } await esNode.load(esArchive); - // changing the timepicker default here saves us from having to set it in Discover (~8s) - await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); await kibanaServer.uiSettings.update({ defaultIndex: indexPatternString, 'dateFormat:tz': 'UTC', + // changing the timepicker default here saves us from having to set it in Discover (~8s) + // The TSVB tests are using a slightly difference end date, so it needs to be set manually here + 'timepicker:timeDefaults': `{ "from": "${PageObjects.timePicker.defaultStartTime}", "to": "Sep 22, 2015 @ 18:31:44.000" }`, }); await kibanaServer.importExport.load(fixtureDirs.lensBasic); await kibanaServer.importExport.load(fixtureDirs.lensDefault);