Alerting: Migrate from aria-label e2e selectors to data-testid (#78437)

Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
This commit is contained in:
Khushi Jain 2023-11-27 20:54:31 +05:30 committed by GitHub
parent 6708848056
commit b7c74a1af6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 13 deletions

View File

@ -1634,8 +1634,7 @@ exports[`better eslint`] = {
], ],
"public/app/features/alerting/AlertTab.tsx:5381": [ "public/app/features/alerting/AlertTab.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"]
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "2"]
], ],
"public/app/features/alerting/AlertTabCtrl.ts:5381": [ "public/app/features/alerting/AlertTabCtrl.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [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"] [0, 0, 0, "Styles should be written using objects.", "0"]
], ],
"public/app/features/alerting/unified/PanelAlertTabContent.tsx:5381": [ "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.", "1"],
[0, 0, 0, "Styles should be written using objects.", "2"], [0, 0, 0, "Styles should be written using objects.", "2"]
[0, 0, 0, "Styles should be written using objects.", "3"]
], ],
"public/app/features/alerting/unified/RedirectToRuleViewer.tsx:5381": [ "public/app/features/alerting/unified/RedirectToRuleViewer.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"], [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"] [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": [ "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.", "1"],
[0, 0, 0, "Styles should be written using objects.", "2"], [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.", "3"]
[0, 0, 0, "Styles should be written using objects.", "4"]
], ],
"public/app/features/alerting/unified/components/rule-editor/rule-types/RuleType.tsx:5381": [ "public/app/features/alerting/unified/components/rule-editor/rule-types/RuleType.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "0"],

View File

@ -214,7 +214,7 @@ export const Components = {
container: (refId: string) => `Query editor row ${refId}`, container: (refId: string) => `Query editor row ${refId}`,
}, },
AlertTab: { AlertTab: {
content: 'Alert editor tab content', content: 'data-testid Alert editor tab content',
}, },
Alert: { Alert: {
/** /**
@ -405,7 +405,7 @@ export const Components = {
submit: 'data-testid-import-dashboard-submit', submit: 'data-testid-import-dashboard-submit',
}, },
PanelAlertTabContent: { PanelAlertTabContent: {
content: 'Unified alert editor tab content', content: 'data-testid Unified alert editor tab content',
}, },
VisualizationPreview: { VisualizationPreview: {
card: (name: string) => `data-testid suggestion-${name}`, card: (name: string) => `data-testid suggestion-${name}`,

View File

@ -229,7 +229,7 @@ class UnConnectedAlertTab extends PureComponent<Props, State> {
<> <>
<CustomScrollbar autoHeightMin="100%"> <CustomScrollbar autoHeightMin="100%">
<Container padding="md"> <Container padding="md">
<div aria-label={selectors.components.AlertTab.content}> <div data-testid={selectors.components.AlertTab.content}>
{alert && hasTransformations && ( {alert && hasTransformations && (
<Alert <Alert
severity={AppNotificationSeverity.Error} severity={AppNotificationSeverity.Error}

View File

@ -59,7 +59,7 @@ export const PanelAlertTabContent = ({ dashboard, panel }: Props) => {
} }
return ( return (
<div aria-label={selectors.components.PanelAlertTabContent.content} className={styles.noRulesWrapper}> <div data-testid={selectors.components.PanelAlertTabContent.content} className={styles.noRulesWrapper}>
{alert} {alert}
{!!dashboard.uid && ( {!!dashboard.uid && (
<> <>

View File

@ -457,7 +457,7 @@ export const QueryAndExpressionsStep = ({ editingExistingRule, onDataChange }: P
dispatch(addNewDataQuery()); dispatch(addNewDataQuery());
}} }}
variant="secondary" variant="secondary"
aria-label={selectors.components.QueryTab.addQuery} data-testid={selectors.components.QueryTab.addQuery}
disabled={noCompatibleDataSources} disabled={noCompatibleDataSources}
className={styles.addQueryButton} className={styles.addQueryButton}
> >