diff --git a/packages/grafana-e2e-selectors/src/selectors/components.ts b/packages/grafana-e2e-selectors/src/selectors/components.ts index df60344157d..0ad5ecb22e1 100644 --- a/packages/grafana-e2e-selectors/src/selectors/components.ts +++ b/packages/grafana-e2e-selectors/src/selectors/components.ts @@ -661,6 +661,12 @@ export const versionedComponents = { newEvaluationGroupCreate: { '11.1.0': 'data-testid alert-rule new-evaluation-group-create-button', }, + step: { + '11.5.0': (stepNo: string) => `data-testid alert-rule step-${stepNo}`, + }, + stepAdvancedModeSwitch: { + '11.5.0': (stepNo: string) => `data-testid advanced-mode-switch step-${stepNo}`, + }, }, Alert: { alertV2: { diff --git a/public/app/features/alerting/unified/components/rule-editor/RuleEditorSection.tsx b/public/app/features/alerting/unified/components/rule-editor/RuleEditorSection.tsx index 8c872e2b4f7..d4a4fc01010 100644 --- a/public/app/features/alerting/unified/components/rule-editor/RuleEditorSection.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/RuleEditorSection.tsx @@ -3,6 +3,7 @@ import * as React from 'react'; import { ReactElement } from 'react'; import { GrafanaTheme2 } from '@grafana/data'; +import { selectors } from '@grafana/e2e-selectors'; import { FieldSet, InlineSwitch, Stack, Text, useStyles2 } from '@grafana/ui'; export interface RuleEditorSectionProps { @@ -25,8 +26,9 @@ export const RuleEditorSection = ({ switchMode, }: React.PropsWithChildren) => { const styles = useStyles2(getStyles); + const AlertRuleSelectors = selectors.components.AlertRules; return ( -
+
{ switchMode.setAdvancedMode(event.currentTarget.checked); diff --git a/public/test/helpers/alertingRuleEditor.tsx b/public/test/helpers/alertingRuleEditor.tsx index 39898405bdd..1f1dc3552f2 100644 --- a/public/test/helpers/alertingRuleEditor.tsx +++ b/public/test/helpers/alertingRuleEditor.tsx @@ -31,8 +31,10 @@ export const ui = { contactPoint: byTestId('contact-point-picker'), routingOptions: byText(/muting, grouping and timings \(optional\)/i), }, - switchModeBasic: (stepNo: GrafanaRuleFormStep) => byTestId(`advanced-switch-${stepNo}-basic`), - switchModeAdvanced: (stepNo: GrafanaRuleFormStep) => byTestId(`advanced-switch-${stepNo}-advanced`), + switchModeBasic: (stepNo: GrafanaRuleFormStep) => + byTestId(selectors.components.AlertRules.stepAdvancedModeSwitch(stepNo.toString())), + switchModeAdvanced: (stepNo: GrafanaRuleFormStep) => + byTestId(selectors.components.AlertRules.stepAdvancedModeSwitch(stepNo.toString())), }, buttons: { saveAndExit: byRole('button', { name: 'Save rule and exit' }),