Skip to content

Commit

Permalink
Various bug fixes and unit tests for AssociatedDetectors (opensearch-…
Browse files Browse the repository at this point in the history
…project#505)

* associated detectors unit tests

Signed-off-by: Amit Galitzky <[email protected]>

* fixed some bugs and added unit tests for associated detectors

Signed-off-by: Amit Galitzky <[email protected]>

---------

Signed-off-by: Amit Galitzky <[email protected]>
  • Loading branch information
amitgalitz committed Jul 7, 2023
1 parent f3266b8 commit 1470204
Show file tree
Hide file tree
Showing 8 changed files with 417 additions and 19 deletions.
17 changes: 9 additions & 8 deletions public/action/ad_dashboard_action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import {
} from '../../../../src/plugins/ui_actions/public';
import { isReferenceOrValueEmbeddable } from '../../../../src/plugins/embeddable/public';
import { EuiIconType } from '@elastic/eui/src/components/icon/icon';
import { isEmpty } from 'lodash';
import { VisualizeEmbeddable } from '../../../../src/plugins/visualizations/public';
import { isEligibleForVisLayers } from '../../../../src/plugins/vis_augmenter/public';

export const ACTION_AD = 'ad';

Expand Down Expand Up @@ -57,15 +60,13 @@ export const createADAction = ({
type: ACTION_AD,
grouping,
isCompatible: async ({ embeddable }: ActionContext) => {
const paramsType = embeddable.vis?.params?.type;
const seriesParams = embeddable.vis?.params?.seriesParams || [];
const series = embeddable.vis?.params?.series || [];
const isLineGraph =
seriesParams.find((item) => item.type === 'line') ||
series.find((item) => item.chart_type === 'line');
const isValidVis = isLineGraph && paramsType !== 'table';
const vis = (embeddable as VisualizeEmbeddable).vis;
return Boolean(
embeddable.parent && isDashboard(embeddable.parent) && isValidVis
embeddable.parent &&
isDashboard(embeddable.parent) &&
vis !== undefined &&
isEligibleForVisLayers(vis) &&
!isEmpty((embeddable as VisualizeEmbeddable).visLayers)
);
},
execute: async ({ embeddable }: ActionContext) => {
Expand Down
Loading

0 comments on commit 1470204

Please sign in to comment.