Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple space-separated values within a single element's data-test-subj attribute #1587

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Converted `EuiToggle` to TypeScript ([#1570](https://github.com/elastic/eui/pull/1570))
- Added type definitions for `EuiButtonGroup`,`EuiButtonToggle`, `EuiFilterButton`, `EuiFilterGroup`, and `EuiFilterSelectItem` ([#1570](https://github.com/elastic/eui/pull/1570))
- Added `displayOnly` prop to EuiFormRow ([#1582](https://github.com/elastic/eui/pull/1582))
- Added support to `findTestSubject` for finding one of multiple space-separated values within a single element's `data-test-subj` attribute ([#1587](https://github.com/elastic/eui/pull/1587))

## [`7.2.0`](https://github.com/elastic/eui/tree/v7.2.0)

Expand Down
4 changes: 3 additions & 1 deletion src/test/find_test_subject.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
* Common use cases include calling simulate or getDOMNode on the returned ReactWrapper.
*/
export const findTestSubject = (mountedComponent, testSubjectSelector) => {
const testSubject = mountedComponent.find(`[data-test-subj="${testSubjectSelector}"]`);
// The ~ looks for the value in space-separated list, allowing support for multiple data-test-subj
// values on a single element.
const testSubject = mountedComponent.find(`[data-test-subj~="${testSubjectSelector}"]`);

// Restores Enzyme 2's find behavior, which was to only return ReactWrappers around DOM elements.
// Enzyme 3 returns ReactWrappers around both DOM elements and React components.
Expand Down