mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[ML] Functional tests - stabilize export job tests (#156586)
This PR stabilizes the export job tests by making sure the export success toast is closed before moving on to the next test. As part of that, the toasts service got two new methods `dismissAllToastsWithChecks` and `assertToastCount`.
This commit is contained in:
parent
2f53207727
commit
dd1fd2647a
2 changed files with 25 additions and 7 deletions
|
@ -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.
|
||||
|
@ -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})`);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue