From b7c74a1af61d6fda5a3eba48dbfc8e0ff97dbc1b Mon Sep 17 00:00:00 2001 From: Khushi Jain <57278642+khushijain21@users.noreply.github.com> Date: Mon, 27 Nov 2023 20:54:31 +0530 Subject: [PATCH] Alerting: Migrate from aria-label e2e selectors to data-testid (#78437) Co-authored-by: Gilles De Mey --- .betterer.results | 13 +++++-------- .../src/selectors/components.ts | 4 ++-- public/app/features/alerting/AlertTab.tsx | 2 +- .../alerting/unified/PanelAlertTabContent.tsx | 2 +- .../QueryAndExpressionsStep.tsx | 2 +- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.betterer.results b/.betterer.results index d56f5aa7e50..97a70b499c1 100644 --- a/.betterer.results +++ b/.betterer.results @@ -1634,8 +1634,7 @@ exports[`better eslint`] = { ], "public/app/features/alerting/AlertTab.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "2"] + [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], "public/app/features/alerting/AlertTabCtrl.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -1769,10 +1768,9 @@ exports[`better eslint`] = { [0, 0, 0, "Styles should be written using objects.", "0"] ], "public/app/features/alerting/unified/PanelAlertTabContent.tsx:5381": [ - [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"], + [0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "1"], - [0, 0, 0, "Styles should be written using objects.", "2"], - [0, 0, 0, "Styles should be written using objects.", "3"] + [0, 0, 0, "Styles should be written using objects.", "2"] ], "public/app/features/alerting/unified/RedirectToRuleViewer.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"], @@ -2344,11 +2342,10 @@ exports[`better eslint`] = { [0, 0, 0, "Styles should be written using objects.", "1"] ], "public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/QueryAndExpressionsStep.tsx:5381": [ - [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"], + [0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "1"], [0, 0, 0, "Styles should be written using objects.", "2"], - [0, 0, 0, "Styles should be written using objects.", "3"], - [0, 0, 0, "Styles should be written using objects.", "4"] + [0, 0, 0, "Styles should be written using objects.", "3"] ], "public/app/features/alerting/unified/components/rule-editor/rule-types/RuleType.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"], diff --git a/packages/grafana-e2e-selectors/src/selectors/components.ts b/packages/grafana-e2e-selectors/src/selectors/components.ts index f692860c395..84d8fd3a27b 100644 --- a/packages/grafana-e2e-selectors/src/selectors/components.ts +++ b/packages/grafana-e2e-selectors/src/selectors/components.ts @@ -214,7 +214,7 @@ export const Components = { container: (refId: string) => `Query editor row ${refId}`, }, AlertTab: { - content: 'Alert editor tab content', + content: 'data-testid Alert editor tab content', }, Alert: { /** @@ -405,7 +405,7 @@ export const Components = { submit: 'data-testid-import-dashboard-submit', }, PanelAlertTabContent: { - content: 'Unified alert editor tab content', + content: 'data-testid Unified alert editor tab content', }, VisualizationPreview: { card: (name: string) => `data-testid suggestion-${name}`, diff --git a/public/app/features/alerting/AlertTab.tsx b/public/app/features/alerting/AlertTab.tsx index f979e8e26a5..207ec7c6be0 100644 --- a/public/app/features/alerting/AlertTab.tsx +++ b/public/app/features/alerting/AlertTab.tsx @@ -229,7 +229,7 @@ class UnConnectedAlertTab extends PureComponent { <> -
+
{alert && hasTransformations && ( { } return ( -
+
{alert} {!!dashboard.uid && ( <> diff --git a/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/QueryAndExpressionsStep.tsx b/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/QueryAndExpressionsStep.tsx index 2031db493af..a77726cda35 100644 --- a/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/QueryAndExpressionsStep.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/query-and-alert-condition/QueryAndExpressionsStep.tsx @@ -457,7 +457,7 @@ export const QueryAndExpressionsStep = ({ editingExistingRule, onDataChange }: P dispatch(addNewDataQuery()); }} variant="secondary" - aria-label={selectors.components.QueryTab.addQuery} + data-testid={selectors.components.QueryTab.addQuery} disabled={noCompatibleDataSources} className={styles.addQueryButton} >