diff --git a/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.test.ts b/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.test.ts index 5c1165dc68c5de..639633852e4474 100644 --- a/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.test.ts +++ b/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.test.ts @@ -59,6 +59,16 @@ test('returns undefined when provided validation function returns redireted', as expect(dashboard).toBeUndefined(); }); +test('does not get initial input when provided validation function returns redireted', async () => { + const creationOptions: DashboardCreationOptions = { + validateLoadedSavedObject: jest.fn().mockImplementation(() => 'redirected'), + getInitialInput: jest.fn(), + }; + const dashboard = await createDashboard(creationOptions, 0, 'test-id'); + expect(dashboard).toBeUndefined(); + expect(creationOptions.getInitialInput).not.toHaveBeenCalled(); +}); + test('pulls state from dashboard saved object when given a saved object id', async () => { pluginServices.getServices().dashboardContentManagement.loadDashboardState = jest .fn() diff --git a/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts b/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts index a595bca8c1841c..753b881e5a94ef 100644 --- a/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts +++ b/src/plugins/dashboard/public/dashboard_container/embeddable/create/create_dashboard.ts @@ -137,7 +137,6 @@ export const initializeDashboard = async ({ useUnifiedSearchIntegration, useSessionStorageIntegration, } = creationOptions ?? {}; - const overrideInput = getInitialInput?.(); // -------------------------------------------------------------------------------------- // Run validation. @@ -161,6 +160,7 @@ export const initializeDashboard = async ({ // -------------------------------------------------------------------------------------- // Combine input from saved object, session storage, & passed input to create initial input. // -------------------------------------------------------------------------------------- + const overrideInput = getInitialInput?.(); const initialInput: DashboardContainerInput = cloneDeep({ ...DEFAULT_DASHBOARD_INPUT, ...(loadDashboardReturn?.dashboardInput ?? {}),