Skip to content

Commit

Permalink
load state from URL after dashboard SO load and validation
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomThomson committed Aug 10, 2023
1 parent ca9b4d0 commit bf0ecc5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Expand Up @@ -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()
Expand Down
Expand Up @@ -137,7 +137,6 @@ export const initializeDashboard = async ({
useUnifiedSearchIntegration,
useSessionStorageIntegration,
} = creationOptions ?? {};
const overrideInput = getInitialInput?.();

// --------------------------------------------------------------------------------------
// Run validation.
Expand All @@ -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 ?? {}),
Expand Down

0 comments on commit bf0ecc5

Please sign in to comment.