From 070aaa3d5cb5e5f6aa0cd54f487c133b47cef2d3 Mon Sep 17 00:00:00 2001 From: Robert Oskamp Date: Mon, 21 Oct 2019 11:38:56 +0200 Subject: [PATCH 1/3] Add retry to testSubjects.existOrFail --- test/functional/services/test_subjects.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/functional/services/test_subjects.ts b/test/functional/services/test_subjects.ts index c3b2076dce9f9..a121ef336c5aa 100644 --- a/test/functional/services/test_subjects.ts +++ b/test/functional/services/test_subjects.ts @@ -55,9 +55,12 @@ export function TestSubjectsProvider({ getService }: FtrProviderContext) { selector: string, existsOptions?: ExistsOptions ): Promise { - if (!(await this.exists(selector, { timeout: TRY_TIME, ...existsOptions }))) { - throw new Error(`expected testSubject(${selector}) to exist`); - } + const options = { timeout: TRY_TIME, ...existsOptions }; + await retry.tryForTime(options.timeout, async () => { + if (!(await this.exists(selector, options))) { + throw new Error(`expected testSubject(${selector}) to exist`); + } + }); } public async missingOrFail( From b284bb91c4c30d8f50a81bd4efaa1d6233d63b29 Mon Sep 17 00:00:00 2001 From: Robert Oskamp Date: Wed, 23 Oct 2019 15:31:11 +0200 Subject: [PATCH 2/3] Move retry logiv to find.existsByDisplayedByCssSelector --- test/functional/services/find.ts | 20 ++++++++++++++++---- test/functional/services/test_subjects.ts | 9 +++------ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/test/functional/services/find.ts b/test/functional/services/find.ts index c65821ea73ace..312668b718dc0 100644 --- a/test/functional/services/find.ts +++ b/test/functional/services/find.ts @@ -303,10 +303,22 @@ export async function FindProvider({ getService }: FtrProviderContext) { timeout: number = WAIT_FOR_EXISTS_TIME ): Promise { log.debug(`Find.existsByDisplayedByCssSelector('${selector}') with timeout=${timeout}`); - return await this.exists(async drive => { - const elements = wrapAll(await drive.findElements(By.css(selector))); - return await this.filterElementIsDisplayed(elements); - }, timeout); + try { + await retry.tryForTime(timeout, async () => { + // make sure that the find timeout is not longer than the retry timeout + await this._withTimeout(Math.min(timeout, WAIT_FOR_EXISTS_TIME)); + const elements = await driver.findElements(By.css(selector)); + await this._withTimeout(defaultFindTimeout); + const displayed = await this.filterElementIsDisplayed(wrapAll(elements)); + if (displayed.length === 0) { + throw new Error(`${selector} is not displayed`); + } + }); + } catch (err) { + await this._withTimeout(defaultFindTimeout); + return false; + } + return true; } public async existsByCssSelector( diff --git a/test/functional/services/test_subjects.ts b/test/functional/services/test_subjects.ts index 483c3cb87b3d1..a3f64e6f96cc8 100644 --- a/test/functional/services/test_subjects.ts +++ b/test/functional/services/test_subjects.ts @@ -56,12 +56,9 @@ export function TestSubjectsProvider({ getService }: FtrProviderContext) { selector: string, existsOptions?: ExistsOptions ): Promise { - const options = { timeout: TRY_TIME, ...existsOptions }; - await retry.tryForTime(options.timeout, async () => { - if (!(await this.exists(selector, options))) { - throw new Error(`expected testSubject(${selector}) to exist`); - } - }); + if (!(await this.exists(selector, { timeout: TRY_TIME, ...existsOptions }))) { + throw new Error(`expected testSubject(${selector}) to exist`); + } } public async missingOrFail( From 89043cd3e1c019edf9894dfc3d3d4d198cbf2a18 Mon Sep 17 00:00:00 2001 From: Robert Oskamp Date: Wed, 13 Nov 2019 10:27:15 +0100 Subject: [PATCH 3/3] Move toast handling to saveDashboard --- test/functional/apps/dashboard/dashboard_snapshots.js | 2 -- test/functional/page_objects/dashboard_page.js | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/test/functional/apps/dashboard/dashboard_snapshots.js b/test/functional/apps/dashboard/dashboard_snapshots.js index e98c4afc443f8..698f4d1de6d57 100644 --- a/test/functional/apps/dashboard/dashboard_snapshots.js +++ b/test/functional/apps/dashboard/dashboard_snapshots.js @@ -53,7 +53,6 @@ export default function ({ getService, getPageObjects, updateBaselines }) { await PageObjects.common.closeToast(); await PageObjects.dashboard.saveDashboard('tsvb'); - await PageObjects.common.closeToast(); await PageObjects.dashboard.clickFullScreenMode(); await dashboardPanelActions.openContextMenu(); await dashboardPanelActions.clickExpandPanelToggle(); @@ -74,7 +73,6 @@ export default function ({ getService, getPageObjects, updateBaselines }) { await PageObjects.common.closeToast(); await PageObjects.dashboard.saveDashboard('area'); - await PageObjects.common.closeToast(); await PageObjects.dashboard.clickFullScreenMode(); await dashboardPanelActions.openContextMenu(); await dashboardPanelActions.clickExpandPanelToggle(); diff --git a/test/functional/page_objects/dashboard_page.js b/test/functional/page_objects/dashboard_page.js index ca141114f976d..ffbbcdf302622 100644 --- a/test/functional/page_objects/dashboard_page.js +++ b/test/functional/page_objects/dashboard_page.js @@ -305,7 +305,8 @@ export function DashboardPageProvider({ getService, getPageObjects }) { /** * Save the current dashboard with the specified name and options and - * verify that the save was successful + * verify that the save was successful, close the toast and return the + * toast message * * @param dashName {String} * @param saveOptions {{storeTimeWithDashboard: boolean, saveAsNew: boolean, needsConfirm: false, waitDialogIsClosed: boolean }} @@ -319,8 +320,11 @@ export function DashboardPageProvider({ getService, getPageObjects }) { // Confirm that the Dashboard has actually been saved await testSubjects.existOrFail('saveDashboardSuccess'); + const message = await PageObjects.common.closeToast(); await PageObjects.header.waitUntilLoadingHasFinished(); await this.waitForSaveModalToClose(); + + return message; } async waitForSaveModalToClose() {