diff --git a/test/functional/page_objects/time_to_visualize_page.ts b/test/functional/page_objects/time_to_visualize_page.ts index 9ff567fcb4ef3..ac8a4414eaa30 100644 --- a/test/functional/page_objects/time_to_visualize_page.ts +++ b/test/functional/page_objects/time_to_visualize_page.ts @@ -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); } }