[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>
This commit is contained in:
Tre 2024-02-14 09:24:20 +00:00 committed by GitHub
parent 9f7ed8861d
commit 986116133f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
92 changed files with 405 additions and 400 deletions

View file

@ -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,
};

View file

@ -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<WebElementWrapper> {
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<void> {
const toast = await this.getElementByIndex(index);
await toast.moveMouseTo();
const dismissButton = await this.testSubjects.findDescendant('toastCloseButton', toast);
await dismissButton.click();
}
public async dismissIfExists(): Promise<void> {
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<string> {
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<void> {
await this.testSubjects.click('toastCloseButton', 6 * this.defaultFindTimeout);
}
public async dismissAll(): Promise<void> {
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<void> {
await this.retry.tryForTime(30 * 1000, async (): Promise<void> => {
await this.dismissAll();
await this.assertCount(0);
});
}
public async assertCount(expectedCount: number): Promise<void> {
await this.retry.tryForTime(5 * 1000, async (): Promise<void> => {
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<WebElementWrapper> {
return await (await this.getGlobalList()).findByCssSelector(`.euiToast:nth-child(${index})`);
}
public async getTitleByIndex(index: number): Promise<string> {
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<string> {
const elem = await this.getElementByIndex(index);
return await elem.getVisibleText();
}
public async getAll(): Promise<WebElementWrapper[]> {
const list = await this.getGlobalList();
return await list.findAllByCssSelector(`.euiToast`);
}
private async getGlobalList(options?: { timeout?: number }): Promise<WebElementWrapper> {
return await this.testSubjects.find('globalToastList', options?.timeout);
}
public async getCount(options?: { timeout?: number }): Promise<number> {
const list = await this.getGlobalList(options);
const toasts = await list.findAllByCssSelector(`.euiToast`, options?.timeout);
return toasts.length;
}
}

View file

@ -12,6 +12,7 @@
"@kbn/repo-info",
"@kbn/test-subj-selector",
"@kbn/ftr-common-functional-services",
"@kbn/std"
"@kbn/std",
"@kbn/expect"
]
}

View file

@ -154,7 +154,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
await retry.try(async () => {
await toasts.dismissAllToasts();
await toasts.dismissAll();
});
await a11y.testAppSnapshot();

View file

@ -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

View file

@ -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')) {

View file

@ -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);
});
});
});

View file

@ -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();
});

View file

@ -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();

View file

@ -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();
});
});
});

View file

@ -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();
});
});
}

View file

@ -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(
[

View file

@ -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) => {

View file

@ -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.'
);

View file

@ -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');
});
});

View file

@ -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

View file

@ -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();

View file

@ -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(

View file

@ -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();

View file

@ -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;
}

View file

@ -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();
});

View file

@ -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');
});

View file

@ -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,

View file

@ -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;
}
}

View file

@ -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 () => {

View file

@ -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();
});
});

View file

@ -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();
});

View file

@ -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')

View file

@ -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();
});

View file

@ -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();
});

View file

@ -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();
});

View file

@ -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,

View file

@ -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'

View file

@ -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!');

View file

@ -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;
}

View file

@ -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);
});
});
}

View file

@ -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({

View file

@ -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();

View file

@ -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');
});
});

View file

@ -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}`);
});
});

View file

@ -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.`

View file

@ -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');
});
});

View file

@ -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');
});

View file

@ -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');
},

View file

@ -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');
}

View file

@ -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);
},

View file

@ -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() {

View file

@ -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 });

View file

@ -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) => {

View file

@ -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.`);
}

View file

@ -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);

View file

@ -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');
});
});

View file

@ -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 () => {

View file

@ -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 () => {

View file

@ -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`
);

View file

@ -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 () => {

View file

@ -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();

View file

@ -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);

View file

@ -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);

View file

@ -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');

View file

@ -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}"`);
});
});

View file

@ -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');

View file

@ -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<string, any> = {}) {
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}'`);
});
});

View file

@ -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}'`);
});

View file

@ -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.');
});
});

View file

@ -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');
});

View file

@ -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 () => {

View file

@ -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 = '<could not determine kibana url>';
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');
});

View file

@ -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');
});

View file

@ -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');
});

View file

@ -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
});
});
});

View file

@ -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();

View file

@ -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', () => {

View file

@ -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();

View file

@ -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', () => {

View file

@ -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();

View file

@ -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(

View file

@ -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: [

View file

@ -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(

View file

@ -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');

View file

@ -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(
[

View file

@ -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();

View file

@ -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`
);

View file

@ -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

View file

@ -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!');

View file

@ -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');
});
});

View file

@ -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');

View file

@ -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();
});
});

View file

@ -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');
});

View file

@ -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}'`);
});

View file

@ -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');

View file

@ -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();
});
});