+
{isClearable && tags.length > 0 && (
onTagChange([])}>
Clear tags
)}
-
} />
+
} aria-label="Tag filter" />
);
};
diff --git a/public/app/features/search/components/DashboardSearch.test.tsx b/public/app/features/search/components/DashboardSearch.test.tsx
index 7319e3c8598..f2a70446e66 100644
--- a/public/app/features/search/components/DashboardSearch.test.tsx
+++ b/public/app/features/search/components/DashboardSearch.test.tsx
@@ -1,6 +1,6 @@
import React from 'react';
import { render, fireEvent, screen, waitFor, act } from '@testing-library/react';
-import userEvent from '@testing-library/user-event';
+import selectEvent from 'react-select-event';
import * as SearchSrv from 'app/core/services/search_srv';
import * as MockSearchSrv from 'app/core/services/__mocks__/search_srv';
import { DashboardSearch, Props } from './DashboardSearch';
@@ -94,12 +94,9 @@ describe('DashboardSearch', () => {
setup();
await waitFor(() => screen.getByLabelText('Tag filter'));
- // Get the actual element for the underlying Select component, since Select doesn't accept aria- props
- const tagComponent = screen.getByLabelText('Tag filter').querySelector('div') as Node;
- fireEvent.keyDown(tagComponent, { keyCode: 40 });
- const firstTag = await screen.findByText('tag1');
- userEvent.click(firstTag);
+ const tagComponent = screen.getByLabelText('Tag filter');
+ await selectEvent.select(tagComponent, 'tag1');
expect(tagComponent).toBeInTheDocument();
diff --git a/public/app/features/search/components/SearchResultsFilter.test.tsx b/public/app/features/search/components/SearchResultsFilter.test.tsx
index 4d5d1805d83..e3ee3440643 100644
--- a/public/app/features/search/components/SearchResultsFilter.test.tsx
+++ b/public/app/features/search/components/SearchResultsFilter.test.tsx
@@ -1,5 +1,6 @@
import React from 'react';
import { fireEvent, render, screen } from '@testing-library/react';
+import selectEvent from 'react-select-event';
import { Props, SearchResultsFilter } from './SearchResultsFilter';
import { SearchLayout } from '../types';
@@ -80,9 +81,8 @@ describe('SearchResultsFilter', () => {
query: { ...searchQuery, tag: [] },
});
const tagComponent = await screen.findByLabelText('Tag filter');
+ await selectEvent.select(tagComponent, 'tag1');
- fireEvent.keyDown(tagComponent.querySelector('div') as Node, { keyCode: 40 });
- fireEvent.click(await screen.findByText('tag1'));
expect(mockFilterByTags).toHaveBeenCalledTimes(1);
expect(mockFilterByTags).toHaveBeenCalledWith(['tag1']);
});
diff --git a/yarn.lock b/yarn.lock
index 49bb770ab58..deaf95b8ffd 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -5725,6 +5725,20 @@
resolve-from "^5.0.0"
store2 "^2.7.1"
+"@testing-library/dom@>=7":
+ version "7.29.4"
+ resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-7.29.4.tgz#1647c2b478789621ead7a50614ad81ab5ae5b86c"
+ integrity sha512-CtrJRiSYEfbtNGtEsd78mk1n1v2TUbeABlNIcOCJdDfkN5/JTOwQEbbQpoSRxGqzcWPgStMvJ4mNolSuBRv1NA==
+ dependencies:
+ "@babel/code-frame" "^7.10.4"
+ "@babel/runtime" "^7.12.5"
+ "@types/aria-query" "^4.2.0"
+ aria-query "^4.2.2"
+ chalk "^4.1.0"
+ dom-accessibility-api "^0.5.4"
+ lz-string "^1.4.4"
+ pretty-format "^26.6.2"
+
"@testing-library/dom@^7.26.6":
version "7.26.6"
resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-7.26.6.tgz#d558db63070a3acea5bea7e2497e631cd12541cc"
@@ -22310,6 +22324,13 @@ react-reverse-portal@^2.0.1:
resolved "https://registry.yarnpkg.com/react-reverse-portal/-/react-reverse-portal-2.0.1.tgz#23b18292c531fb7b343d85a614c15a995838ba31"
integrity sha512-sj/D9nSHspqV8i8hWkTSZ5Ohnrqk2A5fkDKw4Xe/zV4OfF1UYwmbzrxLdmNRdKkWgQwnXIxaa2E3FC7QYdZAeA==
+react-select-event@^5.1.0:
+ version "5.1.0"
+ resolved "https://registry.yarnpkg.com/react-select-event/-/react-select-event-5.1.0.tgz#d45ef68f2a9c872903e8c9725f3ae6e7576f7be0"
+ integrity sha512-D5DzJlYCdZsGbDVFMQFynrG0OLalJM3ZzDT7KQADNVWE604JCeQF9bIuvPZqVD7IzhnPsFzOUCsilzDA6w6WRQ==
+ dependencies:
+ "@testing-library/dom" ">=7"
+
react-select@^3.0.8:
version "3.2.0"
resolved "https://registry.yarnpkg.com/react-select/-/react-select-3.2.0.tgz#de9284700196f5f9b5277c5d850a9ce85f5c72fe"