From a30f8645d1a0d0c5c7525ef69080a0dc8681d5da Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Fri, 2 Feb 2024 13:26:37 +0000 Subject: [PATCH] Chore: Migrate frontend platform code to use `data-testid` for selectors (#81787) * migrate some stuff from aria-label to data-testid * convert styles to objects * fix unit tests * empty commit to kick drone now enterprise branch is there --- .betterer.results | 15 ------- .../src/selectors/components.ts | 4 +- .../DateTimePickers/TimeRangeInput.tsx | 2 +- .../PageHeader/PanelHeaderMenuItem.tsx | 5 ++- .../QueryOperationAction.test.tsx | 14 +++---- .../QueryOperationAction.tsx | 39 +++++++++---------- .../Select/OldFolderPicker.test.tsx | 12 +++--- .../components/Select/OldFolderPicker.tsx | 12 +++--- .../alerting/unified/Silences.test.tsx | 3 +- .../BrowseActions/MoveModal.test.tsx | 7 ++-- .../TransformationsEditor.test.tsx | 2 +- 11 files changed, 50 insertions(+), 65 deletions(-) diff --git a/.betterer.results b/.betterer.results index eb523e906fe..acdb0ea202c 100644 --- a/.betterer.results +++ b/.betterer.results @@ -637,9 +637,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "6"], [0, 0, 0, "Unexpected any. Specify a different type.", "7"] ], - "packages/grafana-ui/src/components/DateTimePickers/TimeRangeInput.tsx:5381": [ - [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"] - ], "packages/grafana-ui/src/components/Forms/Legacy/Input/Input.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], @@ -1006,9 +1003,6 @@ exports[`better eslint`] = { [0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "1"] ], - "public/app/core/components/PageHeader/PanelHeaderMenuItem.tsx:5381": [ - [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"] - ], "public/app/core/components/PanelTypeFilter/PanelTypeFilter.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "1"] @@ -1016,11 +1010,6 @@ exports[`better eslint`] = { "public/app/core/components/QueryOperationRow/OperationRowHelp.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"] ], - "public/app/core/components/QueryOperationRow/QueryOperationAction.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.", "1"], - [0, 0, 0, "Styles should be written using objects.", "2"] - ], "public/app/core/components/QueryOperationRow/QueryOperationRow.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"], [0, 0, 0, "Styles should be written using objects.", "1"] @@ -1046,10 +1035,6 @@ exports[`better eslint`] = { "public/app/core/components/RolePicker/ValueContainer.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"] ], - "public/app/core/components/Select/OldFolderPicker.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.", "1"] - ], "public/app/core/components/TagFilter/TagFilter.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], diff --git a/packages/grafana-e2e-selectors/src/selectors/components.ts b/packages/grafana-e2e-selectors/src/selectors/components.ts index c9dde2bacaa..6a3f126b69d 100644 --- a/packages/grafana-e2e-selectors/src/selectors/components.ts +++ b/packages/grafana-e2e-selectors/src/selectors/components.ts @@ -285,7 +285,7 @@ export const Components = { rows: 'Query editor row', }, QueryEditorRow: { - actionButton: (title: string) => `${title}`, + actionButton: (title: string) => `data-testid ${title}`, title: (refId: string) => `Query editor row title ${refId}`, container: (refId: string) => `Query editor row ${refId}`, }, @@ -392,7 +392,7 @@ export const Components = { */ container: 'Folder picker select container', containerV2: 'data-testid Folder picker select container', - input: 'Select a folder', + input: 'data-testid folder-picker-input', }, ReadonlyFolderPicker: { container: 'data-testid Readonly folder picker select container', diff --git a/packages/grafana-ui/src/components/DateTimePickers/TimeRangeInput.tsx b/packages/grafana-ui/src/components/DateTimePickers/TimeRangeInput.tsx index 8a63f528743..03b48a4d7ff 100644 --- a/packages/grafana-ui/src/components/DateTimePickers/TimeRangeInput.tsx +++ b/packages/grafana-ui/src/components/DateTimePickers/TimeRangeInput.tsx @@ -78,7 +78,7 @@ export const TimeRangeInput = ({