Skip to content

Commit bb2a152

Browse files
Added alerting ui mock for jest test (#92604)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
1 parent 1e1540a commit bb2a152

18 files changed

Lines changed: 126 additions & 48 deletions

File tree

x-pack/plugins/infra/public/alerting/metric_threshold/components/expression.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,12 @@ import {
2626
Aggregators,
2727
METRIC_THRESHOLD_ALERT_TYPE_ID,
2828
} from '../../../../common/alerting/metrics';
29-
import {
30-
ForLastExpression,
31-
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
32-
} from '../../../../../triggers_actions_ui/public/common';
29+
import { ForLastExpression } from '../../../../../triggers_actions_ui/public';
3330
import {
3431
IErrorObject,
3532
AlertTypeParams,
3633
AlertTypeParamsExpressionProps,
37-
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
38-
} from '../../../../../triggers_actions_ui/public/types';
34+
} from '../../../../../triggers_actions_ui/public';
3935
import { MetricsExplorerKueryBar } from '../../../pages/metrics/metrics_explorer/components/kuery_bar';
4036
import { MetricsExplorerOptions } from '../../../pages/metrics/metrics_explorer/hooks/use_metrics_explorer_options';
4137
import { MetricsExplorerGroupBy } from '../../../pages/metrics/metrics_explorer/components/group_by';

x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_row.test.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ describe('ExpressionRow', () => {
6363
timeUnit: 'm',
6464
aggType: 'avg',
6565
};
66-
const { wrapper } = await setup(expression as MetricExpression);
66+
const { wrapper, update } = await setup(expression as MetricExpression);
67+
await update();
6768
const [valueMatch] = wrapper.html().match('<span class="euiExpression__value">50</span>') ?? [];
6869
expect(valueMatch).toBeTruthy();
6970
});
@@ -95,7 +96,7 @@ describe('ExpressionRow', () => {
9596

9697
const { wrapper } = await setup(expression as MetricExpression);
9798

98-
const helpText = wrapper.find('[data-test-subj="ofExpression"]').prop('helpText');
99+
const helpText = wrapper.find('[data-test-subj="ofExpression"]').at(0).prop('helpText');
99100

100101
expect(helpText).toMatchSnapshot();
101102
});

x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_row.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,15 @@ import {
2424
WhenExpression,
2525
OfExpression,
2626
ThresholdExpression,
27-
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
28-
} from '../../../../../triggers_actions_ui/public/common';
27+
} from '../../../../../triggers_actions_ui/public';
2928
import { euiStyled } from '../../../../../../../src/plugins/kibana_react/common';
30-
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
31-
import { IErrorObject } from '../../../../../triggers_actions_ui/public/types';
29+
import { IErrorObject } from '../../../../../triggers_actions_ui/public';
3230
import { MetricExpression, AGGREGATION_TYPES } from '../types';
3331
import {
3432
Comparator,
3533
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
3634
} from '../../../../server/lib/alerting/metric_threshold/types';
37-
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
38-
import { builtInComparators } from '../../../../../triggers_actions_ui/public/common/constants';
35+
import { builtInComparators } from '../../../../../triggers_actions_ui/public';
3936

4037
const customComparators = {
4138
...builtInComparators,

x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import { HttpSetup } from 'kibana/public';
99
import { BASE_ACTION_API_PATH } from '../constants';
10-
import { ActionConnector, ActionConnectorWithoutId, ActionType } from '../../types';
10+
import type { ActionConnector, ActionConnectorWithoutId, ActionType } from '../../types';
1111
import { ActionTypeExecutorResult } from '../../../../../plugins/actions/common';
1212

1313
export async function loadActionTypes({ http }: { http: HttpSetup }): Promise<ActionType[]> {

x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_conditions.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,6 @@ export const AlertConditions = <ConditionProps extends any, ActionGroupIds exten
124124
</EuiFlexGroup>
125125
);
126126
};
127+
128+
// eslint-disable-next-line import/no-default-export
129+
export { AlertConditions as default };

x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/alert_conditions_group.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,6 @@ export const AlertConditionsGroup = <ConditionProps extends unknown>({
6060
</EuiFormRow>
6161
);
6262
};
63+
64+
// eslint-disable-next-line import/no-default-export
65+
export { AlertConditionsGroup as default };

x-pack/plugins/triggers_actions_ui/public/application/sections/alert_form/index.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77

88
import { lazy } from 'react';
99
import { suspendedComponentWithProps } from '../../lib/suspended_component_with_props';
10-
export {
11-
AlertConditions,
12-
ActionGroupWithCondition,
13-
AlertConditionsProps,
14-
} from './alert_conditions';
15-
export { AlertConditionsGroup } from './alert_conditions_group';
1610

1711
export const AlertAdd = suspendedComponentWithProps(lazy(() => import('./alert_add')));
1812
export const AlertEdit = suspendedComponentWithProps(lazy(() => import('./alert_edit')));

x-pack/plugins/triggers_actions_ui/public/application/sections/index.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77

88
import { lazy } from 'react';
99
import { suspendedComponentWithProps } from '../lib/suspended_component_with_props';
10-
export {
11-
ActionGroupWithCondition,
12-
AlertConditionsProps,
13-
AlertConditions,
14-
AlertConditionsGroup,
15-
} from './alert_form';
10+
11+
export type { ActionGroupWithCondition, AlertConditionsProps } from './alert_form/alert_conditions';
12+
13+
export const AlertConditions = lazy(() => import('./alert_form/alert_conditions'));
14+
export const AlertConditionsGroup = lazy(() => import('./alert_form/alert_conditions_group'));
1615

1716
export const AlertAdd = suspendedComponentWithProps(lazy(() => import('./alert_form/alert_add')));
1817
export const AlertEdit = suspendedComponentWithProps(lazy(() => import('./alert_form/alert_edit')));

x-pack/plugins/triggers_actions_ui/public/common/expression_items/for_the_last.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { getTimeOptions } from '../lib/get_time_options';
2323
import { ClosablePopoverTitle } from './components';
2424
import { IErrorObject } from '../../types';
2525

26-
interface ForLastExpressionProps {
26+
export interface ForLastExpressionProps {
2727
timeWindowSize?: number;
2828
timeWindowUnit?: string;
2929
errors: IErrorObject;
@@ -129,3 +129,6 @@ export const ForLastExpression = ({
129129
</EuiPopover>
130130
);
131131
};
132+
133+
// eslint-disable-next-line import/no-default-export
134+
export { ForLastExpression as default };

x-pack/plugins/triggers_actions_ui/public/common/expression_items/group_by_over.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { GroupByType } from '../types';
2222
import { ClosablePopoverTitle } from './components';
2323
import { IErrorObject } from '../../types';
2424

25-
interface GroupByExpressionProps {
25+
export interface GroupByExpressionProps {
2626
groupBy: string;
2727
errors: IErrorObject;
2828
onChangeSelectedTermSize: (selectedTermSize?: number) => void;
@@ -208,3 +208,6 @@ export const GroupByExpression = ({
208208
</EuiPopover>
209209
);
210210
};
211+
212+
// eslint-disable-next-line import/no-default-export
213+
export { GroupByExpression as default };

0 commit comments

Comments
 (0)