From eb13fa3691fbc73b1083673509b066bdd14eea17 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 10 Oct 2019 18:16:39 +0200 Subject: [PATCH] Fix homepage app sample data dashboard test failures in cloud (#47737) (#47835) * Improve launchSampleData of HomePageProvider for cloud testing * Migrate to typescript --- .../{home_page.js => home_page.ts} | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) rename test/functional/page_objects/{home_page.js => home_page.ts} (71%) diff --git a/test/functional/page_objects/home_page.js b/test/functional/page_objects/home_page.ts similarity index 71% rename from test/functional/page_objects/home_page.js rename to test/functional/page_objects/home_page.ts index 008a3dff69c0f..cf9eb4332c3e1 100644 --- a/test/functional/page_objects/home_page.js +++ b/test/functional/page_objects/home_page.ts @@ -17,47 +17,42 @@ * under the License. */ -export function HomePageProvider({ getService }) { +import { FtrProviderContext } from '../ftr_provider_context'; + +export function HomePageProvider({ getService }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const retry = getService('retry'); + const find = getService('find'); class HomePage { - async clickSynopsis(title) { + async clickSynopsis(title: string) { await testSubjects.click(`homeSynopsisLink${title}`); } - async doesSynopsisExist(title) { + async doesSynopsisExist(title: string) { return await testSubjects.exists(`homeSynopsisLink${title}`); } - async doesSampleDataSetExist(id) { + async doesSampleDataSetExist(id: string) { return await testSubjects.exists(`sampleDataSetCard${id}`); } - async doesSampleDataSetSuccessfulInstallToastExist() { - return await testSubjects.exists('sampleDataSetInstallToast'); - } - - async doesSampleDataSetSuccessfulUninstallToastExist() { - return await testSubjects.exists('sampleDataSetUninstallToast'); - } - - async isSampleDataSetInstalled(id) { + async isSampleDataSetInstalled(id: string) { return await testSubjects.exists(`removeSampleDataSet${id}`); } - async addSampleDataSet(id) { + async addSampleDataSet(id: string) { await testSubjects.click(`addSampleDataSet${id}`); await this._waitForSampleDataLoadingAction(id); } - async removeSampleDataSet(id) { + async removeSampleDataSet(id: string) { await testSubjects.click(`removeSampleDataSet${id}`); await this._waitForSampleDataLoadingAction(id); } // loading action is either uninstall and install - async _waitForSampleDataLoadingAction(id) { + async _waitForSampleDataLoadingAction(id: string) { const sampleDataCard = await testSubjects.find(`sampleDataSetCard${id}`); await retry.try(async () => { // waitForDeletedByCssSelector needs to be inside retry because it will timeout at least once @@ -66,22 +61,27 @@ export function HomePageProvider({ getService }) { }); } - async launchSampleDataSet(id) { - await testSubjects.click(`launchSampleDataSet${id}`); + async launchSampleDataSet(id: string) { + if (await find.existsByCssSelector(`#sampleDataLinks${id}`)) { + // omits cloud test failures + await find.clickByCssSelectorWhenNotDisabled(`#sampleDataLinks${id}`); + await find.clickByCssSelector('.euiContextMenuItem:nth-of-type(1)'); + } else { + await testSubjects.click(`launchSampleDataSet${id}`); + } } async loadSavedObjects() { await retry.try(async () => { await testSubjects.click('loadSavedObjects'); const successMsgExists = await testSubjects.exists('loadSavedObjects_success', { - timeout: 5000 + timeout: 5000, }); if (!successMsgExists) { throw new Error('Failed to load saved objects'); } }); } - } return new HomePage();