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

Closes https://github.com/elastic/kibana/issues/168029

flaky test runner
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3447

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Nathan Reese 2023-10-11 08:31:06 -06:00 committed by GitHub
parent 91cdbe2d35
commit f088e55fdd
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);
}
}