diff --git a/contribute/style-guides/e2e.md b/contribute/style-guides/e2e.md index 4c69945a42a..4a53e065cfd 100644 --- a/contribute/style-guides/e2e.md +++ b/contribute/style-guides/e2e.md @@ -160,3 +160,41 @@ describe('List test', () => { }); }); ``` + +## Aria-Labels vs data-testid +Our selectors are set up to work with both aria-labels and data-testid attributes. Aria-labels help assistive technologies such as screenreaders identify interactive elements of a page for our users. + +A good example of a time to use an aria-label might be if you have a button with an X to close: +``` + + )} diff --git a/public/app/features/manage-dashboards/components/ImportDashboardForm.tsx b/public/app/features/manage-dashboards/components/ImportDashboardForm.tsx index 865a75a07f5..7c679382e62 100644 --- a/public/app/features/manage-dashboards/components/ImportDashboardForm.tsx +++ b/public/app/features/manage-dashboards/components/ImportDashboardForm.tsx @@ -14,6 +14,7 @@ import { DataSourcePicker } from '@grafana/runtime'; import { FolderPicker } from 'app/core/components/Select/FolderPicker'; import { DashboardInput, DashboardInputs, DataSourceInput, ImportDashboardDTO } from '../state/reducers'; import { validateTitle, validateUid } from '../utils/validation'; +import { selectors } from '@grafana/e2e-selectors'; interface Props extends Pick, 'register' | 'errors' | 'control' | 'getValues' | 'watch'> { uidReset: boolean; @@ -61,6 +62,7 @@ export const ImportDashboardForm: FC = ({ validate: async (v: string) => await validateTitle(v, getValues().folder.id), })} type="text" + data-testid={selectors.components.ImportDashboardForm.name} /> @@ -137,6 +139,7 @@ export const ImportDashboardForm: FC = ({