diff --git a/public/app/features/alerting/unified/CloneRuleEditor.test.tsx b/public/app/features/alerting/unified/CloneRuleEditor.test.tsx index a40da75e65b..c3c0cd1a7a7 100644 --- a/public/app/features/alerting/unified/CloneRuleEditor.test.tsx +++ b/public/app/features/alerting/unified/CloneRuleEditor.test.tsx @@ -32,6 +32,7 @@ import { import { mockAlertmanagerConfigResponse } from './mocks/alertmanagerApi'; import { mockSearchApiResponse } from './mocks/grafanaApi'; import { mockRulerRulesApiResponse, mockRulerRulesGroupApiResponse } from './mocks/rulerApi'; +import { AlertingQueryRunner } from './state/AlertingQueryRunner'; import { RuleFormValues } from './types/rule-form'; import { Annotation } from './utils/constants'; import { GRAFANA_RULES_SOURCE_NAME } from './utils/datasource'; @@ -51,6 +52,8 @@ jest.mock('./components/rule-editor/notificaton-preview/NotificationPreview', () NotificationPreview: () =>
, })); +jest.spyOn(AlertingQueryRunner.prototype, 'run').mockImplementation(() => Promise.resolve()); + const server = setupServer(); beforeAll(() => { diff --git a/public/app/features/alerting/unified/components/alert-groups/MatcherFilter.test.tsx b/public/app/features/alerting/unified/components/alert-groups/MatcherFilter.test.tsx index b5c47e3a8ac..9043b8f8a7c 100644 --- a/public/app/features/alerting/unified/components/alert-groups/MatcherFilter.test.tsx +++ b/public/app/features/alerting/unified/components/alert-groups/MatcherFilter.test.tsx @@ -3,13 +3,13 @@ import userEvent from '@testing-library/user-event'; import lodash from 'lodash'; // eslint-disable-line lodash/import-scope import React from 'react'; -import { logInfo } from '@grafana/runtime'; +import * as runtime from '@grafana/runtime'; import { LogMessages } from '../../Analytics'; import { MatcherFilter } from './MatcherFilter'; -jest.mock('@grafana/runtime'); +const logInfoSpy = jest.spyOn(runtime, 'logInfo'); describe('Analytics', () => { beforeEach(() => { @@ -25,7 +25,7 @@ describe('Analytics', () => { const searchInput = screen.getByTestId('search-query-input'); await userEvent.type(searchInput, 'job='); - expect(logInfo).toHaveBeenCalledWith(LogMessages.filterByLabel); + expect(logInfoSpy).toHaveBeenCalledWith(LogMessages.filterByLabel); }); it('should call onChange handler', async () => { diff --git a/public/app/features/alerting/unified/components/rule-editor/CloudRulesSourcePicker.tsx b/public/app/features/alerting/unified/components/rule-editor/CloudRulesSourcePicker.tsx index cd2c21eb57b..cf90e30003e 100644 --- a/public/app/features/alerting/unified/components/rule-editor/CloudRulesSourcePicker.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/CloudRulesSourcePicker.tsx @@ -9,13 +9,14 @@ import { useRulesSourcesWithRuler } from '../../hooks/useRuleSourcesWithRuler'; import { fetchAllPromBuildInfoAction } from '../../state/actions'; interface Props { + disabled?: boolean; onChange: (ds: DataSourceInstanceSettings) => void; value: string | null; onBlur?: () => void; name?: string; } -export function CloudRulesSourcePicker({ value, ...props }: Props): JSX.Element { +export function CloudRulesSourcePicker({ value, disabled, ...props }: Props): JSX.Element { const rulesSourcesWithRuler = useRulesSourcesWithRuler(); const { loading = true } = useAsync(() => dispatch(fetchAllPromBuildInfoAction()), [dispatch]); @@ -28,6 +29,13 @@ export function CloudRulesSourcePicker({ value, ...props }: Props): JSX.Element ); return ( -