[8.11] fix flaky test Chrome X-Pack UI Functional Tests.x-pack/test/functional/apps/maps/group2/embeddable/add_to_dashboard·js (#168500) (#168615)

# Backport

This will backport the following commits from `main` to `8.11`:
- [fix flaky test Chrome X-Pack UI Functional
Tests.x-pack/test/functional/apps/maps/group2/embeddable/add_to_dashboard·js
(#168500)](https://github.com/elastic/kibana/pull/168500)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Nathan
Reese","email":"reese.nathan@elastic.co"},"sourceCommit":{"committedDate":"2023-10-11T14:31:06Z","message":"fix
flaky test Chrome X-Pack UI Functional
Tests.x-pack/test/functional/apps/maps/group2/embeddable/add_to_dashboard·js
(#168500)\n\nCloses
https://github.com/elastic/kibana/issues/168029\r\n\r\nflaky test
runner\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3447\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"f088e55fdde2066f2d5f4fa528d382112b6320f8","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Presentation","release_note:skip","v8.11.0","v8.12.0"],"number":168500,"url":"https://github.com/elastic/kibana/pull/168500","mergeCommit":{"message":"fix
flaky test Chrome X-Pack UI Functional
Tests.x-pack/test/functional/apps/maps/group2/embeddable/add_to_dashboard·js
(#168500)\n\nCloses
https://github.com/elastic/kibana/issues/168029\r\n\r\nflaky test
runner\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3447\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"f088e55fdde2066f2d5f4fa528d382112b6320f8"}},"sourceBranch":"main","suggestedTargetBranches":["8.11"],"targetPullRequestStates":[{"branch":"8.11","label":"v8.11.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/168500","number":168500,"mergeCommit":{"message":"fix
flaky test Chrome X-Pack UI Functional
Tests.x-pack/test/functional/apps/maps/group2/embeddable/add_to_dashboard·js
(#168500)\n\nCloses
https://github.com/elastic/kibana/issues/168029\r\n\r\nflaky test
runner\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3447\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"f088e55fdde2066f2d5f4fa528d382112b6320f8"}}]}]
BACKPORT-->

Co-authored-by: Nathan Reese <reese.nathan@elastic.co>
This commit is contained in:
Kibana Machine 2023-10-11 11:50:05 -04:00 committed by GitHub
parent 0e06567fd3
commit f12738f365
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,6 +27,7 @@ export class TimeToVisualizePageObject extends FtrService {
private readonly find = this.ctx.getService('find');
private readonly common = this.ctx.getPageObject('common');
private readonly dashboard = this.ctx.getPageObject('dashboard');
private readonly retry = this.ctx.getService('retry');
public async ensureSaveModalIsOpen() {
await this.testSubjects.exists('savedObjectSaveModal', { timeout: 5000 });
@ -47,6 +48,21 @@ export class TimeToVisualizePageObject extends FtrService {
await this.dashboard.clickNewDashboard(false);
}
private async selectDashboard(dashboardId: string) {
await this.retry.try(async () => {
await this.testSubjects.waitForEnabled('open-dashboard-picker');
await this.testSubjects.click('open-dashboard-picker');
await this.testSubjects.setValue('dashboard-picker-search', dashboardId);
await this.common.sleep(150); // wait for input debounce so loading starts
await this.testSubjects.waitForEnabled('open-dashboard-picker');
await this.testSubjects.click(`dashboard-picker-option-${dashboardId.replaceAll(' ', '-')}`);
const dashboardPickerLabel = await this.testSubjects.getVisibleText('open-dashboard-picker');
if (dashboardPickerLabel === 'Select dashboard') {
throw new Error(`Dashboard not selected`);
}
});
}
public async setSaveModalValues(
vizName: string,
{ saveAsNew, redirectToOrigin, addToDashboard, dashboardId, saveToLibrary }: SaveModalArgs = {}
@ -75,14 +91,7 @@ export class TimeToVisualizePageObject extends FtrService {
await label.click();
if (dashboardId) {
await this.testSubjects.waitForEnabled('open-dashboard-picker');
await this.testSubjects.click('open-dashboard-picker');
await this.testSubjects.setValue('dashboard-picker-search', dashboardId);
await this.common.sleep(150); // wait for input debounce so loading starts
await this.testSubjects.waitForEnabled('open-dashboard-picker');
await this.testSubjects.click(
`dashboard-picker-option-${dashboardId.replaceAll(' ', '-')}`
);
await this.selectDashboard(dashboardId);
}
}