From 30b6cf704223e10bbb0700b46eefa779fe729728 Mon Sep 17 00:00:00 2001 From: Michail Yasonik Date: Fri, 19 Feb 2021 13:03:56 -0500 Subject: [PATCH] swallow error messages --- test/functional/page_objects/common_page.ts | 12 ++---------- test/functional/services/toasts.ts | 10 +++++++--- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/test/functional/page_objects/common_page.ts b/test/functional/page_objects/common_page.ts index c6412f55dffbf..b189ad3830ca3 100644 --- a/test/functional/page_objects/common_page.ts +++ b/test/functional/page_objects/common_page.ts @@ -22,6 +22,7 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo const globalNav = getService('globalNav'); const testSubjects = getService('testSubjects'); const PageObjects = getPageObjects(['login']); + const toasts = getService('toasts'); const defaultTryTimeout = config.get('timeouts.try'); const defaultFindTimeout = config.get('timeouts.find'); @@ -396,16 +397,7 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo } async clearAllToasts() { - const toasts = await find.allByCssSelector('.euiToast'); - for (const toastElement of toasts) { - try { - await toastElement.moveMouseTo(); - const closeBtn = await toastElement.findByCssSelector('.euiToast__closeButton'); - await closeBtn.click(); - } catch (err) { - // ignore errors, toast clear themselves after timeout - } - } + await toasts.dismissAllToasts(); } async getJsonBodyText() { diff --git a/test/functional/services/toasts.ts b/test/functional/services/toasts.ts index e8e788fc96f84..aeaf79e75574a 100644 --- a/test/functional/services/toasts.ts +++ b/test/functional/services/toasts.ts @@ -10,7 +10,6 @@ import { FtrProviderContext } from '../ftr_provider_context'; export function ToastsProvider({ getService }: FtrProviderContext) { const testSubjects = getService('testSubjects'); - const retry = getService('retry'); class Toasts { /** @@ -53,8 +52,13 @@ export function ToastsProvider({ getService }: FtrProviderContext) { await toast.moveMouseTo(); if (await testSubjects.descendantExists('toastCloseButton', toast)) { - const dismissButton = await testSubjects.findDescendant('toastCloseButton', toast); - await dismissButton.click(); + try { + const dismissButton = await testSubjects.findDescendant('toastCloseButton', toast); + await dismissButton.click(); + } catch (err) { + // ignore errors + // toasts are finnicky because they can dismiss themselves right before you close them + } } } }