-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into editable-required-fields
- Loading branch information
Showing
10 changed files
with
90 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
x-pack/plugins/embeddable_enhanced/public/get_dynamic_actions_state.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { SerializedEvent } from '@kbn/ui-actions-enhanced-plugin/common/types'; | ||
import { getDynamicActionsState } from './get_dynamic_actions_state'; | ||
|
||
describe('getDynamicActionsState', () => { | ||
test('should return empty state when enhancements is undefined', () => { | ||
expect(getDynamicActionsState()).toEqual({ dynamicActions: { events: [] } }); | ||
}); | ||
|
||
test('should return empty state when enhancements is empty object', () => { | ||
expect(getDynamicActionsState({})).toEqual({ dynamicActions: { events: [] } }); | ||
}); | ||
|
||
test('should return empty state when enhancements.dynamicActions is undefined', () => { | ||
expect(getDynamicActionsState({ dynamicActions: undefined })).toEqual({ | ||
dynamicActions: { events: [] }, | ||
}); | ||
}); | ||
|
||
test('should return empty state when enhancements.dynamicActions is empty object', () => { | ||
expect(getDynamicActionsState({ dynamicActions: {} })).toEqual({ | ||
dynamicActions: { events: [] }, | ||
}); | ||
}); | ||
|
||
test('should return state when enhancements.dynamicActions is provided', () => { | ||
expect( | ||
getDynamicActionsState({ dynamicActions: { events: [{} as unknown as SerializedEvent] } }) | ||
).toEqual({ dynamicActions: { events: [{}] } }); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
x-pack/plugins/embeddable_enhanced/public/get_dynamic_actions_state.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { DynamicActionsState } from '@kbn/ui-actions-enhanced-plugin/public'; | ||
|
||
export function getDynamicActionsState(enhancements?: { | ||
dynamicActions?: Partial<DynamicActionsState>; | ||
}) { | ||
return { | ||
dynamicActions: { | ||
events: [], | ||
...(enhancements?.dynamicActions ?? {}), | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters