From 986116133f43e5ad81c113aba7d44e6b34d8eaf0 Mon Sep 17 00:00:00 2001 From: Tre Date: Wed, 14 Feb 2024 09:24:20 +0000 Subject: [PATCH] [FTR] Refactor toasts svc (#174222) ### Summary Refactoring general ui service (test helpers), to a kbn package. - Optimize methods and drop some code duplication. ### Why - Makes the service easily available from multiple code areas. - This is a preparation to potentially moving tests to plugins / packages, where they would no longer be able to import thing from test or x-pack/test but only from a package. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> --- .../services/all.ts | 2 + .../services/toasts.ts | 156 ++++++++++++++++++ .../tsconfig.json | 3 +- test/accessibility/apps/discover.ts | 2 +- test/examples/search/warnings.ts | 13 +- test/functional/apps/console/_context_menu.ts | 2 +- test/functional/apps/console/_text_input.ts | 2 +- .../apps/dashboard/group3/bwc_shared_urls.ts | 4 +- .../dashboard/group6/dashboard_snapshots.ts | 5 +- .../apps/discover/group1/_shared_links.ts | 6 +- .../group2/_data_grid_copy_to_clipboard.ts | 16 +- .../apps/discover/group4/_adhoc_data_views.ts | 4 +- .../management/data_views/_field_formatter.ts | 2 +- .../data_views/_handle_not_found.ts | 2 +- .../data_views/_handle_version_conflict.ts | 5 +- test/functional/page_objects/common_page.ts | 33 ---- .../functional/page_objects/dashboard_page.ts | 3 +- test/functional/page_objects/home_page.ts | 3 +- .../functional/page_objects/visualize_page.ts | 3 +- .../services/dashboard/add_panel.ts | 7 +- .../services/dashboard/dashboard_settings.ts | 6 +- .../services/dashboard/panel_settings.ts | 2 +- test/functional/services/index.ts | 2 - test/functional/services/toasts.ts | 112 ------------- .../test_suites/data_plugin/session.ts | 6 +- .../apps/group1/advanced_settings.ts | 12 +- .../apps/group1/dashboard_panel_options.ts | 2 +- .../test/accessibility/apps/group1/spaces.ts | 2 +- .../test/accessibility/apps/group1/uptime.ts | 2 +- .../apps/group3/rules_connectors.ts | 2 +- .../apps/group3/security_solution.ts | 2 +- .../page_objects/findings_page.ts | 12 -- .../pages/findings_alerts.ts | 11 +- .../search_examples/search_example.ts | 8 +- .../search_examples/search_sessions_cache.ts | 6 +- .../search_examples/sql_search_example.ts | 2 +- .../dashboard_to_dashboard_drilldown.ts | 5 +- .../functional/apps/discover/reporting.ts | 3 +- .../data_streams_tab/data_streams_tab.ts | 4 +- .../enrich_policies_tab.ts | 4 +- .../apps/lens/group6/annotations.ts | 2 +- x-pack/test/functional/apps/security/users.ts | 12 +- .../apps/user_profiles/user_profiles.ts | 15 +- .../observability_logs_explorer.ts | 2 +- .../functional/page_objects/reporting_page.ts | 5 - .../test/functional/services/cases/common.ts | 2 +- .../test/functional/services/ml/common_ui.ts | 6 +- .../services/ml/stack_management_jobs.ts | 20 +-- .../services/observability/alerts/common.ts | 4 +- .../functional/services/transform/wizard.ts | 4 +- .../apps/cases/group2/attachment_framework.ts | 8 +- .../apps/cases/group2/configure.ts | 4 +- .../apps/cases/group2/list_view.ts | 4 +- .../apps/cases/group2/upgrade.ts | 4 +- .../discover/search_source_alert.ts | 12 +- .../discover_ml_uptime/uptime/alert_flyout.ts | 5 +- .../uptime/simple_down_alert.ts | 2 +- .../alert_create_flyout.ts | 11 +- .../triggers_actions_ui/connectors/general.ts | 9 +- .../connectors/opsgenie.ts | 5 +- .../triggers_actions_ui/connectors/slack.ts | 11 +- .../triggers_actions_ui/connectors/tines.ts | 5 +- .../apps/triggers_actions_ui/details.ts | 9 +- .../maintenance_windows_table.ts | 11 +- .../rules_list/bulk_actions.ts | 11 +- .../rules_list/rules_list.ts | 7 +- .../tests/conversations/index.spec.ts | 4 +- .../ibm_resilient_connector.ts | 5 +- .../stack_connectors/sentinelone_connector.ts | 3 +- .../stack_connectors/tines_connector.ts | 4 +- .../async_search/save_search_session.ts | 2 +- .../session_searches_integration.ts | 6 +- .../async_search/sessions_in_space.ts | 2 +- .../tests/apps/discover/async_search.ts | 6 +- .../tests/apps/discover/sessions_in_space.ts | 2 +- .../login_selector/basic_functionality.ts | 5 +- .../integrations/artifact_entries_list.ts | 11 +- .../apps/integrations/endpoint_exceptions.ts | 5 +- .../apps/integrations/trusted_apps_list.ts | 3 +- .../page_objects/policy_page.ts | 3 +- .../discover/group2/_adhoc_data_views.ts | 4 +- .../common/discover/x_pack/reporting.ts | 3 +- .../discover/search_source_alert.ts | 12 +- .../common/examples/search/warnings.ts | 13 +- .../search_examples/search_example.ts | 8 +- .../index_management/data_streams.ts | 4 +- .../cases/attachment_framework.ts | 4 +- .../observability/cases/configure.ts | 4 +- .../observability/rules/rules_list.ts | 8 +- .../test_suites/search/rules/rule_details.ts | 8 +- .../ftr/cases/attachment_framework.ts | 4 +- .../security/ftr/cases/configure.ts | 4 +- 92 files changed, 405 insertions(+), 400 deletions(-) create mode 100644 packages/kbn-ftr-common-functional-ui-services/services/toasts.ts delete mode 100644 test/functional/services/toasts.ts diff --git a/packages/kbn-ftr-common-functional-ui-services/services/all.ts b/packages/kbn-ftr-common-functional-ui-services/services/all.ts index 313aa6eb0b71f..bffa7468e14ea 100644 --- a/packages/kbn-ftr-common-functional-ui-services/services/all.ts +++ b/packages/kbn-ftr-common-functional-ui-services/services/all.ts @@ -11,6 +11,7 @@ import { RemoteProvider } from './remote'; import { FindProvider } from './find'; import { TestSubjects } from './test_subjects'; import { BrowserProvider } from './browser'; +import { ToastsService } from './toasts'; export const services = { retryOnStale: RetryOnStaleProvider, @@ -18,4 +19,5 @@ export const services = { find: FindProvider, testSubjects: TestSubjects, browser: BrowserProvider, + toasts: ToastsService, }; diff --git a/packages/kbn-ftr-common-functional-ui-services/services/toasts.ts b/packages/kbn-ftr-common-functional-ui-services/services/toasts.ts new file mode 100644 index 0000000000000..e13ec28ff61d5 --- /dev/null +++ b/packages/kbn-ftr-common-functional-ui-services/services/toasts.ts @@ -0,0 +1,156 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import expect from '@kbn/expect'; +import { FtrService } from './ftr_provider_context'; +import { WebElementWrapper } from './web_element_wrapper'; + +export class ToastsService extends FtrService { + private readonly testSubjects = this.ctx.getService('testSubjects'); + private readonly retry = this.ctx.getService('retry'); + private readonly find = this.ctx.getService('find'); + private readonly config = this.ctx.getService('config'); + private readonly defaultFindTimeout = this.config.get('timeouts.find'); + /** + * Returns the title and message of a specific error toast. + * This method is specific to toasts created via `.addError` since they contain + * an additional button, that should not be part of the message. + * + * @param index The index of the toast (1-based, NOT 0-based!) of the toast. Use first by default. + * @param titleOnly If this is true, only the title of the error message is returned. There are error messages that only contain a title, no message. + * @returns The title and message of the specified error toast. + */ + public async getErrorByIndex( + index: number = 1, + titleOnly: boolean = false + ): Promise<{ title: string; message?: string }> { + const title = await this.getTitleByIndex(index); + if (titleOnly) return { title }; + + const toast = await this.getElementByIndex(index); + const messageElement = await this.testSubjects.findDescendant('errorToastMessage', toast); + const message: string = await messageElement.getVisibleText(); + + return { title, message }; + } + + public async toastMessageByTestSubj(testSubj = 'csp:toast-success') { + const testSubjSvc = this.testSubjects; + return { + async getElement(): Promise { + return await testSubjSvc.find(testSubj); + }, + async clickToastMessageLink(linkTestSubj = 'csp:toast-success-link') { + const element = await this.getElement(); + const link = await element.findByTestSubject(linkTestSubj); + await link.click(); + }, + }; + } + + /** + * Dismiss a specific toast from the toast list. Since toasts usually should time out themselves, + * you only need to call this for permanent toasts (e.g. error toasts). + * + * @param index The 1-based index of the toast to dismiss. Use first by default. + */ + public async dismissByIndex(index: number = 1): Promise { + const toast = await this.getElementByIndex(index); + await toast.moveMouseTo(); + const dismissButton = await this.testSubjects.findDescendant('toastCloseButton', toast); + await dismissButton.click(); + } + + public async dismissIfExists(): Promise { + const toastShown = await this.find.existsByCssSelector('.euiToast'); + if (toastShown) { + try { + await this.testSubjects.click('toastCloseButton'); + } catch (err) { + // ignore errors, toast clear themselves after timeout + } + } + } + + public async getTitleAndDismiss(): Promise { + const toast = await this.find.byCssSelector('.euiToast', 6 * this.defaultFindTimeout); + await toast.moveMouseTo(); + const title = await (await this.testSubjects.find('euiToastHeader__title')).getVisibleText(); + + await this.testSubjects.click('toastCloseButton'); + return title; + } + + public async dismiss(): Promise { + await this.testSubjects.click('toastCloseButton', 6 * this.defaultFindTimeout); + } + + public async dismissAll(): Promise { + const allToastElements = await this.getAll(); + + if (allToastElements.length === 0) return; + + for (const toastElement of allToastElements) { + try { + await toastElement.moveMouseTo(); + const closeBtn = await toastElement.findByTestSubject('toastCloseButton'); + await closeBtn.click(); + } catch (err) { + // ignore errors, toast clear themselves after timeout + } + } + } + + public async dismissAllWithChecks(): Promise { + await this.retry.tryForTime(30 * 1000, async (): Promise => { + await this.dismissAll(); + await this.assertCount(0); + }); + } + + public async assertCount(expectedCount: number): Promise { + await this.retry.tryForTime(5 * 1000, async (): Promise => { + const toastCount = await this.getCount({ timeout: 1000 }); + expect(toastCount).to.eql( + expectedCount, + `Toast count should be ${expectedCount} (got ${toastCount})` + ); + }); + } + + public async getElementByIndex(index: number): Promise { + return await (await this.getGlobalList()).findByCssSelector(`.euiToast:nth-child(${index})`); + } + + public async getTitleByIndex(index: number): Promise { + const resultToast = await this.getElementByIndex(index); + const titleElement = await this.testSubjects.findDescendant('euiToastHeader', resultToast); + const title: string = await titleElement.getVisibleText(); + return title; + } + + public async getContentByIndex(index: number): Promise { + const elem = await this.getElementByIndex(index); + return await elem.getVisibleText(); + } + + public async getAll(): Promise { + const list = await this.getGlobalList(); + return await list.findAllByCssSelector(`.euiToast`); + } + + private async getGlobalList(options?: { timeout?: number }): Promise { + return await this.testSubjects.find('globalToastList', options?.timeout); + } + + public async getCount(options?: { timeout?: number }): Promise { + const list = await this.getGlobalList(options); + const toasts = await list.findAllByCssSelector(`.euiToast`, options?.timeout); + return toasts.length; + } +} diff --git a/packages/kbn-ftr-common-functional-ui-services/tsconfig.json b/packages/kbn-ftr-common-functional-ui-services/tsconfig.json index ccba7988041f7..555e696f0ca51 100644 --- a/packages/kbn-ftr-common-functional-ui-services/tsconfig.json +++ b/packages/kbn-ftr-common-functional-ui-services/tsconfig.json @@ -12,6 +12,7 @@ "@kbn/repo-info", "@kbn/test-subj-selector", "@kbn/ftr-common-functional-services", - "@kbn/std" + "@kbn/std", + "@kbn/expect" ] } diff --git a/test/accessibility/apps/discover.ts b/test/accessibility/apps/discover.ts index 8a4dc8de7a52b..4a20261d5bf64 100644 --- a/test/accessibility/apps/discover.ts +++ b/test/accessibility/apps/discover.ts @@ -154,7 +154,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); await retry.try(async () => { - await toasts.dismissAllToasts(); + await toasts.dismissAll(); }); await a11y.testAppSnapshot(); diff --git a/test/examples/search/warnings.ts b/test/examples/search/warnings.ts index 80d4224d2ef83..2e595bc725ac0 100644 --- a/test/examples/search/warnings.ts +++ b/test/examples/search/warnings.ts @@ -9,14 +9,12 @@ import type { estypes } from '@elastic/elasticsearch'; import expect from '@kbn/expect'; import assert from 'assert'; -import type { WebElementWrapper } from '@kbn/ftr-common-functional-ui-services'; import type { FtrProviderContext } from '../../functional/ftr_provider_context'; // eslint-disable-next-line import/no-default-export export default function ({ getService, getPageObjects }: FtrProviderContext) { const PageObjects = getPageObjects(['common', 'timePicker']); const testSubjects = getService('testSubjects'); - const find = getService('find'); const retry = getService('retry'); const es = getService('es'); const log = getService('log'); @@ -25,6 +23,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const esArchiver = getService('esArchiver'); const monacoEditor = getService('monacoEditor'); + const toasts = getService('toasts'); describe('handling warnings with search source fetch', function () { const dataViewTitle = 'sample-01,sample-01-rollup'; @@ -34,7 +33,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const testIndex = 'sample-01'; const testRollupIndex = 'sample-01-rollup'; const testRollupField = 'kubernetes.container.memory.usage.bytes'; - const toastsSelector = '[data-test-subj=globalToastList] [data-test-subj=euiToastHeader]'; const shardFailureType = 'unsupported_aggregation_on_downsampled_index'; const shardFailureReason = `Field [${testRollupField}] of type [aggregate_metric_double] is not supported for aggregation [percentiles]`; @@ -97,15 +95,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); afterEach(async () => { - await PageObjects.common.clearAllToasts(); + await toasts.dismissAll(); }); it('should show search warnings as toasts', async () => { await testSubjects.click('searchSourceWithOther'); await retry.try(async () => { - const toasts = await find.allByCssSelector(toastsSelector); - expect(toasts.length).to.be(2); + expect(await toasts.getCount()).to.be(2); await testSubjects.click('viewWarningBtn'); }); @@ -152,10 +149,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.click('searchSourceWithoutOther'); // wait for toasts - toasts appear after the response is rendered - let toasts: WebElementWrapper[] = []; await retry.try(async () => { - toasts = await find.allByCssSelector(toastsSelector); - expect(toasts.length).to.be(2); + expect(await toasts.getCount()).to.be(2); }); // warnings tab diff --git a/test/functional/apps/console/_context_menu.ts b/test/functional/apps/console/_context_menu.ts index 0d89a762ad910..4051804d7407f 100644 --- a/test/functional/apps/console/_context_menu.ts +++ b/test/functional/apps/console/_context_menu.ts @@ -43,7 +43,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.console.clickContextMenu(); await PageObjects.console.clickCopyAsCurlButton(); - const resultToast = await toasts.getToastElement(1); + const resultToast = await toasts.getElementByIndex(1); const toastText = await resultToast.getVisibleText(); if (toastText.includes('Write permission denied')) { diff --git a/test/functional/apps/console/_text_input.ts b/test/functional/apps/console/_text_input.ts index 29290fac6728f..8826b24931c07 100644 --- a/test/functional/apps/console/_text_input.ts +++ b/test/functional/apps/console/_text_input.ts @@ -42,7 +42,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); await retry.try(async () => { - expect(await toasts.getToastCount()).to.equal(1); + expect(await toasts.getCount()).to.equal(1); }); }); }); diff --git a/test/functional/apps/dashboard/group3/bwc_shared_urls.ts b/test/functional/apps/dashboard/group3/bwc_shared_urls.ts index 0b06e28af0f11..8f89ed302c67c 100644 --- a/test/functional/apps/dashboard/group3/bwc_shared_urls.ts +++ b/test/functional/apps/dashboard/group3/bwc_shared_urls.ts @@ -78,7 +78,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const query = await queryBar.getQueryString(); expect(query).to.equal('memory:>220000'); - const warningToast = await toasts.getToastElement(1); + const warningToast = await toasts.getElementByIndex(1); expect(await warningToast.getVisibleText()).to.contain('Cannot load panels'); await PageObjects.dashboard.waitForRenderComplete(); @@ -96,7 +96,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const query = await queryBar.getQueryString(); expect(query).to.equal('memory:>220000'); - const warningToast = await toasts.getToastElement(1); + const warningToast = await toasts.getElementByIndex(1); expect(await warningToast.getVisibleText()).to.contain('Cannot load panels'); await PageObjects.dashboard.waitForRenderComplete(); }); diff --git a/test/functional/apps/dashboard/group6/dashboard_snapshots.ts b/test/functional/apps/dashboard/group6/dashboard_snapshots.ts index 3c743e9021a21..23b8b071e41d1 100644 --- a/test/functional/apps/dashboard/group6/dashboard_snapshots.ts +++ b/test/functional/apps/dashboard/group6/dashboard_snapshots.ts @@ -31,6 +31,7 @@ export default function ({ const dashboardAddPanel = getService('dashboardAddPanel'); const testSubjects = getService('testSubjects'); const retry = getService('retry'); + const toasts = getService('toasts'); describe('dashboard snapshots', function describeIndexTests() { before(async function () { @@ -58,7 +59,7 @@ export default function ({ await PageObjects.dashboard.clickNewDashboard(); await PageObjects.timePicker.setLogstashDataRange(); await dashboardAddPanel.addVisualization('Rendering Test: tsvb-ts'); - await PageObjects.common.closeToastIfExists(); + await toasts.dismissIfExists(); await PageObjects.dashboard.saveDashboard('tsvb'); await PageObjects.dashboard.clickFullScreenMode(); @@ -80,7 +81,7 @@ export default function ({ await PageObjects.dashboard.clickNewDashboard(); await PageObjects.timePicker.setLogstashDataRange(); await dashboardAddPanel.addVisualization('Rendering Test: area with not filter'); - await PageObjects.common.closeToastIfExists(); + await toasts.dismissIfExists(); await PageObjects.dashboard.saveDashboard('area'); await PageObjects.dashboard.clickFullScreenMode(); diff --git a/test/functional/apps/discover/group1/_shared_links.ts b/test/functional/apps/discover/group1/_shared_links.ts index c6269cabfda98..a8d229b264f47 100644 --- a/test/functional/apps/discover/group1/_shared_links.ts +++ b/test/functional/apps/discover/group1/_shared_links.ts @@ -163,7 +163,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(resolvedTime.start).to.equal(actualTime.start); expect(resolvedTime.end).to.equal(actualTime.end); }); - await toasts.dismissAllToasts(); + await toasts.dismissAll(); }); it("sharing hashed url shouldn't crash the app", async () => { @@ -173,12 +173,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await browser.get(currentUrl, false); const resolvedUrl = await browser.getCurrentUrl(); expect(resolvedUrl).to.match(/discover/); - const { title } = await toasts.getErrorToast(1, true); + const { title } = await toasts.getErrorByIndex(1, true); expect(title).to.contain( 'Unable to completely restore the URL, be sure to use the share functionality.' ); }); - await toasts.dismissAllToasts(); + await toasts.dismissAll(); }); }); }); diff --git a/test/functional/apps/discover/group2/_data_grid_copy_to_clipboard.ts b/test/functional/apps/discover/group2/_data_grid_copy_to_clipboard.ts index 27d847f9c49ce..0a6f72d43ad72 100644 --- a/test/functional/apps/discover/group2/_data_grid_copy_to_clipboard.ts +++ b/test/functional/apps/discover/group2/_data_grid_copy_to_clipboard.ts @@ -57,8 +57,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ).to.be(true); } - expect(await toasts.getToastCount()).to.be(1); - await toasts.dismissAllToasts(); + expect(await toasts.getCount()).to.be(1); + await toasts.dismissAll(); await dataGrid.clickCopyColumnValues('_source'); @@ -68,8 +68,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(copiedSourceData.endsWith('}')).to.be(true); } - expect(await toasts.getToastCount()).to.be(1); - await toasts.dismissAllToasts(); + expect(await toasts.getCount()).to.be(1); + await toasts.dismissAll(); }); it('should be able to copy a column name to clipboard', async () => { @@ -82,8 +82,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(copiedTimestampName).to.be('@timestamp'); } - expect(await toasts.getToastCount()).to.be(1); - await toasts.dismissAllToasts(); + expect(await toasts.getCount()).to.be(1); + await toasts.dismissAll(); await dataGrid.clickCopyColumnName('_source'); @@ -92,8 +92,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(copiedSourceName).to.be('Document'); } - expect(await toasts.getToastCount()).to.be(1); - await toasts.dismissAllToasts(); + expect(await toasts.getCount()).to.be(1); + await toasts.dismissAll(); }); }); } diff --git a/test/functional/apps/discover/group4/_adhoc_data_views.ts b/test/functional/apps/discover/group4/_adhoc_data_views.ts index 2fe0167763687..f84b69d2184a1 100644 --- a/test/functional/apps/discover/group4/_adhoc_data_views.ts +++ b/test/functional/apps/discover/group4/_adhoc_data_views.ts @@ -255,12 +255,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const second = await PageObjects.discover.getCurrentDataViewId(); expect(first).not.equal(second); - await toasts.dismissAllToasts(); + await toasts.dismissAll(); await browser.goBack(); await PageObjects.header.waitUntilLoadingHasFinished(); - const [firstToast, secondToast] = await toasts.getAllToastElements(); + const [firstToast, secondToast] = await toasts.getAll(); expect([await firstToast.getVisibleText(), await secondToast.getVisibleText()].sort()).to.eql( [ diff --git a/test/functional/apps/management/data_views/_field_formatter.ts b/test/functional/apps/management/data_views/_field_formatter.ts index cddbe8ccf5ce4..9754bacee599f 100644 --- a/test/functional/apps/management/data_views/_field_formatter.ts +++ b/test/functional/apps/management/data_views/_field_formatter.ts @@ -521,7 +521,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.settings.controlChangeCancel(); } - await toasts.dismissAllToasts(); // dismiss "saved" toast, otherwise it could overlap save button for a next test + await toasts.dismissAll(); // dismiss "saved" toast, otherwise it could overlap save button for a next test }); specs.forEach((spec, index) => { diff --git a/test/functional/apps/management/data_views/_handle_not_found.ts b/test/functional/apps/management/data_views/_handle_not_found.ts index 1cc13ad4f85d0..74c4e86d17d00 100644 --- a/test/functional/apps/management/data_views/_handle_not_found.ts +++ b/test/functional/apps/management/data_views/_handle_not_found.ts @@ -29,7 +29,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); await testSubjects.existOrFail('noDataViewsPrompt'); - const { message } = await toasts.getErrorToast(); + const { message } = await toasts.getErrorByIndex(); expect(message).to.contain( 'The data view with id:111111111111 could not be loaded. Try creating a new one.' ); diff --git a/test/functional/apps/management/data_views/_handle_version_conflict.ts b/test/functional/apps/management/data_views/_handle_version_conflict.ts index bcbd81c48209f..140d4741943ce 100644 --- a/test/functional/apps/management/data_views/_handle_version_conflict.ts +++ b/test/functional/apps/management/data_views/_handle_version_conflict.ts @@ -28,6 +28,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const scriptedFiledName = 'versionConflictScript'; const PageObjects = getPageObjects(['common', 'home', 'settings', 'discover', 'header']); const log = getService('log'); + const toasts = getService('toasts'); describe('FOO index version conflict', function describeIndexTests() { before(async function () { @@ -62,7 +63,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.settings.setFieldFormat('url'); await PageObjects.settings.clickSaveScriptedField(); await retry.try(async function () { - const message = await PageObjects.common.closeToast(); + const message = await toasts.getTitleAndDismiss(); expect(message).to.contain('Unable'); }); }); @@ -95,7 +96,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(response.body.result).to.be('updated'); await PageObjects.settings.controlChangeSave(); await retry.try(async function () { - const message = await PageObjects.common.closeToast(); + const message = await toasts.getTitleAndDismiss(); expect(message).to.contain('Unable'); }); }); diff --git a/test/functional/page_objects/common_page.ts b/test/functional/page_objects/common_page.ts index 98ac4d0abfe04..eaa538537deed 100644 --- a/test/functional/page_objects/common_page.ts +++ b/test/functional/page_objects/common_page.ts @@ -480,39 +480,6 @@ export class CommonPageObject extends FtrService { }); } - async closeToast() { - const toast = await this.find.byCssSelector('.euiToast', 6 * this.defaultFindTimeout); - await toast.moveMouseTo(); - const title = await (await this.testSubjects.find('euiToastHeader__title')).getVisibleText(); - - await this.testSubjects.click('toastCloseButton'); - return title; - } - - async closeToastIfExists() { - const toastShown = await this.find.existsByCssSelector('.euiToast'); - if (toastShown) { - try { - await this.testSubjects.click('toastCloseButton'); - } catch (err) { - // ignore errors, toast clear themselves after timeout - } - } - } - - async clearAllToasts() { - const toasts = await this.find.allByCssSelector('.euiToast'); - for (const toastElement of toasts) { - try { - await toastElement.moveMouseTo(); - const closeBtn = await toastElement.findByTestSubject('toastCloseButton'); - await closeBtn.click(); - } catch (err) { - // ignore errors, toast clear themselves after timeout - } - } - } - async getJsonBodyText() { if (await this.find.existsByCssSelector('a[id=rawdata-tab]', this.defaultFindTimeout)) { // Firefox has 3 tabs and requires navigation to see Raw output diff --git a/test/functional/page_objects/dashboard_page.ts b/test/functional/page_objects/dashboard_page.ts index d17c12d8269d5..f5acc43f88273 100644 --- a/test/functional/page_objects/dashboard_page.ts +++ b/test/functional/page_objects/dashboard_page.ts @@ -45,6 +45,7 @@ export class DashboardPageObject extends FtrService { private readonly visualize = this.ctx.getPageObject('visualize'); private readonly discover = this.ctx.getPageObject('discover'); private readonly appsMenu = this.ctx.getService('appsMenu'); + private readonly toasts = this.ctx.getService('toasts'); private readonly logstashIndex = this.config.get('esTestCluster.ccs') ? 'ftr-remote:logstash-*' @@ -489,7 +490,7 @@ export class DashboardPageObject extends FtrService { // Confirm that the Dashboard has actually been saved await this.testSubjects.existOrFail('saveDashboardSuccess'); }); - const message = await this.common.closeToast(); + const message = await this.toasts.getTitleAndDismiss(); await this.header.waitUntilLoadingHasFinished(); await this.common.waitForSaveModalToClose(); diff --git a/test/functional/page_objects/home_page.ts b/test/functional/page_objects/home_page.ts index 61eb1f40c49e7..1901f12073438 100644 --- a/test/functional/page_objects/home_page.ts +++ b/test/functional/page_objects/home_page.ts @@ -14,6 +14,7 @@ export class HomePageObject extends FtrService { private readonly find = this.ctx.getService('find'); private readonly common = this.ctx.getPageObject('common'); public readonly log = this.ctx.getService('log'); + private readonly toasts = this.ctx.getService('toasts'); async clickSynopsis(title: string) { await this.testSubjects.click(`homeSynopsisLink${title}`); @@ -165,7 +166,7 @@ export class HomePageObject extends FtrService { async launchSampleDataSet(id: string) { await this.addSampleDataSet(id); - await this.common.closeToastIfExists(); + await this.toasts.dismissIfExists(); await this.retry.try(async () => { await this.testSubjects.click(`launchSampleDataSet${id}`); await this.find.byCssSelector( diff --git a/test/functional/page_objects/visualize_page.ts b/test/functional/page_objects/visualize_page.ts index e39c9ac3a679d..ceae95f637493 100644 --- a/test/functional/page_objects/visualize_page.ts +++ b/test/functional/page_objects/visualize_page.ts @@ -42,6 +42,7 @@ export class VisualizePageObject extends FtrService { private readonly header = this.ctx.getPageObject('header'); private readonly visEditor = this.ctx.getPageObject('visEditor'); private readonly visChart = this.ctx.getPageObject('visChart'); + private readonly toasts = this.ctx.getService('toasts'); index = { LOGSTASH_TIME_BASED: 'logstash-*', @@ -398,7 +399,7 @@ export class VisualizePageObject extends FtrService { // Confirm that the Visualization has actually been saved await this.testSubjects.existOrFail('saveVisualizationSuccess'); - const message = await this.common.closeToast(); + const message = await this.toasts.getTitleAndDismiss(); await this.header.waitUntilLoadingHasFinished(); await this.common.waitForSaveModalToClose(); diff --git a/test/functional/services/dashboard/add_panel.ts b/test/functional/services/dashboard/add_panel.ts index 5b16c6af9ca20..b5d835101b7a4 100644 --- a/test/functional/services/dashboard/add_panel.ts +++ b/test/functional/services/dashboard/add_panel.ts @@ -16,6 +16,7 @@ export class DashboardAddPanelService extends FtrService { private readonly header = this.ctx.getPageObject('header'); private readonly savedObjectsFinder = this.ctx.getService('savedObjectsFinder'); private readonly browser = this.ctx.getService('browser'); + private readonly toasts = this.ctx.getService('toasts'); async clickOpenAddPanel() { this.log.debug('DashboardAddPanel.clickOpenAddPanel'); @@ -95,7 +96,7 @@ export class DashboardAddPanelService extends FtrService { continue; } await button.click(); - await this.common.closeToastIfExists(); + embeddableList.push(name); } }); @@ -105,7 +106,7 @@ export class DashboardAddPanelService extends FtrService { async clickPagerNextButton() { // Clear all toasts that could hide pagination controls - await this.common.clearAllToasts(); + await this.toasts.dismissAll(); const addPanel = await this.testSubjects.find('dashboardAddPanel'); @@ -252,7 +253,7 @@ export class DashboardAddPanelService extends FtrService { } // close "Added successfully" toast - await this.common.clearAllToasts(); + await this.toasts.dismissAll(); return embeddableName; } diff --git a/test/functional/services/dashboard/dashboard_settings.ts b/test/functional/services/dashboard/dashboard_settings.ts index 0796444ea7189..5e99e3af360e0 100644 --- a/test/functional/services/dashboard/dashboard_settings.ts +++ b/test/functional/services/dashboard/dashboard_settings.ts @@ -109,7 +109,7 @@ export function DashboardSettingsProvider({ getService }: FtrProviderContext) { public async clickApplyButton(shouldClose: boolean = true) { log.debug('clickApplyButton'); await retry.try(async () => { - await toasts.dismissAllToasts(); + await toasts.dismissAll(); await testSubjects.click('applyCustomizeDashboardButton'); if (shouldClose) await this.expectDashboardSettingsFlyoutClosed(); }); @@ -118,7 +118,7 @@ export function DashboardSettingsProvider({ getService }: FtrProviderContext) { public async clickCancelButton() { log.debug('clickCancelButton'); await retry.try(async () => { - await toasts.dismissAllToasts(); + await toasts.dismissAll(); await testSubjects.click('cancelCustomizeDashboardButton'); await this.expectDashboardSettingsFlyoutClosed(); }); @@ -127,7 +127,7 @@ export function DashboardSettingsProvider({ getService }: FtrProviderContext) { public async clickCloseFlyoutButton() { log.debug(); await retry.try(async () => { - await toasts.dismissAllToasts(); + await toasts.dismissAll(); await (await this.findFlyoutTestSubject('euiFlyoutCloseButton')).click(); await this.expectDashboardSettingsFlyoutClosed(); }); diff --git a/test/functional/services/dashboard/panel_settings.ts b/test/functional/services/dashboard/panel_settings.ts index 11b817b176b6e..7927d513e6e71 100644 --- a/test/functional/services/dashboard/panel_settings.ts +++ b/test/functional/services/dashboard/panel_settings.ts @@ -151,7 +151,7 @@ export function DashboardCustomizePanelProvider({ getService, getPageObject }: F public async clickSaveButton() { log.debug('clickSaveButton'); await retry.try(async () => { - await toasts.dismissAllToasts(); + await toasts.dismissAll(); await testSubjects.click('saveCustomizePanelButton'); await testSubjects.waitForDeleted('saveCustomizePanelButton'); }); diff --git a/test/functional/services/index.ts b/test/functional/services/index.ts index e8b8fafc8852d..1966755f157ed 100644 --- a/test/functional/services/index.ts +++ b/test/functional/services/index.ts @@ -38,7 +38,6 @@ import { FieldEditorService } from './field_editor'; import { ManagementMenuService } from './management'; import { QueryBarService } from './query_bar'; import { RenderableService } from './renderable'; -import { ToastsService } from './toasts'; import { DataGridService } from './data_grid'; import { PieChartService, @@ -86,7 +85,6 @@ export const services = { vegaDebugInspector: VegaDebugInspectorViewService, appsMenu: AppsMenuService, globalNav: GlobalNavService, - toasts: ToastsService, savedQueryManagementComponent: SavedQueryManagementComponentService, elasticChart: ElasticChartService, supertest: KibanaSupertestProvider, diff --git a/test/functional/services/toasts.ts b/test/functional/services/toasts.ts deleted file mode 100644 index a4d3b2dd3e457..0000000000000 --- a/test/functional/services/toasts.ts +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import expect from '@kbn/expect'; -import { FtrService } from '../ftr_provider_context'; - -export class ToastsService extends FtrService { - private readonly testSubjects = this.ctx.getService('testSubjects'); - private readonly retry = this.ctx.getService('retry'); - - /** - * Returns the title and message of a specific error toast. - * This method is specific to toasts created via `.addError` since they contain - * an additional button, that should not be part of the message. - * - * @param index The index of the toast (1-based, NOT 0-based!) of the toast. Use first by default. - * @param titleOnly If this is true, only the title of the error message is returned. There are error messages that only contain a title, no message. - * @returns The title and message of the specified error toast.https://github.com/elastic/kibana/issues/17087 - */ - public async getErrorToast(index: number = 1, titleOnly: boolean = false) { - const toast = await this.getToastElement(index); - const titleElement = await this.testSubjects.findDescendant('euiToastHeader', toast); - const title: string = await titleElement.getVisibleText(); - if (titleOnly) { - return { title }; - } - const messageElement = await this.testSubjects.findDescendant('errorToastMessage', toast); - const message: string = await messageElement.getVisibleText(); - return { title, message }; - } - - /** - * Dismiss a specific toast from the toast list. Since toasts usually should time out themselves, - * you only need to call this for permanent toasts (e.g. error toasts). - * - * @param index The 1-based index of the toast to dismiss. Use first by default. - */ - public async dismissToast(index: number = 1) { - const toast = await this.getToastElement(index); - await toast.moveMouseTo(); - const dismissButton = await this.testSubjects.findDescendant('toastCloseButton', toast); - await dismissButton.click(); - } - - public async dismissAllToasts() { - const list = await this.getGlobalToastList(); - const toasts = await list.findAllByCssSelector(`.euiToast`); - - if (toasts.length === 0) return; - - for (const toast of toasts) { - await toast.moveMouseTo(); - - if (await this.testSubjects.descendantExists('toastCloseButton', toast)) { - try { - const dismissButton = await this.testSubjects.findDescendant('toastCloseButton', toast); - await dismissButton.click(); - } catch (err) { - // ignore errors - // toasts are finnicky because they can dismiss themselves right before you close them - } - } - } - } - - public async dismissAllToastsWithChecks() { - await this.retry.tryForTime(30 * 1000, async () => { - await this.dismissAllToasts(); - await this.assertToastCount(0); - }); - } - - public async assertToastCount(expectedCount: number) { - await this.retry.tryForTime(5 * 1000, async () => { - const toastCount = await this.getToastCount({ timeout: 1000 }); - expect(toastCount).to.eql( - expectedCount, - `Toast count should be ${expectedCount} (got ${toastCount})` - ); - }); - } - - public async getToastElement(index: number) { - const list = await this.getGlobalToastList(); - return await list.findByCssSelector(`.euiToast:nth-child(${index})`); - } - - public async getToastContent(index: number) { - const elem = await this.getToastElement(index); - return await elem.getVisibleText(); - } - - public async getAllToastElements() { - const list = await this.getGlobalToastList(); - return await list.findAllByCssSelector(`.euiToast`); - } - - private async getGlobalToastList(options?: { timeout?: number }) { - return await this.testSubjects.find('globalToastList', options?.timeout); - } - - public async getToastCount(options?: { timeout?: number }) { - const list = await this.getGlobalToastList(options); - const toasts = await list.findAllByCssSelector(`.euiToast`, options?.timeout); - return toasts.length; - } -} diff --git a/test/plugin_functional/test_suites/data_plugin/session.ts b/test/plugin_functional/test_suites/data_plugin/session.ts index 793e9f1ca2faa..824d8b36806ed 100644 --- a/test/plugin_functional/test_suites/data_plugin/session.ts +++ b/test/plugin_functional/test_suites/data_plugin/session.ts @@ -27,7 +27,7 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide const getSessionIds = async () => { const sessionsBtn = await testSubjects.find('showSessionsButton'); await sessionsBtn.click(); - const toast = await toasts.getToastElement(1); + const toast = await toasts.getElementByIndex(1); const sessionIds = await toast.getVisibleText(); return sessionIds.split(','); }; @@ -42,7 +42,7 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide afterEach(async () => { await testSubjects.click('clearSessionsButton'); - await toasts.dismissAllToasts(); + await toasts.dismissAll(); }); it('Starts on index pattern select', async () => { @@ -92,7 +92,7 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide afterEach(async () => { await testSubjects.click('clearSessionsButton'); - await toasts.dismissAllToasts(); + await toasts.dismissAll(); }); after(async () => { diff --git a/x-pack/test/accessibility/apps/group1/advanced_settings.ts b/x-pack/test/accessibility/apps/group1/advanced_settings.ts index 4515105d7557c..3d3a513daed35 100644 --- a/x-pack/test/accessibility/apps/group1/advanced_settings.ts +++ b/x-pack/test/accessibility/apps/group1/advanced_settings.ts @@ -20,42 +20,42 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { shouldUseHashForSubUrl: false, }); await testSubjects.click('settings'); - await toasts.dismissAllToasts(); + await toasts.dismissAll(); await a11y.testAppSnapshot(); }); // clicking on the top search bar it('adv settings - search ', async () => { await testSubjects.click('settingsSearchBar'); - await toasts.dismissAllToasts(); + await toasts.dismissAll(); await a11y.testAppSnapshot(); }); // clicking on the category dropdown it('adv settings - category -dropdown ', async () => { await testSubjects.click('settingsSearchBar'); - await toasts.dismissAllToasts(); + await toasts.dismissAll(); await a11y.testAppSnapshot(); }); // clicking on the toggle button it('adv settings - toggle ', async () => { await testSubjects.click('management-settings-editField-csv:quoteValues'); - await toasts.dismissAllToasts(); + await toasts.dismissAll(); await a11y.testAppSnapshot(); }); // clicking on editor panel it('adv settings - edit ', async () => { await testSubjects.click('management-settings-editField-csv:separator'); - await toasts.dismissAllToasts(); + await toasts.dismissAll(); await a11y.testAppSnapshot(); }); // clicking on save button it('adv settings - save', async () => { await testSubjects.click('settings-save-button'); - await toasts.dismissAllToasts(); + await toasts.dismissAll(); await a11y.testAppSnapshot(); }); }); diff --git a/x-pack/test/accessibility/apps/group1/dashboard_panel_options.ts b/x-pack/test/accessibility/apps/group1/dashboard_panel_options.ts index a5182a8d2ca03..f9909809e490a 100644 --- a/x-pack/test/accessibility/apps/group1/dashboard_panel_options.ts +++ b/x-pack/test/accessibility/apps/group1/dashboard_panel_options.ts @@ -105,7 +105,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.click('dashboardEditMode'); await dashboardPanelActions.toggleContextMenu(header); await testSubjects.click('embeddablePanelAction-clonePanel'); - await toasts.dismissAllToasts(); + await toasts.dismissAll(); await a11y.testAppSnapshot(); }); diff --git a/x-pack/test/accessibility/apps/group1/spaces.ts b/x-pack/test/accessibility/apps/group1/spaces.ts index 33616c3576b1d..5ec4b7c1ee644 100644 --- a/x-pack/test/accessibility/apps/group1/spaces.ts +++ b/x-pack/test/accessibility/apps/group1/spaces.ts @@ -42,7 +42,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('a11y test for manage spaces page', async () => { await PageObjects.spaceSelector.clickManageSpaces(); await PageObjects.header.waitUntilLoadingHasFinished(); - await toasts.dismissAllToasts(); + await toasts.dismissAll(); await retry.waitFor( 'Manage spaces page visible', async () => await testSubjects.exists('createSpace') diff --git a/x-pack/test/accessibility/apps/group1/uptime.ts b/x-pack/test/accessibility/apps/group1/uptime.ts index 3818ddb1061a2..03a38447ed845 100644 --- a/x-pack/test/accessibility/apps/group1/uptime.ts +++ b/x-pack/test/accessibility/apps/group1/uptime.ts @@ -61,7 +61,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('overview alert popover controls', async () => { await uptimeService.overview.openAlertsPopover(); - await toasts.dismissAllToasts(); + await toasts.dismissAll(); await a11y.testAppSnapshot(); }); diff --git a/x-pack/test/accessibility/apps/group3/rules_connectors.ts b/x-pack/test/accessibility/apps/group3/rules_connectors.ts index bf46735a84fde..019a23c8fc49d 100644 --- a/x-pack/test/accessibility/apps/group3/rules_connectors.ts +++ b/x-pack/test/accessibility/apps/group3/rules_connectors.ts @@ -52,7 +52,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); // https://github.com/elastic/kibana/issues/144953 it.skip('a11y test on save rule without connectors panel', async () => { - await toasts.dismissAllToasts(); + await toasts.dismissAll(); await testSubjects.click('saveRuleButton'); await a11y.testAppSnapshot(); }); diff --git a/x-pack/test/accessibility/apps/group3/security_solution.ts b/x-pack/test/accessibility/apps/group3/security_solution.ts index 7257f88be8a74..af62d92b345e1 100644 --- a/x-pack/test/accessibility/apps/group3/security_solution.ts +++ b/x-pack/test/accessibility/apps/group3/security_solution.ts @@ -33,7 +33,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Custom Query Rule', () => { describe('Define Step', () => { it('default view meets a11y requirements', async () => { - await toasts.dismissAllToasts(); + await toasts.dismissAll(); await testSubjects.click('customRuleType'); await a11y.testAppSnapshot(); }); diff --git a/x-pack/test/cloud_security_posture_functional/page_objects/findings_page.ts b/x-pack/test/cloud_security_posture_functional/page_objects/findings_page.ts index 5c42f0e9bf9ae..5b457c9ff7714 100644 --- a/x-pack/test/cloud_security_posture_functional/page_objects/findings_page.ts +++ b/x-pack/test/cloud_security_posture_functional/page_objects/findings_page.ts @@ -291,17 +291,6 @@ export function FindingsPageProvider({ getService, getPageObjects }: FtrProvider const misconfigurationsFlyout = createFlyoutObject('findings_flyout'); - const toastMessage = async (testSubj = 'csp:toast-success') => ({ - async getElement() { - return await testSubjects.find(testSubj); - }, - async clickToastMessageLink(linkTestSubj = 'csp:toast-success-link') { - const element = await this.getElement(); - const link = await element.findByTestSubject(linkTestSubj); - await link.click(); - }, - }); - const groupSelector = (testSubj = 'group-selector-dropdown') => ({ async getElement() { return await testSubjects.find(testSubj); @@ -360,7 +349,6 @@ export function FindingsPageProvider({ getService, getPageObjects }: FtrProvider distributionBar, vulnerabilityDataGrid, misconfigurationsFlyout, - toastMessage, detectionRuleApi, groupSelector, findingsGrouping, diff --git a/x-pack/test/cloud_security_posture_functional/pages/findings_alerts.ts b/x-pack/test/cloud_security_posture_functional/pages/findings_alerts.ts index 9b60c77c3ec15..5e4e812c88a8f 100644 --- a/x-pack/test/cloud_security_posture_functional/pages/findings_alerts.ts +++ b/x-pack/test/cloud_security_posture_functional/pages/findings_alerts.ts @@ -13,6 +13,7 @@ import type { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const retry = getService('retry'); + const toasts = getService('toasts'); const pageObjects = getPageObjects(['common', 'findings', 'header']); const chance = new Chance(); @@ -155,13 +156,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await misconfigurationsFlyout.getVisibleText('csp:findings-flyout-detection-rule-count') ).to.be('1 detection rule'); - const toastMessage = await (await findings.toastMessage()).getElement(); + const toastMessage = await (await toasts.toastMessageByTestSubj()).getElement(); expect(toastMessage).to.be.ok(); const toastMessageTitle = await toastMessage.findByTestSubject('csp:toast-success-title'); expect(await toastMessageTitle.getVisibleText()).to.be(ruleName1); - await (await findings.toastMessage()).clickToastMessageLink(); + await (await toasts.toastMessageByTestSubj()).clickToastMessageLink(); const rulePageTitle = await testSubjects.find('header-page-title'); expect(await rulePageTitle.getVisibleText()).to.be(ruleName1); @@ -182,13 +183,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await misconfigurationsFlyout.getVisibleText('csp:findings-flyout-detection-rule-count') ).to.be('1 detection rule'); - const toastMessage = await (await findings.toastMessage()).getElement(); + const toastMessage = await (await toasts.toastMessageByTestSubj()).getElement(); expect(toastMessage).to.be.ok(); const toastMessageTitle = await toastMessage.findByTestSubject('csp:toast-success-title'); expect(await toastMessageTitle.getVisibleText()).to.be(ruleName1); - await (await findings.toastMessage()).clickToastMessageLink(); + await (await toasts.toastMessageByTestSubj()).clickToastMessageLink(); const rulePageTitle = await testSubjects.find('header-page-title'); expect(await rulePageTitle.getVisibleText()).to.be(ruleName1); @@ -199,7 +200,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await latestFindingsTable.openFlyoutAt(0); await misconfigurationsFlyout.clickTakeActionCreateRuleButton(); - await (await findings.toastMessage()).clickToastMessageLink(); + await (await toasts.toastMessageByTestSubj()).clickToastMessageLink(); const rulePageDescription = await testSubjects.find( 'stepAboutRuleDetailsToggleDescriptionText' diff --git a/x-pack/test/examples/search_examples/search_example.ts b/x-pack/test/examples/search_examples/search_example.ts index 6dd9c6e125b18..a46739fb6b569 100644 --- a/x-pack/test/examples/search_examples/search_example.ts +++ b/x-pack/test/examples/search_examples/search_example.ts @@ -50,9 +50,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); beforeEach(async () => { - await toasts.dismissAllToasts(); + await toasts.dismissAll(); await retry.waitFor('toasts gone', async () => { - return (await toasts.getToastCount()) === 0; + return (await toasts.getCount()) === 0; }); }); @@ -85,10 +85,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should handle warnings', async () => { await testSubjects.click('searchWithWarning'); await retry.waitFor('', async () => { - const toastCount = await toasts.getToastCount(); + const toastCount = await toasts.getCount(); return toastCount > 1; }); - const warningToast = await toasts.getToastElement(2); + const warningToast = await toasts.getElementByIndex(2); const textEl = await warningToast.findByTestSubject('euiToastBody'); const text: string = await textEl.getVisibleText(); expect(text).to.contain('Watch out!'); diff --git a/x-pack/test/examples/search_examples/search_sessions_cache.ts b/x-pack/test/examples/search_examples/search_sessions_cache.ts index 44a72680c155d..04e5325f66738 100644 --- a/x-pack/test/examples/search_examples/search_sessions_cache.ts +++ b/x-pack/test/examples/search_examples/search_sessions_cache.ts @@ -17,12 +17,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const comboBox = getService('comboBox'); async function getExecutedAt() { - const toast = await toasts.getToastElement(1); + const toast = await toasts.getElementByIndex(1); const timeElem = await testSubjects.findDescendant('requestExecutedAt', toast); const text = await timeElem.getVisibleText(); - await toasts.dismissAllToasts(); + await toasts.dismissAll(); await retry.waitFor('toasts gone', async () => { - return (await toasts.getToastCount()) === 0; + return (await toasts.getCount()) === 0; }); return text; } diff --git a/x-pack/test/examples/search_examples/sql_search_example.ts b/x-pack/test/examples/search_examples/sql_search_example.ts index a51ea21ea36bd..fc31d15deb82c 100644 --- a/x-pack/test/examples/search_examples/sql_search_example.ts +++ b/x-pack/test/examples/search_examples/sql_search_example.ts @@ -36,7 +36,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { 'responseCodeBlock', `"logstash-2015.09.22"` ); - expect(await toasts.getToastCount()).to.be(0); + expect(await toasts.getCount()).to.be(0); }); }); } diff --git a/x-pack/test/functional/apps/dashboard/group3/drilldowns/dashboard_to_dashboard_drilldown.ts b/x-pack/test/functional/apps/dashboard/group3/drilldowns/dashboard_to_dashboard_drilldown.ts index deb5195040800..a8dd8c7aaa769 100644 --- a/x-pack/test/functional/apps/dashboard/group3/drilldowns/dashboard_to_dashboard_drilldown.ts +++ b/x-pack/test/functional/apps/dashboard/group3/drilldowns/dashboard_to_dashboard_drilldown.ts @@ -36,12 +36,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const security = getService('security'); const spaces = getService('spaces'); const elasticChart = getService('elasticChart'); + const toasts = getService('toasts'); const createDrilldown = async () => { await PageObjects.dashboard.gotoDashboardEditMode( dashboardDrilldownsManage.DASHBOARD_WITH_PIE_CHART_NAME ); - await PageObjects.common.clearAllToasts(); // toasts get in the way of bottom "Create drilldown" button in flyout + await toasts.dismissAll(); // toasts get in the way of bottom "Create drilldown" button in flyout // create drilldown await dashboardPanelActions.openContextMenu(); @@ -77,7 +78,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { controls: Array<{ field: string; type: string }> ) => { await PageObjects.dashboard.gotoDashboardEditMode(dashboardName); - await PageObjects.common.clearAllToasts(); // toasts get in the way of bottom "Save and close" button in create control flyout + await toasts.dismissAll(); // toasts get in the way of bottom "Save and close" button in create control flyout for (const control of controls) { await PageObjects.dashboardControls.createControl({ diff --git a/x-pack/test/functional/apps/discover/reporting.ts b/x-pack/test/functional/apps/discover/reporting.ts index 9f9a1e277cec8..78166fd85d22e 100644 --- a/x-pack/test/functional/apps/discover/reporting.ts +++ b/x-pack/test/functional/apps/discover/reporting.ts @@ -30,6 +30,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const filterBar = getService('filterBar'); const find = getService('find'); const testSubjects = getService('testSubjects'); + const toasts = getService('toasts'); const setFieldsFromSource = async (setValue: boolean) => { await kibanaServer.uiSettings.update({ 'discover:searchFieldsFromSource': setValue }); @@ -38,7 +39,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const getReport = async () => { // close any open notification toasts - await PageObjects.reporting.clearToastNotifications(); + await toasts.dismissAll(); await PageObjects.reporting.openCsvReportingPanel(); await PageObjects.reporting.clickGenerateReportButton(); diff --git a/x-pack/test/functional/apps/index_management/data_streams_tab/data_streams_tab.ts b/x-pack/test/functional/apps/index_management/data_streams_tab/data_streams_tab.ts index 4480063da220b..d680778adc523 100644 --- a/x-pack/test/functional/apps/index_management/data_streams_tab/data_streams_tab.ts +++ b/x-pack/test/functional/apps/index_management/data_streams_tab/data_streams_tab.ts @@ -106,7 +106,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('saveButton'); // Expect to see a success toast - const successToast = await toasts.getToastElement(1); + const successToast = await toasts.getElementByIndex(1); expect(await successToast.getVisibleText()).to.contain('Data retention updated'); }); @@ -124,7 +124,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('saveButton'); // Expect to see a success toast - const successToast = await toasts.getToastElement(1); + const successToast = await toasts.getElementByIndex(1); expect(await successToast.getVisibleText()).to.contain('Data retention disabled'); }); }); diff --git a/x-pack/test/functional/apps/index_management/enrich_policies_tab/enrich_policies_tab.ts b/x-pack/test/functional/apps/index_management/enrich_policies_tab/enrich_policies_tab.ts index ab626393a9578..aa7aa2764b7c0 100644 --- a/x-pack/test/functional/apps/index_management/enrich_policies_tab/enrich_policies_tab.ts +++ b/x-pack/test/functional/apps/index_management/enrich_policies_tab/enrich_policies_tab.ts @@ -90,7 +90,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await pageObjects.indexManagement.clickExecuteEnrichPolicyAt(0); await pageObjects.indexManagement.clickConfirmModalButton(); - const successToast = await toasts.getToastElement(1); + const successToast = await toasts.getElementByIndex(1); expect(await successToast.getVisibleText()).to.contain(`Executed ${ENRICH_POLICY_NAME}`); }); @@ -98,7 +98,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await pageObjects.indexManagement.clickDeleteEnrichPolicyAt(0); await pageObjects.indexManagement.clickConfirmModalButton(); - const successToast = await toasts.getToastElement(2); + const successToast = await toasts.getElementByIndex(2); expect(await successToast.getVisibleText()).to.contain(`Deleted ${ENRICH_POLICY_NAME}`); }); }); diff --git a/x-pack/test/functional/apps/lens/group6/annotations.ts b/x-pack/test/functional/apps/lens/group6/annotations.ts index cd9986b29ab03..66871edd593b5 100644 --- a/x-pack/test/functional/apps/lens/group6/annotations.ts +++ b/x-pack/test/functional/apps/lens/group6/annotations.ts @@ -155,7 +155,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.click('confirmSaveSavedObjectButton'); - const toastContents = await toastsService.getToastContent(1); + const toastContents = await toastsService.getContentByIndex(1); expect(toastContents).to.be( `Saved "${ANNOTATION_GROUP_TITLE}"\nView or manage in the annotation library.` diff --git a/x-pack/test/functional/apps/security/users.ts b/x-pack/test/functional/apps/security/users.ts index 1bf0e2eea4d70..e9711dc29c46b 100644 --- a/x-pack/test/functional/apps/security/users.ts +++ b/x-pack/test/functional/apps/security/users.ts @@ -159,11 +159,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('change password', () => { before(async () => { - await toasts.dismissAllToasts(); + await toasts.dismissAll(); }); afterEach(async () => { await PageObjects.security.submitUpdateUserForm(); - await toasts.dismissAllToasts(); + await toasts.dismissAll(); }); after(async () => { await PageObjects.security.forceLogout(); @@ -177,10 +177,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.security.updateUserPassword(optionalUser); await retry.waitFor('', async () => { - const toastCount = await toasts.getToastCount(); + const toastCount = await toasts.getCount(); return toastCount >= 1; }); - const successToast = await toasts.getToastElement(1); + const successToast = await toasts.getElementByIndex(1); expect(await successToast.getVisibleText()).to.be('Password successfully changed'); }); @@ -196,10 +196,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.security.updateUserPassword(optionalUser, true); await retry.waitFor('', async () => { - const toastCount = await toasts.getToastCount(); + const toastCount = await toasts.getCount(); return toastCount >= 1; }); - const successToast = await toasts.getToastElement(1); + const successToast = await toasts.getElementByIndex(1); expect(await successToast.getVisibleText()).to.be('Password successfully changed'); }); }); diff --git a/x-pack/test/functional/apps/user_profiles/user_profiles.ts b/x-pack/test/functional/apps/user_profiles/user_profiles.ts index a9f2f7a519502..cd41155707d68 100644 --- a/x-pack/test/functional/apps/user_profiles/user_profiles.ts +++ b/x-pack/test/functional/apps/user_profiles/user_profiles.ts @@ -8,8 +8,9 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; -export default ({ getPageObjects }: FtrProviderContext) => { +export default ({ getPageObjects, getService }: FtrProviderContext) => { const pageObjects = getPageObjects(['common', 'userProfiles', 'settings']); + const toasts = getService('toasts'); describe('User Profile Page', async () => { before(async () => {}); @@ -24,7 +25,7 @@ export default ({ getPageObjects }: FtrProviderContext) => { await pageObjects.userProfiles.saveUserProfileChanges(); - let toast = await pageObjects.common.closeToast(); + let toast = await toasts.getTitleAndDismiss(); expect(toast).to.be('Profile updated'); @@ -32,7 +33,7 @@ export default ({ getPageObjects }: FtrProviderContext) => { await pageObjects.userProfiles.saveUserProfileChanges(); - toast = await pageObjects.common.closeToast(); + toast = await toasts.getTitleAndDismiss(); expect(toast).to.be('Profile updated'); }); @@ -42,7 +43,7 @@ export default ({ getPageObjects }: FtrProviderContext) => { await pageObjects.userProfiles.saveUserProfileChanges(); - let toast = await pageObjects.common.closeToast(); + let toast = await toasts.getTitleAndDismiss(); expect(toast).to.be('Profile updated'); @@ -50,7 +51,7 @@ export default ({ getPageObjects }: FtrProviderContext) => { await pageObjects.userProfiles.saveUserProfileChanges(); - toast = await pageObjects.common.closeToast(); + toast = await toasts.getTitleAndDismiss(); expect(toast).to.be('Profile updated'); }); @@ -72,7 +73,7 @@ export default ({ getPageObjects }: FtrProviderContext) => { const submitButton = await pageObjects.userProfiles.getChangePasswordFormSubmitButton(); await submitButton.click(); - const initialToast = await pageObjects.common.closeToast(); + const initialToast = await toasts.getTitleAndDismiss(); expect(initialToast).to.be('Password successfully changed'); @@ -84,7 +85,7 @@ export default ({ getPageObjects }: FtrProviderContext) => { await submitButton.click(); - const resetToast = await pageObjects.common.closeToast(); + const resetToast = await toasts.getTitleAndDismiss(); expect(resetToast).to.be('Password successfully changed'); }); diff --git a/x-pack/test/functional/page_objects/observability_logs_explorer.ts b/x-pack/test/functional/page_objects/observability_logs_explorer.ts index baeff166b6c6c..270b233c9dca3 100644 --- a/x-pack/test/functional/page_objects/observability_logs_explorer.ts +++ b/x-pack/test/functional/page_objects/observability_logs_explorer.ts @@ -393,7 +393,7 @@ export function ObservabilityLogsExplorerPageObject({ }, async assertRestoreFailureToastExist() { - const successToast = await toasts.getToastElement(1); + const successToast = await toasts.getElementByIndex(1); expect(await successToast.getVisibleText()).to.contain('Error restoring state from URL'); }, diff --git a/x-pack/test/functional/page_objects/reporting_page.ts b/x-pack/test/functional/page_objects/reporting_page.ts index d4fbad898ecfa..1574a5b8df0ce 100644 --- a/x-pack/test/functional/page_objects/reporting_page.ts +++ b/x-pack/test/functional/page_objects/reporting_page.ts @@ -98,11 +98,6 @@ export class ReportingPageObject extends FtrService { await this.share.openShareMenuItem('PNG Reports'); } - async clearToastNotifications() { - const toasts = await this.testSubjects.findAll('toastCloseButton'); - await Promise.all(toasts.map(async (t) => await t.click())); - } - async getQueueReportError() { return await this.testSubjects.exists('errorToastMessage'); } diff --git a/x-pack/test/functional/services/cases/common.ts b/x-pack/test/functional/services/cases/common.ts index 4809fe4278814..d8bb1ffe7a286 100644 --- a/x-pack/test/functional/services/cases/common.ts +++ b/x-pack/test/functional/services/cases/common.ts @@ -94,7 +94,7 @@ export function CasesCommonServiceProvider({ getService, getPageObject }: FtrPro }, async expectToasterToContain(content: string) { - const toast = await toasts.getToastElement(1); + const toast = await toasts.getElementByIndex(1); expect(await toast.getVisibleText()).to.contain(content); }, diff --git a/x-pack/test/functional/services/ml/common_ui.ts b/x-pack/test/functional/services/ml/common_ui.ts index 63a1fdf17cf4f..98404c88b412e 100644 --- a/x-pack/test/functional/services/ml/common_ui.ts +++ b/x-pack/test/functional/services/ml/common_ui.ts @@ -389,15 +389,13 @@ export function MachineLearningCommonUIProvider({ async assertLastToastHeader(expectedHeader: string, timeout: number = 5000) { await retry.tryForTime(timeout, async () => { - const resultToast = await toasts.getToastElement(1); - const titleElement = await testSubjects.findDescendant('euiToastHeader', resultToast); - const title: string = await titleElement.getVisibleText(); + const title: string = await toasts.getTitleByIndex(1); expect(title).to.eql( expectedHeader, `Expected the toast header to equal "${expectedHeader}" (got "${title}")` ); }); - await toasts.dismissAllToasts(); + await toasts.dismissAll(); }, async ensureAllMenuPopoversClosed() { diff --git a/x-pack/test/functional/services/ml/stack_management_jobs.ts b/x-pack/test/functional/services/ml/stack_management_jobs.ts index 52b8e005ac94c..072cb26bd86a4 100644 --- a/x-pack/test/functional/services/ml/stack_management_jobs.ts +++ b/x-pack/test/functional/services/ml/stack_management_jobs.ts @@ -89,13 +89,10 @@ export function MachineLearningStackManagementJobsProvider({ }); // check and close success toast - const resultToast = await toasts.getToastElement(1); - const titleElement = await testSubjects.findDescendant('euiToastHeader', resultToast); - const title: string = await titleElement.getVisibleText(); + const title = await toasts.getTitleByIndex(1); expect(title).to.match(/^\d+ item[s]? synchronized$/); - const dismissButton = await testSubjects.findDescendant('toastCloseButton', resultToast); - await dismissButton.click(); + await toasts.dismissByIndex(1); }, async assertADJobRowSpaces(adJobId: string, expectedSpaces: string[]) { @@ -281,13 +278,10 @@ export function MachineLearningStackManagementJobsProvider({ }); // check and close success toast - const resultToast = await toasts.getToastElement(1); - const titleElement = await testSubjects.findDescendant('euiToastHeader', resultToast); - const title: string = await titleElement.getVisibleText(); + const title = await toasts.getTitleByIndex(1); expect(title).to.match(/^\d+ job[s]? successfully imported$/); - const dismissButton = await testSubjects.findDescendant('toastCloseButton', resultToast); - await dismissButton.click(); + await toasts.dismissByIndex(1); // check that the flyout is closed await testSubjects.missingOrFail('mlJobMgmtImportJobsFlyout', { timeout: 60 * 1000 }); @@ -349,12 +343,10 @@ export function MachineLearningStackManagementJobsProvider({ }); // check and close success toast - const resultToast = await toasts.getToastElement(1); - const titleElement = await testSubjects.findDescendant('euiToastHeader', resultToast); - const title: string = await titleElement.getVisibleText(); + const title = await toasts.getTitleByIndex(1); expect(title).to.match(/^Your file is downloading in the background$/); - await toasts.dismissAllToastsWithChecks(); + await toasts.dismissAllWithChecks(); // check that the flyout is closed await testSubjects.missingOrFail('mlJobMgmtExportJobsFlyout', { timeout: 60 * 1000 }); diff --git a/x-pack/test/functional/services/observability/alerts/common.ts b/x-pack/test/functional/services/observability/alerts/common.ts index c4df13d80f675..39edf24a96317 100644 --- a/x-pack/test/functional/services/observability/alerts/common.ts +++ b/x-pack/test/functional/services/observability/alerts/common.ts @@ -241,8 +241,8 @@ export function ObservabilityAlertsCommonProvider({ } // wait for a confirmation toast (the css index is 1-based) - await toasts.getToastElement(1); - await toasts.dismissAllToasts(); + await toasts.getElementByIndex(1); + await toasts.dismissAll(); }; const setWorkflowStatusFilter = retryOnStale.wrap(async (workflowStatus: WorkflowStatus) => { diff --git a/x-pack/test/functional/services/transform/wizard.ts b/x-pack/test/functional/services/transform/wizard.ts index 5e00904ab8a27..19cb6c15a9f56 100644 --- a/x-pack/test/functional/services/transform/wizard.ts +++ b/x-pack/test/functional/services/transform/wizard.ts @@ -1178,10 +1178,10 @@ export function TransformWizardProvider({ getService, getPageObjects }: FtrProvi }, async assertErrorToastsNotExist() { - const toastCount = await toasts.getToastCount(); + const toastCount = await toasts.getCount(); // Toast element index starts at 1, not 0 for (let toastIdx = 1; toastIdx < toastCount + 1; toastIdx++) { - const toast = await toasts.getToastElement(toastIdx); + const toast = await toasts.getElementByIndex(toastIdx); const isErrorToast = await toast.elementHasClass('euiToast--danger'); expect(isErrorToast).to.eql(false, `Expected toast message to be successful, got error.`); } diff --git a/x-pack/test/functional_with_es_ssl/apps/cases/group2/attachment_framework.ts b/x-pack/test/functional_with_es_ssl/apps/cases/group2/attachment_framework.ts index fc313fc502fd8..9c1c5395f667a 100644 --- a/x-pack/test/functional_with_es_ssl/apps/cases/group2/attachment_framework.ts +++ b/x-pack/test/functional_with_es_ssl/apps/cases/group2/attachment_framework.ts @@ -250,7 +250,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { */ await cases.create.createCase({ owner }); await cases.common.expectToasterToContain('has been updated'); - await toasts.dismissAllToastsWithChecks(); + await toasts.dismissAllWithChecks(); } const casesCreatedFromFlyout = await findCases({ supertest }); @@ -343,7 +343,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { await testSubjects.click(`cases-table-row-select-${currentCaseId}`); await cases.common.expectToasterToContain('has been updated'); - await toasts.dismissAllToastsWithChecks(); + await toasts.dismissAllWithChecks(); await ensureFirstCommentOwner(currentCaseId, owner); } }); @@ -406,7 +406,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { await cases.common.expectToasterToContain(`${caseTitle} has been updated`); await testSubjects.click('toaster-content-case-view-link'); - await toasts.dismissAllToastsWithChecks(); + await toasts.dismissAllWithChecks(); const title = await find.byCssSelector('[data-test-subj="editable-title-header-value"]'); expect(await title.getVisibleText()).toEqual(caseTitle); @@ -434,7 +434,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { await cases.common.expectToasterToContain(`${theCaseTitle} has been updated`); await testSubjects.click('toaster-content-case-view-link'); - await toasts.dismissAllToastsWithChecks(); + await toasts.dismissAllWithChecks(); const title = await find.byCssSelector('[data-test-subj="editable-title-header-value"]'); expect(await title.getVisibleText()).toEqual(theCaseTitle); diff --git a/x-pack/test/functional_with_es_ssl/apps/cases/group2/configure.ts b/x-pack/test/functional_with_es_ssl/apps/cases/group2/configure.ts index c61077c4583c8..7f016ee919a3f 100644 --- a/x-pack/test/functional_with_es_ssl/apps/cases/group2/configure.ts +++ b/x-pack/test/functional_with_es_ssl/apps/cases/group2/configure.ts @@ -36,9 +36,9 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { it('change closure option successfully', async () => { await cases.common.selectRadioGroupValue('closure-options-radio-group', 'close-by-pushing'); - const toast = await toasts.getToastElement(1); + const toast = await toasts.getElementByIndex(1); expect(await toast.getVisibleText()).to.be('Settings successfully updated'); - await toasts.dismissAllToasts(); + await toasts.dismissAll(); await cases.common.assertRadioGroupValue('closure-options-radio-group', 'close-by-pushing'); }); }); diff --git a/x-pack/test/functional_with_es_ssl/apps/cases/group2/list_view.ts b/x-pack/test/functional_with_es_ssl/apps/cases/group2/list_view.ts index 906e571941ff2..f1b4e4ea8485a 100644 --- a/x-pack/test/functional_with_es_ssl/apps/cases/group2/list_view.ts +++ b/x-pack/test/functional_with_es_ssl/apps/cases/group2/list_view.ts @@ -883,7 +883,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { describe('row actions', () => { afterEach(async () => { - await toasts.dismissAllToastsWithChecks(); + await toasts.dismissAllWithChecks(); }); describe('Status', () => { @@ -969,7 +969,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { describe('Column Selection', () => { afterEach(async () => { - await toasts.dismissAllToastsWithChecks(); + await toasts.dismissAllWithChecks(); }); before(async () => { diff --git a/x-pack/test/functional_with_es_ssl/apps/cases/group2/upgrade.ts b/x-pack/test/functional_with_es_ssl/apps/cases/group2/upgrade.ts index 8320ac9707e3a..cf1ea5512eaba 100644 --- a/x-pack/test/functional_with_es_ssl/apps/cases/group2/upgrade.ts +++ b/x-pack/test/functional_with_es_ssl/apps/cases/group2/upgrade.ts @@ -78,7 +78,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { }); it('does not show any error toasters', async () => { - expect(await toasts.getToastCount()).to.be(0); + expect(await toasts.getCount()).to.be(0); }); it('shows the title correctly', async () => { @@ -294,7 +294,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { }); it('does not show any error toasters', async () => { - expect(await toasts.getToastCount()).to.be(0); + expect(await toasts.getCount()).to.be(0); }); it('shows the title correctly', async () => { diff --git a/x-pack/test/functional_with_es_ssl/apps/discover_ml_uptime/discover/search_source_alert.ts b/x-pack/test/functional_with_es_ssl/apps/discover_ml_uptime/discover/search_source_alert.ts index bffa564fba774..3053f776aede7 100644 --- a/x-pack/test/functional_with_es_ssl/apps/discover_ml_uptime/discover/search_source_alert.ts +++ b/x-pack/test/functional_with_es_ssl/apps/discover_ml_uptime/discover/search_source_alert.ts @@ -254,10 +254,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const checkInitialRuleParamsState = async (dataView: string, isViewInApp = false) => { if (isViewInApp) { - expect(await toasts.getToastCount()).to.be(0); + expect(await toasts.getCount()).to.be(0); } else { - expect(await toasts.getToastCount()).to.be(1); - expect((await toasts.getToastContent(1)).startsWith('Displayed documents may vary')).to.be( + expect(await toasts.getCount()).to.be(1); + expect((await toasts.getContentByIndex(1)).startsWith('Displayed documents may vary')).to.be( true ); } @@ -271,7 +271,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }; const checkUpdatedRuleParamsState = async () => { - expect(await toasts.getToastCount()).to.be(0); + expect(await toasts.getCount()).to.be(0); const queryString = await queryBar.getQueryString(); const hasFilter = await filterBar.hasFilter('message.keyword', 'msg-1'); expect(queryString).to.be.equal('message:msg-1'); @@ -519,8 +519,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should not display results after data view removal on clicking viewInApp link', async () => { await clickViewInApp(RULE_NAME); - expect(await toasts.getToastCount()).to.be.equal(1); - const content = await toasts.getToastContent(1); + expect(await toasts.getCount()).to.be.equal(1); + const content = await toasts.getContentByIndex(1); expect(content).to.equal( `Error fetching search source\nCould not locate that data view (id: ${sourceDataViewId}), click here to re-create it` ); diff --git a/x-pack/test/functional_with_es_ssl/apps/discover_ml_uptime/uptime/alert_flyout.ts b/x-pack/test/functional_with_es_ssl/apps/discover_ml_uptime/uptime/alert_flyout.ts index b68ecb3c08d9e..25f77cb8d41ef 100644 --- a/x-pack/test/functional_with_es_ssl/apps/discover_ml_uptime/uptime/alert_flyout.ts +++ b/x-pack/test/functional_with_es_ssl/apps/discover_ml_uptime/uptime/alert_flyout.ts @@ -15,6 +15,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const pageObjects = getPageObjects(['common', 'uptime']); const supertest = getService('supertest'); const retry = getService('retry'); + const toasts = getService('toasts'); describe('overview page alert flyout controls', function () { const DEFAULT_DATE_START = 'Sep 10, 2019 @ 12:40:08.078'; @@ -86,7 +87,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { it('can save alert', async () => { await alerts.clickSaveRuleButton(ruleName); await alerts.clickSaveAlertsConfirmButton(); - await pageObjects.common.closeToast(); + await toasts.dismiss(); }); it('posts an alert, verifies its presence, and deletes the alert', async () => { @@ -171,7 +172,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { it('can save alert', async () => { await alerts.clickSaveRuleButton(alertId); await alerts.clickSaveAlertsConfirmButton(); - await pageObjects.common.closeToast(); + await toasts.dismiss(); }); it('has created a valid alert with expected parameters', async () => { diff --git a/x-pack/test/functional_with_es_ssl/apps/discover_ml_uptime/uptime/simple_down_alert.ts b/x-pack/test/functional_with_es_ssl/apps/discover_ml_uptime/uptime/simple_down_alert.ts index 98a4a09ee2b8a..e5efd66060e31 100644 --- a/x-pack/test/functional_with_es_ssl/apps/discover_ml_uptime/uptime/simple_down_alert.ts +++ b/x-pack/test/functional_with_es_ssl/apps/discover_ml_uptime/uptime/simple_down_alert.ts @@ -73,7 +73,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { }); it('displays relevant alert in list drawer', async () => { - await toasts.dismissAllToasts(); + await toasts.dismissAll(); await testSubjects.click(`xpack.synthetics.monitorList.${monitorId}.expandMonitorDetail`); await pageObjects.header.waitUntilLoadingHasFinished(); diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alert_create_flyout.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alert_create_flyout.ts index 30ece977d1641..5d11dd17695d0 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alert_create_flyout.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alert_create_flyout.ts @@ -20,6 +20,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const retry = getService('retry'); const browser = getService('browser'); const rules = getService('rules'); + const toasts = getService('toasts'); async function getAlertsByName(name: string) { const { @@ -143,7 +144,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.setValue('nameInput', slackConnectorName); await testSubjects.setValue('slackWebhookUrlInput', 'https://test.com'); await find.clickByCssSelector('[data-test-subj="saveActionButtonModal"]:not(disabled)'); - const createdConnectorToastTitle = await pageObjects.common.closeToast(); + const createdConnectorToastTitle = await toasts.getTitleAndDismiss(); expect(createdConnectorToastTitle).to.eql(`Created '${slackConnectorName}'`); await testSubjects.click('notifyWhenSelect'); await testSubjects.click('onThrottleInterval'); @@ -186,7 +187,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { ); await testSubjects.click('saveRuleButton'); - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql(`Created rule "${alertName}"`); await pageObjects.triggersActionsUI.searchAlerts(alertName); const searchResultsAfterSave = await pageObjects.triggersActionsUI.getAlertsList(); @@ -214,7 +215,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.setValue('nameInput', slackConnectorName); await testSubjects.setValue('slackWebhookUrlInput', 'https://test.com'); await find.clickByCssSelector('[data-test-subj="saveActionButtonModal"]:not(disabled)'); - const createdConnectorToastTitle = await pageObjects.common.closeToast(); + const createdConnectorToastTitle = await toasts.getTitleAndDismiss(); expect(createdConnectorToastTitle).to.eql(`Created '${slackConnectorName}'`); await testSubjects.setValue('messageTextArea', 'test message '); await ( @@ -236,7 +237,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('addNewActionConnectorActionGroup-1-option-other'); await testSubjects.click('saveRuleButton'); - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql(`Created rule "${alertName}"`); await pageObjects.triggersActionsUI.searchAlerts(alertName); const searchResultsAfterSave = await pageObjects.triggersActionsUI.getAlertsList(); @@ -267,7 +268,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('confirmRuleSaveModal > confirmModalConfirmButton'); await testSubjects.missingOrFail('confirmRuleSaveModal'); - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql(`Created rule "${alertName}"`); await new Promise((resolve) => setTimeout(resolve, 1000)); await pageObjects.triggersActionsUI.searchAlerts(alertName); diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors/general.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors/general.ts index 3f23faad58ce2..093c9c812c061 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors/general.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors/general.ts @@ -28,6 +28,7 @@ export default ({ getPageObjects, getPageObject, getService }: FtrProviderContex const supertest = getService('supertest'); let objectRemover: ObjectRemover; const browser = getService('browser'); + const toasts = getService('toasts'); describe('General connector functionality', function () { before(async () => { @@ -61,7 +62,7 @@ export default ({ getPageObjects, getPageObject, getService }: FtrProviderContex '[data-test-subj="create-connector-flyout-save-btn"]:not(disabled)' ); - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql(`Created '${connectorName}'`); await pageObjects.triggersActionsUI.searchConnectors(connectorName); @@ -102,7 +103,7 @@ export default ({ getPageObjects, getPageObject, getService }: FtrProviderContex '[data-test-subj="edit-connector-flyout-save-btn"]:not(disabled)' ); - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql(`Updated '${updatedConnectorName}'`); await testSubjects.click('euiFlyoutCloseButton'); @@ -228,7 +229,7 @@ export default ({ getPageObjects, getPageObject, getService }: FtrProviderContex await testSubjects.click('deleteIdsConfirmation > confirmModalConfirmButton'); await testSubjects.missingOrFail('deleteIdsConfirmation'); - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql('Deleted 1 connector'); await pageObjects.triggersActionsUI.searchConnectors(connectorName); @@ -259,7 +260,7 @@ export default ({ getPageObjects, getPageObject, getService }: FtrProviderContex await testSubjects.click('deleteIdsConfirmation > confirmModalConfirmButton'); await testSubjects.missingOrFail('deleteIdsConfirmation'); - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql('Deleted 1 connector'); await pageObjects.triggersActionsUI.searchConnectors(connectorName); diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors/opsgenie.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors/opsgenie.ts index 6b37fa90119ea..47490f2c52a4e 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors/opsgenie.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors/opsgenie.ts @@ -20,6 +20,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const actions = getService('actions'); const rules = getService('rules'); const browser = getService('browser'); + const toasts = getService('toasts'); let objectRemover: ObjectRemover; describe('Opsgenie', () => { @@ -45,7 +46,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { apiKey: 'apiKey', }); - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql(`Created '${connectorName}'`); await pageObjects.triggersActionsUI.searchConnectors(connectorName); @@ -80,7 +81,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { apiKey: 'apiKey', }); - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql(`Updated '${updatedConnectorName}'`); await testSubjects.click('euiFlyoutCloseButton'); diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors/slack.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors/slack.ts index 14dbc0db0c241..25243b838e583 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors/slack.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors/slack.ts @@ -18,6 +18,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const supertest = getService('supertest'); const actions = getService('actions'); const rules = getService('rules'); + const toasts = getService('toasts'); let objectRemover: ObjectRemover; describe('Slack', () => { @@ -52,7 +53,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { url: 'https://test.com', }); - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql(`Created '${connectorName}'`); await pageObjects.triggersActionsUI.searchConnectors(connectorName); @@ -80,7 +81,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { token: 'supersecrettoken', }); - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql(`Created '${connectorName}'`); await pageObjects.triggersActionsUI.searchConnectors(connectorName); @@ -166,7 +167,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { }, ]); - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql(`Created rule "${ruleName}"`); }); @@ -183,7 +184,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('saveRuleButton'); - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql('Failed to retrieve Slack channels list'); // We are not saving the rule yet as we currently have no way @@ -210,7 +211,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { // tags: '', // }, // ]); - // const toastTitle = await pageObjects.common.closeToast(); + // const toastTitle = await toasts.getTitleAndDismiss(); // expect(toastTitle).to.eql(`Created rule "${ruleName}"`); }); }); diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors/tines.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors/tines.ts index 87ce49d95e3da..048fda14996bd 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors/tines.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors/tines.ts @@ -29,6 +29,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const actions = getService('actions'); const browser = getService('browser'); const comboBox = getService('comboBox'); + const toasts = getService('toasts'); let objectRemover: ObjectRemover; let simulatorUrl: string; @@ -63,7 +64,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { token: 'apiToken', }); - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql(`Created '${connectorName}'`); await pageObjects.triggersActionsUI.searchConnectors(connectorName); @@ -99,7 +100,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { token: 'apiToken', }); - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql(`Updated '${updatedConnectorName}'`); await testSubjects.click('euiFlyoutCloseButton'); diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/details.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/details.ts index 0d7539c566e7e..a6b5af188c260 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/details.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/details.ts @@ -25,6 +25,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const supertest = getService('supertest'); const comboBox = getService('comboBox'); const objectRemover = new ObjectRemover(supertest); + const toasts = getService('toasts'); async function createConnectorManualCleanup(overwrites: Record = {}) { const { body: createdConnector } = await supertest @@ -382,7 +383,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await find.clickByCssSelector('[data-test-subj="saveEditedRuleButton"]:not(disabled)'); - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql(`Updated '${updatedRuleName}'`); await retry.tryForTime(30 * 1000, async () => { @@ -469,7 +470,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('deleteIdsConfirmation > confirmModalConfirmButton'); await testSubjects.missingOrFail('deleteIdsConfirmation'); - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql('Deleted 1 connector'); // Wait to ensure the table is finished loading @@ -546,7 +547,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('deleteIdsConfirmation > confirmModalConfirmButton'); await testSubjects.missingOrFail('deleteIdsConfirmation'); - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql('Deleted 1 connector'); // Wait to ensure the table is finished loading @@ -656,7 +657,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await find.clickByCssSelector('[data-test-subj="saveEditedRuleButton"]:not(disabled)'); - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql(`Updated '${updatedRuleName}'`); }); }); diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/maintenance_windows/maintenance_windows_table.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/maintenance_windows/maintenance_windows_table.ts index 6a23cc5486469..0b228be252ca3 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/maintenance_windows/maintenance_windows_table.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/maintenance_windows/maintenance_windows_table.ts @@ -15,6 +15,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const testSubjects = getService('testSubjects'); const pageObjects = getPageObjects(['common', 'maintenanceWindows', 'header']); const retry = getService('retry'); + const toasts = getService('toasts'); let objectRemover: ObjectRemover; const browser = getService('browser'); @@ -52,7 +53,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('confirmModalConfirmButton'); await retry.try(async () => { - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql(`Cancelled running maintenance window '${name}'`); }); @@ -85,7 +86,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('confirmModalConfirmButton'); await retry.try(async () => { - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql(`Archived maintenance window '${name}'`); }); @@ -116,7 +117,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('confirmModalConfirmButton'); await retry.try(async () => { - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql(`Cancelled and archived running maintenance window '${name}'`); }); @@ -149,7 +150,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('confirmModalConfirmButton'); await retry.try(async () => { - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql(`Archived maintenance window '${name}'`); }); @@ -164,7 +165,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('confirmModalConfirmButton'); await retry.try(async () => { - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql(`Unarchived maintenance window '${name}'`); }); diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/rules_list/bulk_actions.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/rules_list/bulk_actions.ts index 617429f3a23c9..4c545e20cb687 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/rules_list/bulk_actions.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/rules_list/bulk_actions.ts @@ -23,6 +23,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const supertest = getService('supertest'); const retry = getService('retry'); const objectRemover = new ObjectRemover(supertest); + const toasts = getService('toasts'); async function refreshAlertsList() { await testSubjects.click('logsTab'); @@ -60,7 +61,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('linkSnooze1h'); await retry.try(async () => { - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql('Updated snooze settings for 2 rules.'); }); @@ -99,7 +100,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('confirmModalConfirmButton'); await retry.try(async () => { - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql('Updated snooze settings for 2 rules.'); }); @@ -130,7 +131,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('scheduler-saveSchedule'); await retry.try(async () => { - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql('Updated snooze settings for 2 rules.'); }); @@ -169,7 +170,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('confirmModalConfirmButton'); await retry.try(async () => { - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql('Updated snooze settings for 2 rules.'); }); @@ -201,7 +202,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('confirmModalConfirmButton'); await retry.try(async () => { - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql('Updated API key for 1 rule.'); }); }); diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/rules_list/rules_list.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/rules_list/rules_list.ts index 7838ec24c50a3..e3324ccbc000a 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/rules_list/rules_list.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/rules_list/rules_list.ts @@ -27,6 +27,7 @@ export default ({ getPageObjects, getPageObject, getService }: FtrProviderContex const retry = getService('retry'); const header = getPageObject('header'); const objectRemover = new ObjectRemover(supertest); + const toasts = getService('toasts'); async function refreshAlertsList() { const existsClearFilter = await testSubjects.exists('rules-list-clear-filter'); @@ -346,7 +347,7 @@ export default ({ getPageObjects, getPageObject, getService }: FtrProviderContex await testSubjects.click('confirmModalConfirmButton'); await retry.try(async () => { - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql('Deleted 1 rule'); }); @@ -369,7 +370,7 @@ export default ({ getPageObjects, getPageObject, getService }: FtrProviderContex await header.waitUntilLoadingHasFinished(); await retry.try(async () => { - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql('Disabled 1 rule'); }); @@ -468,7 +469,7 @@ export default ({ getPageObjects, getPageObject, getService }: FtrProviderContex await testSubjects.click('confirmModalConfirmButton'); await retry.try(async () => { - const toastTitle = await pageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql('Deleted 1 rule'); }); diff --git a/x-pack/test/observability_ai_assistant_functional/tests/conversations/index.spec.ts b/x-pack/test/observability_ai_assistant_functional/tests/conversations/index.spec.ts index 66badaab026ab..119f29693cfcc 100644 --- a/x-pack/test/observability_ai_assistant_functional/tests/conversations/index.spec.ts +++ b/x-pack/test/observability_ai_assistant_functional/tests/conversations/index.spec.ts @@ -115,11 +115,11 @@ export default function ApiTest({ getService, getPageObjects }: FtrProviderConte ); await retry.waitFor('Connector created toast', async () => { - const count = await toasts.getToastCount(); + const count = await toasts.getCount(); return count > 0; }); - await toasts.dismissAllToasts(); + await toasts.dismissAll(); }); it('creates a connector', async () => { diff --git a/x-pack/test/screenshot_creation/apps/response_ops_docs/stack_connectors/ibm_resilient_connector.ts b/x-pack/test/screenshot_creation/apps/response_ops_docs/stack_connectors/ibm_resilient_connector.ts index 4ff2a98377dad..a950f1824b5af 100644 --- a/x-pack/test/screenshot_creation/apps/response_ops_docs/stack_connectors/ibm_resilient_connector.ts +++ b/x-pack/test/screenshot_creation/apps/response_ops_docs/stack_connectors/ibm_resilient_connector.ts @@ -18,6 +18,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const pageObjects = getPageObjects(['common', 'header']); const testSubjects = getService('testSubjects'); const kibanaServer = getService('kibanaServer'); + const toasts = getService('toasts'); let resilientSimulatorUrl: string = ''; let smallUrl: string; @@ -47,9 +48,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await commonScreenshots.takeScreenshot('resilient-connector', screenshotDirectories); await testSubjects.click('create-connector-flyout-save-test-btn'); // Close all toasts since it is unable to get incident types from example site - await pageObjects.common.clearAllToasts(); + await toasts.dismissAll(); await pageObjects.header.waitUntilLoadingHasFinished(); - await pageObjects.common.clearAllToasts(); + await toasts.dismissAll(); await commonScreenshots.takeScreenshot('resilient-params-test', screenshotDirectories); await testSubjects.click('euiFlyoutCloseButton'); }); diff --git a/x-pack/test/screenshot_creation/apps/response_ops_docs/stack_connectors/sentinelone_connector.ts b/x-pack/test/screenshot_creation/apps/response_ops_docs/stack_connectors/sentinelone_connector.ts index ced2d8e2e0260..537fc8e6b9163 100644 --- a/x-pack/test/screenshot_creation/apps/response_ops_docs/stack_connectors/sentinelone_connector.ts +++ b/x-pack/test/screenshot_creation/apps/response_ops_docs/stack_connectors/sentinelone_connector.ts @@ -18,6 +18,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const actions = getService('actions'); const kibanaServer = getService('kibanaServer'); const testSubjects = getService('testSubjects'); + const toasts = getService('toasts'); let simulatorUrl: string; let editSimulatorUrl: string; @@ -43,7 +44,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.setValue('secrets.token-input', 'tester'); await commonScreenshots.takeScreenshot('sentinelone-connector', screenshotDirectories); await testSubjects.click('create-connector-flyout-save-test-btn'); - await pageObjects.common.clearAllToasts(); + await toasts.dismissAll(); await commonScreenshots.takeScreenshot('sentinelone-params-test', screenshotDirectories); await testSubjects.click('euiFlyoutCloseButton'); }); diff --git a/x-pack/test/screenshot_creation/apps/response_ops_docs/stack_connectors/tines_connector.ts b/x-pack/test/screenshot_creation/apps/response_ops_docs/stack_connectors/tines_connector.ts index 6c399f4b1b9ec..83472abbc5693 100644 --- a/x-pack/test/screenshot_creation/apps/response_ops_docs/stack_connectors/tines_connector.ts +++ b/x-pack/test/screenshot_creation/apps/response_ops_docs/stack_connectors/tines_connector.ts @@ -18,6 +18,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const actions = getService('actions'); const kibanaServer = getService('kibanaServer'); const testSubjects = getService('testSubjects'); + const toasts = getService('toasts'); + let simulatorUrl: string; let editSimulatorUrl: string; @@ -44,7 +46,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.setValue('secrets.token-input', 'tester'); await commonScreenshots.takeScreenshot('tines-connector', screenshotDirectories); await testSubjects.click('create-connector-flyout-save-test-btn'); - await pageObjects.common.clearAllToasts(); + await toasts.dismissAll(); await commonScreenshots.takeScreenshot('tines-params-test', screenshotDirectories); await testSubjects.click('euiFlyoutCloseButton'); }); diff --git a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/save_search_session.ts b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/save_search_session.ts index 8f3cb7f3b8a8e..bb7f87dadc3a1 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/save_search_session.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/save_search_session.ts @@ -146,7 +146,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.header.waitUntilLoadingHasFinished(); await PageObjects.dashboard.waitForRenderComplete(); await searchSessions.expectState('restored'); - expect(await toasts.getToastCount()).to.be(0); // no session restoration related warnings + expect(await toasts.getCount()).to.be(0); // no session restoration related warnings }); }); }); diff --git a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/session_searches_integration.ts b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/session_searches_integration.ts index cffd9db8dd12b..0a6b4f0625e95 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/session_searches_integration.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/session_searches_integration.ts @@ -181,9 +181,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // Check that session is still loading await searchSessions.expectState('backgroundLoading'); await retry.waitFor('session restoration warnings related to other bucket', async () => { - return (await toasts.getToastCount()) === 1; + return (await toasts.getCount()) === 1; }); - await toasts.dismissAllToasts(); + await toasts.dismissAll(); // check that other bucket requested add to a session await searchSessions.openPopover(); @@ -194,7 +194,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(searchSessionItem.searchesCount).to.be(2); await searchSessionItem.view(); - expect(await toasts.getToastCount()).to.be(0); // there should be no warnings + expect(await toasts.getCount()).to.be(0); // there should be no warnings await searchSessions.expectState('restored', 20000); await dashboardExpect.noErrorEmbeddablesPresent(); diff --git a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/sessions_in_space.ts b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/sessions_in_space.ts index c5851c44365dc..79b98e4741e0d 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/sessions_in_space.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/sessions_in_space.ts @@ -68,7 +68,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // Check that session is restored await searchSessions.expectState('restored'); await dashboardExpect.noErrorEmbeddablesPresent(); - expect(await toasts.getToastCount()).to.be(0); // no session restoration related warnings + expect(await toasts.getCount()).to.be(0); // no session restoration related warnings }); }); describe('Disabled storing search sessions', () => { diff --git a/x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts b/x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts index 251290c6f4b5e..3f586ddc89856 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/discover/async_search.ts @@ -63,7 +63,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await PageObjects.header.waitUntilLoadingHasFinished(); await searchSessions.expectState('restored'); await testSubjects.existOrFail('discoverErrorCalloutTitle'); // expect error because of fake searchSessionId - await PageObjects.common.clearAllToasts(); + await toasts.dismissAll(); const searchSessionId1 = await getSearchSessionId(); expect(searchSessionId1).to.be(fakeSearchSessionId); await queryBar.clickQuerySubmitButton(); @@ -87,7 +87,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { // back navigation takes discover to fakeSearchSessionId which is in error state // clean up page to get out of error state before proceeding to next test - await PageObjects.common.clearAllToasts(); + await toasts.dismissAll(); await queryBar.clickQuerySubmitButton(); await PageObjects.header.waitUntilLoadingHasFinished(); }); @@ -128,7 +128,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await PageObjects.header.waitUntilLoadingHasFinished(); await searchSessions.expectState('restored'); expect(await PageObjects.discover.hasNoResults()).to.be(true); - expect(await toasts.getToastCount()).to.be(0); // no session restoration related warnings + expect(await toasts.getCount()).to.be(0); // no session restoration related warnings await PageObjects.searchSessionsManagement.goTo(); const searchSessionListAfterRestore = await PageObjects.searchSessionsManagement.getList(); diff --git a/x-pack/test/search_sessions_integration/tests/apps/discover/sessions_in_space.ts b/x-pack/test/search_sessions_integration/tests/apps/discover/sessions_in_space.ts index 1bb691629a63e..6c6228aa0056f 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/discover/sessions_in_space.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/discover/sessions_in_space.ts @@ -71,7 +71,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // Check that session is restored await searchSessions.expectState('restored'); - expect(await toasts.getToastCount()).to.be(0); // no session restoration related warnings + expect(await toasts.getCount()).to.be(0); // no session restoration related warnings }); }); describe('Disabled storing search sessions in space', () => { diff --git a/x-pack/test/security_functional/tests/login_selector/basic_functionality.ts b/x-pack/test/security_functional/tests/login_selector/basic_functionality.ts index b3d3b58568f49..727edd341a65f 100644 --- a/x-pack/test/security_functional/tests/login_selector/basic_functionality.ts +++ b/x-pack/test/security_functional/tests/login_selector/basic_functionality.ts @@ -15,6 +15,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const security = getService('security'); const deployment = getService('deployment'); const PageObjects = getPageObjects(['security', 'common']); + const toasts = getService('toasts'); describe('Basic functionality', function () { this.tags('includeFirefox'); @@ -154,7 +155,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should show toast with error if SSO fails', async () => { await PageObjects.security.loginSelector.selectLoginMethod('saml', 'unknown_saml'); - const toastTitle = await PageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql('Could not perform login.'); await PageObjects.security.loginSelector.verifyLoginSelectorIsVisible(); @@ -163,7 +164,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should show toast with error if anonymous login fails', async () => { await PageObjects.security.loginSelector.selectLoginMethod('anonymous', 'anonymous1'); - const toastTitle = await PageObjects.common.closeToast(); + const toastTitle = await toasts.getTitleAndDismiss(); expect(toastTitle).to.eql('Could not perform login.'); await PageObjects.security.loginSelector.verifyLoginSelectorIsVisible(); diff --git a/x-pack/test/security_solution_endpoint/apps/integrations/artifact_entries_list.ts b/x-pack/test/security_solution_endpoint/apps/integrations/artifact_entries_list.ts index b1ee0897fd0b0..cb759ed015a20 100644 --- a/x-pack/test/security_solution_endpoint/apps/integrations/artifact_entries_list.ts +++ b/x-pack/test/security_solution_endpoint/apps/integrations/artifact_entries_list.ts @@ -36,6 +36,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const esClient = getService('es'); const supertest = getService('supertest'); const find = getService('find'); + const toasts = getService('toasts'); const policyTestResources = getService('policyTestResources'); const unzipPromisify = promisify(unzip); @@ -241,7 +242,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { checkResult.value ); } - await pageObjects.common.closeToast(); + await toasts.dismiss(); // Title is shown after adding an item expect(await testSubjects.getVisibleText('header-page-title')).to.equal(testData.title); @@ -275,7 +276,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { ); } - await pageObjects.common.closeToast(); + await toasts.dismiss(); // Title still shown after editing an item expect(await testSubjects.getVisibleText('header-page-title')).to.equal(testData.title); @@ -333,7 +334,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { policyId: firstPolicy.packagePolicy.id, suffix: firstSuffix, }); - await pageObjects.common.closeToast(); + await toasts.dismiss(); // Create second trusted app await createArtifact(testData, { @@ -341,11 +342,11 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { suffix: secondSuffix, createButton: 'pageAddButton', }); - await pageObjects.common.closeToast(); + await toasts.dismiss(); // Create third trusted app await createArtifact(testData, { suffix: thirdSuffix, createButton: 'pageAddButton' }); - await pageObjects.common.closeToast(); + await toasts.dismiss(); // Checks if fleet artifact has been updated correctly await checkFleetArtifacts( diff --git a/x-pack/test/security_solution_endpoint/apps/integrations/endpoint_exceptions.ts b/x-pack/test/security_solution_endpoint/apps/integrations/endpoint_exceptions.ts index dd927c68593dd..23b5b4f058152 100644 --- a/x-pack/test/security_solution_endpoint/apps/integrations/endpoint_exceptions.ts +++ b/x-pack/test/security_solution_endpoint/apps/integrations/endpoint_exceptions.ts @@ -27,6 +27,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const find = getService('find'); const unzipPromisify = promisify(unzip); const comboBox = getService('comboBox'); + const toasts = getService('toasts'); describe('Endpoint Exceptions', function () { targetTags(this, ['@ess', '@serverless']); @@ -172,7 +173,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await setLastEntry({ field: 'process.executable', operator: 'matches', value: 'ex*' }); await testSubjects.click('addExceptionConfirmButton'); - await pageObjects.common.closeToast(); + await toasts.dismiss(); await checkArtifact({ entries: [ @@ -216,7 +217,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await setLastEntry({ field: 'process.executable', operator: 'is', value: 'something' }); await testSubjects.click('addExceptionConfirmButton'); - await pageObjects.common.closeToast(); + await toasts.dismiss(); await checkArtifact({ entries: [ diff --git a/x-pack/test/security_solution_endpoint/apps/integrations/trusted_apps_list.ts b/x-pack/test/security_solution_endpoint/apps/integrations/trusted_apps_list.ts index e00dde08d58fb..9bef272a010a2 100644 --- a/x-pack/test/security_solution_endpoint/apps/integrations/trusted_apps_list.ts +++ b/x-pack/test/security_solution_endpoint/apps/integrations/trusted_apps_list.ts @@ -15,6 +15,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const testSubjects = getService('testSubjects'); const browser = getService('browser'); const endpointTestResources = getService('endpointTestResources'); + const toasts = getService('toasts'); describe('When on the Trusted Apps list', function () { targetTags(this, ['@ess', '@serverless']); @@ -48,7 +49,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { ).to.equal( 'AND process.hash.*IS a4370c0cf81686c0b696fa6261c9d3e0d810ae704ab8301839dffd5d5112f476' ); - await pageObjects.common.closeToast(); + await toasts.dismiss(); // Title is shown after adding an item expect(await testSubjects.getVisibleText('header-page-title')).to.equal( diff --git a/x-pack/test/security_solution_endpoint/page_objects/policy_page.ts b/x-pack/test/security_solution_endpoint/page_objects/policy_page.ts index f2b6452245135..34f376d55b103 100644 --- a/x-pack/test/security_solution_endpoint/page_objects/policy_page.ts +++ b/x-pack/test/security_solution_endpoint/page_objects/policy_page.ts @@ -13,6 +13,7 @@ export function EndpointPolicyPageProvider({ getService, getPageObjects }: FtrPr const pageObjects = getPageObjects(['common', 'header']); const testSubjects = getService('testSubjects'); const retryService = getService('retry'); + const toasts = getService('toasts'); const formTestSubj = getPolicySettingsFormTestSubjects(); return { @@ -111,7 +112,7 @@ export function EndpointPolicyPageProvider({ getService, getPageObjects }: FtrPr // which are displayed using one or more Toast messages. This in turn prevents the user from // actually clicking the Save button. Because those errors are not associated with Policy details, // we'll first check that all toasts are cleared - await pageObjects.common.clearAllToasts(); + await toasts.dismissAll(); await testSubjects.click('policyDetailsSaveButton'); await testSubjects.existOrFail('policyDetailsConfirmModal'); diff --git a/x-pack/test_serverless/functional/test_suites/common/discover/group2/_adhoc_data_views.ts b/x-pack/test_serverless/functional/test_suites/common/discover/group2/_adhoc_data_views.ts index b27001a396bb6..192014d40f2b8 100644 --- a/x-pack/test_serverless/functional/test_suites/common/discover/group2/_adhoc_data_views.ts +++ b/x-pack/test_serverless/functional/test_suites/common/discover/group2/_adhoc_data_views.ts @@ -260,12 +260,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const second = await PageObjects.discover.getCurrentDataViewId(); expect(first).not.equal(second); - await toasts.dismissAllToasts(); + await toasts.dismissAll(); await browser.goBack(); await PageObjects.header.waitUntilLoadingHasFinished(); - const [firstToast, secondToast] = await toasts.getAllToastElements(); + const [firstToast, secondToast] = await toasts.getAll(); expect([await firstToast.getVisibleText(), await secondToast.getVisibleText()].sort()).to.eql( [ diff --git a/x-pack/test_serverless/functional/test_suites/common/discover/x_pack/reporting.ts b/x-pack/test_serverless/functional/test_suites/common/discover/x_pack/reporting.ts index 620bf876cb9a9..e7e32c3c94dde 100644 --- a/x-pack/test_serverless/functional/test_suites/common/discover/x_pack/reporting.ts +++ b/x-pack/test_serverless/functional/test_suites/common/discover/x_pack/reporting.ts @@ -29,6 +29,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const filterBar = getService('filterBar'); const find = getService('find'); const testSubjects = getService('testSubjects'); + const toasts = getService('toasts'); const setFieldsFromSource = async (setValue: boolean) => { await kibanaServer.uiSettings.update({ 'discover:searchFieldsFromSource': setValue }); @@ -37,7 +38,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const getReport = async () => { // close any open notification toasts - await PageObjects.reporting.clearToastNotifications(); + await toasts.dismissAll(); await PageObjects.reporting.openCsvReportingPanel(); await PageObjects.reporting.clickGenerateReportButton(); diff --git a/x-pack/test_serverless/functional/test_suites/common/discover_ml_uptime/discover/search_source_alert.ts b/x-pack/test_serverless/functional/test_suites/common/discover_ml_uptime/discover/search_source_alert.ts index 25ae3eb08af48..1a82e4b73b2be 100644 --- a/x-pack/test_serverless/functional/test_suites/common/discover_ml_uptime/discover/search_source_alert.ts +++ b/x-pack/test_serverless/functional/test_suites/common/discover_ml_uptime/discover/search_source_alert.ts @@ -290,10 +290,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const checkInitialRuleParamsState = async (dataView: string, isViewInApp = false) => { if (isViewInApp) { - expect(await toasts.getToastCount()).to.be(0); + expect(await toasts.getCount()).to.be(0); } else { - expect(await toasts.getToastCount()).to.be(1); - expect((await toasts.getToastContent(1)).startsWith('Displayed documents may vary')).to.be( + expect(await toasts.getCount()).to.be(1); + expect((await toasts.getContentByIndex(1)).startsWith('Displayed documents may vary')).to.be( true ); } @@ -307,7 +307,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }; const checkUpdatedRuleParamsState = async () => { - expect(await toasts.getToastCount()).to.be(0); + expect(await toasts.getCount()).to.be(0); const queryString = await queryBar.getQueryString(); const hasFilter = await filterBar.hasFilter('message.keyword', 'msg-1'); expect(queryString).to.be.equal('message:msg-1'); @@ -569,8 +569,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it('should not display results after data view removal on clicking viewInApp link', async () => { await clickViewInApp(RULE_NAME); - expect(await toasts.getToastCount()).to.be.equal(1); - const content = await toasts.getToastContent(1); + expect(await toasts.getCount()).to.be.equal(1); + const content = await toasts.getContentByIndex(1); expect(content).to.equal( `Error fetching search source\nCould not locate that data view (id: ${sourceDataViewId}), click here to re-create it` ); diff --git a/x-pack/test_serverless/functional/test_suites/common/examples/search/warnings.ts b/x-pack/test_serverless/functional/test_suites/common/examples/search/warnings.ts index 43b6c6c086717..50b1f7f16f244 100644 --- a/x-pack/test_serverless/functional/test_suites/common/examples/search/warnings.ts +++ b/x-pack/test_serverless/functional/test_suites/common/examples/search/warnings.ts @@ -8,13 +8,11 @@ import type { estypes } from '@elastic/elasticsearch'; import expect from '@kbn/expect'; import assert from 'assert'; -import type { WebElementWrapper } from '@kbn/ftr-common-functional-ui-services'; import type { FtrProviderContext } from '../../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const PageObjects = getPageObjects(['common', 'timePicker', 'svlCommonPage']); const testSubjects = getService('testSubjects'); - const find = getService('find'); const retry = getService('retry'); const es = getService('es'); const log = getService('log'); @@ -23,6 +21,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const esArchiver = getService('esArchiver'); const monacoEditor = getService('monacoEditor'); + const toasts = getService('toasts'); describe('handling warnings with search source fetch', function () { const dataViewTitle = 'sample-01,sample-01-rollup'; @@ -32,7 +31,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const testIndex = 'sample-01'; const testRollupIndex = 'sample-01-rollup'; const testRollupField = 'kubernetes.container.memory.usage.bytes'; - const toastsSelector = '[data-test-subj=globalToastList] [data-test-subj=euiToastHeader]'; const shardFailureType = 'unsupported_aggregation_on_downsampled_index'; const shardFailureReason = `Field [${testRollupField}] of type [aggregate_metric_double] is not supported for aggregation [percentiles]`; @@ -96,15 +94,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); afterEach(async () => { - await PageObjects.common.clearAllToasts(); + await toasts.dismissAll(); }); it('should show search warnings as toasts', async () => { await testSubjects.click('searchSourceWithOther'); await retry.try(async () => { - const toasts = await find.allByCssSelector(toastsSelector); - expect(toasts.length).to.be(2); + expect(await toasts.getCount()).to.be(2); await testSubjects.click('viewWarningBtn'); }); @@ -151,10 +148,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.click('searchSourceWithoutOther'); // wait for toasts - toasts appear after the response is rendered - let toasts: WebElementWrapper[] = []; await retry.try(async () => { - toasts = await find.allByCssSelector(toastsSelector); - expect(toasts.length).to.be(2); + expect(await toasts.getCount()).to.be(2); }); // warnings tab diff --git a/x-pack/test_serverless/functional/test_suites/common/examples/search_examples/search_example.ts b/x-pack/test_serverless/functional/test_suites/common/examples/search_examples/search_example.ts index a07e823b57972..f2cbf39d96e5f 100644 --- a/x-pack/test_serverless/functional/test_suites/common/examples/search_examples/search_example.ts +++ b/x-pack/test_serverless/functional/test_suites/common/examples/search_examples/search_example.ts @@ -53,9 +53,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); beforeEach(async () => { - await toasts.dismissAllToasts(); + await toasts.dismissAll(); await retry.waitFor('toasts gone', async () => { - return (await toasts.getToastCount()) === 0; + return (await toasts.getCount()) === 0; }); }); @@ -90,10 +90,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { it.skip('should handle warnings', async () => { await testSubjects.click('searchWithWarning'); await retry.waitFor('', async () => { - const toastCount = await toasts.getToastCount(); + const toastCount = await toasts.getCount(); return toastCount > 1; }); - const warningToast = await toasts.getToastElement(2); + const warningToast = await toasts.getElementByIndex(2); const textEl = await warningToast.findByTestSubject('euiToastBody'); const text: string = await textEl.getVisibleText(); expect(text).to.contain('Watch out!'); diff --git a/x-pack/test_serverless/functional/test_suites/common/management/index_management/data_streams.ts b/x-pack/test_serverless/functional/test_suites/common/management/index_management/data_streams.ts index 4a92df7d90f39..4223decc869c6 100644 --- a/x-pack/test_serverless/functional/test_suites/common/management/index_management/data_streams.ts +++ b/x-pack/test_serverless/functional/test_suites/common/management/index_management/data_streams.ts @@ -115,7 +115,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('saveButton'); // Expect to see a success toast - const successToast = await toasts.getToastElement(1); + const successToast = await toasts.getElementByIndex(1); expect(await successToast.getVisibleText()).to.contain('Data retention updated'); }); @@ -133,7 +133,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('saveButton'); // Expect to see a success toast - const successToast = await toasts.getToastElement(1); + const successToast = await toasts.getElementByIndex(1); expect(await successToast.getVisibleText()).to.contain('Data retention disabled'); }); }); diff --git a/x-pack/test_serverless/functional/test_suites/observability/cases/attachment_framework.ts b/x-pack/test_serverless/functional/test_suites/observability/cases/attachment_framework.ts index 18cf4d4ebfc93..a06bbf97d8f34 100644 --- a/x-pack/test_serverless/functional/test_suites/observability/cases/attachment_framework.ts +++ b/x-pack/test_serverless/functional/test_suites/observability/cases/attachment_framework.ts @@ -72,7 +72,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { await cases.common.expectToasterToContain(`${caseTitle} has been updated`); await testSubjects.click('toaster-content-case-view-link'); - await toasts.dismissAllToastsWithChecks(); + await toasts.dismissAllWithChecks(); if (await testSubjects.exists('appLeaveConfirmModal')) { await testSubjects.exists('confirmModalConfirmButton'); @@ -106,7 +106,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { await cases.common.expectToasterToContain(`${theCaseTitle} has been updated`); await testSubjects.click('toaster-content-case-view-link'); - await toasts.dismissAllToastsWithChecks(); + await toasts.dismissAllWithChecks(); if (await testSubjects.exists('appLeaveConfirmModal')) { await testSubjects.exists('confirmModalConfirmButton'); diff --git a/x-pack/test_serverless/functional/test_suites/observability/cases/configure.ts b/x-pack/test_serverless/functional/test_suites/observability/cases/configure.ts index 63cc955cfb4d0..7b56c069fec5d 100644 --- a/x-pack/test_serverless/functional/test_suites/observability/cases/configure.ts +++ b/x-pack/test_serverless/functional/test_suites/observability/cases/configure.ts @@ -52,9 +52,9 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { it('change closure option successfully', async () => { await cases.common.selectRadioGroupValue('closure-options-radio-group', 'close-by-pushing'); - const toast = await toasts.getToastElement(1); + const toast = await toasts.getElementByIndex(1); expect(await toast.getVisibleText()).to.be('Settings successfully updated'); - await toasts.dismissAllToasts(); + await toasts.dismissAll(); }); }); diff --git a/x-pack/test_serverless/functional/test_suites/observability/rules/rules_list.ts b/x-pack/test_serverless/functional/test_suites/observability/rules/rules_list.ts index 2ebb4395bf317..fa7fd21328b03 100644 --- a/x-pack/test_serverless/functional/test_suites/observability/rules/rules_list.ts +++ b/x-pack/test_serverless/functional/test_suites/observability/rules/rules_list.ts @@ -368,7 +368,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { await testSubjects.click('confirmModalConfirmButton'); await retry.try(async () => { - const resultToast = await toasts.getToastElement(1); + const resultToast = await toasts.getElementByIndex(1); const toastText = await resultToast.getVisibleText(); expect(toastText).toEqual('Deleted 1 rule'); }); @@ -396,7 +396,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { await header.waitUntilLoadingHasFinished(); await retry.try(async () => { - const resultToast = await toasts.getToastElement(1); + const resultToast = await toasts.getElementByIndex(1); const toastText = await resultToast.getVisibleText(); expect(toastText).toEqual('Disabled 1 rule'); }); @@ -484,7 +484,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { await testSubjects.click('confirmModalConfirmButton'); await retry.try(async () => { - const resultToast = await toasts.getToastElement(1); + const resultToast = await toasts.getElementByIndex(1); const toastText = await resultToast.getVisibleText(); expect(toastText).toEqual('Deleted 1 rule'); }); @@ -937,7 +937,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { '[data-test-subj="rulesListNotifyBadge-snoozed"]:not(.euiButton-isDisabled)' ); await retry.try(async () => { - const resultToast = await toasts.getToastElement(1); + const resultToast = await toasts.getElementByIndex(1); const toastText = await resultToast.getVisibleText(); expect(toastText).toEqual('Rules notification successfully unsnoozed'); }); diff --git a/x-pack/test_serverless/functional/test_suites/search/rules/rule_details.ts b/x-pack/test_serverless/functional/test_suites/search/rules/rule_details.ts index 4ca9268618f1d..6d859406f3786 100644 --- a/x-pack/test_serverless/functional/test_suites/search/rules/rule_details.ts +++ b/x-pack/test_serverless/functional/test_suites/search/rules/rule_details.ts @@ -298,7 +298,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { await find.clickByCssSelector('[data-test-subj="saveEditedRuleButton"]:not(disabled)'); await retry.try(async () => { - const resultToast = await toasts.getToastElement(1); + const resultToast = await toasts.getElementByIndex(1); const toastText = await resultToast.getVisibleText(); expect(toastText).toEqual(`Updated '${updatedRuleName}'`); }); @@ -407,7 +407,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { await deleteConnector(connector1.name); await retry.try(async () => { - const resultToast = await toasts.getToastElement(1); + const resultToast = await toasts.getElementByIndex(1); const toastText = await resultToast.getVisibleText(); expect(toastText).toEqual('Deleted 1 connector'); }); @@ -484,7 +484,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { await deleteConnector(connector.name); await retry.try(async () => { - const resultToast = await toasts.getToastElement(1); + const resultToast = await toasts.getElementByIndex(1); const toastText = await resultToast.getVisibleText(); expect(toastText).toEqual('Deleted 1 connector'); }); @@ -618,7 +618,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { await find.clickByCssSelector('[data-test-subj="saveEditedRuleButton"]:not(disabled)'); await retry.try(async () => { - const resultToast = await toasts.getToastElement(1); + const resultToast = await toasts.getElementByIndex(1); const toastText = await resultToast.getVisibleText(); expect(toastText).toEqual(`Updated '${updatedRuleName}'`); }); diff --git a/x-pack/test_serverless/functional/test_suites/security/ftr/cases/attachment_framework.ts b/x-pack/test_serverless/functional/test_suites/security/ftr/cases/attachment_framework.ts index 39973a9eed08d..85a78cef48a86 100644 --- a/x-pack/test_serverless/functional/test_suites/security/ftr/cases/attachment_framework.ts +++ b/x-pack/test_serverless/functional/test_suites/security/ftr/cases/attachment_framework.ts @@ -65,7 +65,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { await cases.common.expectToasterToContain(`${caseTitle} has been updated`); await testSubjects.click('toaster-content-case-view-link'); - await toasts.dismissAllToastsWithChecks(); + await toasts.dismissAllWithChecks(); if (await testSubjects.exists('appLeaveConfirmModal')) { await testSubjects.exists('confirmModalConfirmButton'); @@ -104,7 +104,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { await cases.common.expectToasterToContain(`${theCaseTitle} has been updated`); await testSubjects.click('toaster-content-case-view-link'); - await toasts.dismissAllToastsWithChecks(); + await toasts.dismissAllWithChecks(); if (await testSubjects.exists('appLeaveConfirmModal')) { await testSubjects.exists('confirmModalConfirmButton'); diff --git a/x-pack/test_serverless/functional/test_suites/security/ftr/cases/configure.ts b/x-pack/test_serverless/functional/test_suites/security/ftr/cases/configure.ts index fe14d0f9aef4c..bd36f8f7a8ea1 100644 --- a/x-pack/test_serverless/functional/test_suites/security/ftr/cases/configure.ts +++ b/x-pack/test_serverless/functional/test_suites/security/ftr/cases/configure.ts @@ -52,9 +52,9 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { it('change closure option successfully', async () => { await cases.common.selectRadioGroupValue('closure-options-radio-group', 'close-by-pushing'); - const toast = await toasts.getToastElement(1); + const toast = await toasts.getElementByIndex(1); expect(await toast.getVisibleText()).to.be('Settings successfully updated'); - await toasts.dismissAllToasts(); + await toasts.dismissAll(); }); });