Frontend: Migrate DataSourceHttpSettings.tsx from aria-label e2e selectors to data-testid (#79615)

This commit is contained in:
Jamin 2024-01-10 11:51:16 +00:00 committed by GitHub
parent 642391c9f9
commit 71b98163e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View File

@ -609,9 +609,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"packages/grafana-ui/src/components/DataSourceSettings/DataSourceHttpSettings.tsx:5381": [
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"]
],
"packages/grafana-ui/src/components/DataSourceSettings/types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],

View File

@ -53,7 +53,7 @@ export const Components = {
},
},
DataSourceHttpSettings: {
urlInput: 'Datasource HTTP settings url',
urlInput: 'data-testid Datasource HTTP settings url',
},
Jaeger: {
traceIDInput: 'Trace ID',

View File

@ -1,5 +1,5 @@
import { css, cx } from '@emotion/css';
import React, { useState, useCallback } from 'react';
import React, { useState, useCallback, useId } from 'react';
import { SelectableValue } from '@grafana/data';
import { selectors } from '@grafana/e2e-selectors';
@ -153,12 +153,15 @@ export const DataSourceHttpSettings = (props: HttpSettingsProps) => {
const inputStyle = cx({ [`width-20`]: true, [notValidStyle]: !isValidUrl });
const fromFieldId = useId();
const urlInput = (
<Input
id={fromFieldId}
className={inputStyle}
placeholder={defaultUrl}
value={dataSourceConfig.url}
aria-label={selectors.components.DataSource.DataSourceHttpSettings.urlInput}
data-testid={selectors.components.DataSource.DataSourceHttpSettings.urlInput}
onChange={(event) => onSettingsChange({ url: event.currentTarget.value })}
disabled={dataSourceConfig.readOnly}
/>