mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
# Backport This will backport the following commits from `main` to `8.8`: - [[ML] Functional tests - stabilize export job tests (#156586)](https://github.com/elastic/kibana/pull/156586) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Robert Oskamp","email":"robert.oskamp@elastic.co"},"sourceCommit":{"committedDate":"2023-05-05T07:17:04Z","message":"[ML] Functional tests - stabilize export job tests (#156586)\n\nThis PR stabilizes the export job tests by making sure the export\r\nsuccess toast is closed before moving on to the next test. As part of\r\nthat, the toasts service got two new methods\r\n`dismissAllToastsWithChecks` and `assertToastCount`.","sha":"dd1fd2647a453fe9ad233d3afc9848b507c945da","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":[":ml","release_note:skip","backport:prev-minor","v8.8.0","v8.9.0"],"number":156586,"url":"https://github.com/elastic/kibana/pull/156586","mergeCommit":{"message":"[ML] Functional tests - stabilize export job tests (#156586)\n\nThis PR stabilizes the export job tests by making sure the export\r\nsuccess toast is closed before moving on to the next test. As part of\r\nthat, the toasts service got two new methods\r\n`dismissAllToastsWithChecks` and `assertToastCount`.","sha":"dd1fd2647a453fe9ad233d3afc9848b507c945da"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"8.8","label":"v8.8.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/156586","number":156586,"mergeCommit":{"message":"[ML] Functional tests - stabilize export job tests (#156586)\n\nThis PR stabilizes the export job tests by making sure the export\r\nsuccess toast is closed before moving on to the next test. As part of\r\nthat, the toasts service got two new methods\r\n`dismissAllToastsWithChecks` and `assertToastCount`.","sha":"dd1fd2647a453fe9ad233d3afc9848b507c945da"}}]}] BACKPORT--> Co-authored-by: Robert Oskamp <robert.oskamp@elastic.co>
This commit is contained in:
parent
d762daa21b
commit
36d827ad1d
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