Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions test/functional/services/toasts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
* 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.
Expand Down Expand Up @@ -62,6 +64,23 @@ export class ToastsService extends FtrService {
}
}

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})`);
Expand All @@ -77,13 +96,13 @@ export class ToastsService extends FtrService {
return await list.findAllByCssSelector(`.euiToast`);
}

private async getGlobalToastList() {
return await this.testSubjects.find('globalToastList');
private async getGlobalToastList(options?: { timeout?: number }) {
return await this.testSubjects.find('globalToastList', options?.timeout);
}

public async getToastCount() {
const list = await this.getGlobalToastList();
const toasts = await list.findAllByCssSelector(`.euiToast`);
public async getToastCount(options?: { timeout?: number }) {
const list = await this.getGlobalToastList(options);
const toasts = await list.findAllByCssSelector(`.euiToast`, options?.timeout);
return toasts.length;
}
}
3 changes: 1 addition & 2 deletions x-pack/test/functional/services/ml/stack_management_jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,7 @@ export function MachineLearningStackManagementJobsProvider({
const title: string = await titleElement.getVisibleText();
expect(title).to.match(/^Your file is downloading in the background$/);

const dismissButton = await testSubjects.findDescendant('toastCloseButton', resultToast);
await dismissButton.click();
await toasts.dismissAllToastsWithChecks();

// check that the flyout is closed
await testSubjects.missingOrFail('mlJobMgmtExportJobsFlyout', { timeout: 60 * 1000 });
Expand Down