From 0aacdb03bcfe6792735696cc0144c8cc198c2779 Mon Sep 17 00:00:00 2001 From: "Eyo O. Eyo" <7893459+eokoneyo@users.noreply.github.com> Date: Tue, 5 Nov 2024 21:00:03 +0100 Subject: [PATCH] fix for flaky sample data test (#199005) ## Summary Closes https://github.com/elastic/kibana/issues/187473, https://github.com/elastic/kibana/issues/112103 ### Checklist - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed (cherry picked from commit f988de272608bcb93b8a22f35c945f28dff50a91) --- test/functional/page_objects/home_page.ts | 62 +++++++++++++---------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/test/functional/page_objects/home_page.ts b/test/functional/page_objects/home_page.ts index 31a162a8800d6..4bdf99a9b7b35 100644 --- a/test/functional/page_objects/home_page.ts +++ b/test/functional/page_objects/home_page.ts @@ -91,40 +91,46 @@ export class HomePageObject extends FtrService { async addSampleDataSet(id: string) { await this.openSampleDataAccordion(); - const isInstalled = await this.isSampleDataSetInstalled(id); - if (!isInstalled) { + await this.retry.waitFor('sample data to be installed', async () => { + // count for the edge case where some how installation completes just before the retry occurs + if (await this.isSampleDataSetInstalled(id)) { + return true; + } + this.log.debug(`Attempting to add sample data: ${id}`); - await this.retry.waitFor('sample data to be installed', async () => { - // Echoing the adjustments made to 'removeSampleDataSet', as we are seeing flaky test cases here as well - // https://github.com/elastic/kibana/issues/52714 - await this.testSubjects.waitForEnabled(`addSampleDataSet${id}`); - await this.common.sleep(1010); - await this.testSubjects.click(`addSampleDataSet${id}`); - await this.common.sleep(1010); - await this._waitForSampleDataLoadingAction(id); - return await this.isSampleDataSetInstalled(id); - }); - } + + // Echoing the adjustments made to 'removeSampleDataSet', as we are seeing flaky test cases here as well + // https://github.com/elastic/kibana/issues/52714 + await this.testSubjects.waitForEnabled(`addSampleDataSet${id}`); + await this.common.sleep(1010); + await this.testSubjects.click(`addSampleDataSet${id}`); + await this.common.sleep(1010); + await this._waitForSampleDataLoadingAction(id); + return await this.isSampleDataSetInstalled(id); + }); } async removeSampleDataSet(id: string) { await this.openSampleDataAccordion(); - const isInstalled = await this.isSampleDataSetInstalled(id); - if (isInstalled) { + await this.retry.waitFor('sample data to be removed', async () => { + // account for the edge case where some how data is uninstalled just before the retry occurs + if (!(await this.isSampleDataSetInstalled(id))) { + return true; + } + this.log.debug(`Attempting to remove sample data: ${id}`); - await this.retry.waitFor('sample data to be removed', async () => { - // looks like overkill but we're hitting flaky cases where we click but it doesn't remove - await this.testSubjects.waitForEnabled(`removeSampleDataSet${id}`); - // https://github.com/elastic/kibana/issues/65949 - // Even after waiting for the "Remove" button to be enabled we still have failures - // where it appears the click just didn't work. - await this.common.sleep(1010); - await this.testSubjects.click(`removeSampleDataSet${id}`); - await this.common.sleep(1010); - await this._waitForSampleDataLoadingAction(id); - return !(await this.isSampleDataSetInstalled(id)); - }); - } + + // looks like overkill but we're hitting flaky cases where we click but it doesn't remove + await this.testSubjects.waitForEnabled(`removeSampleDataSet${id}`); + // https://github.com/elastic/kibana/issues/65949 + // Even after waiting for the "Remove" button to be enabled we still have failures + // where it appears the click just didn't work. + await this.common.sleep(1010); + await this.testSubjects.click(`removeSampleDataSet${id}`); + await this.common.sleep(1010); + await this._waitForSampleDataLoadingAction(id); + return !(await this.isSampleDataSetInstalled(id)); + }); } // loading action is either uninstall and install