enzyme -> RTL: convert the Search component suites - #471
Merged
Conversation
Migrate components/Search (Search and AdvancedSearch) off enzyme/mountWithContexts onto renderWithContexts (React Testing Library). The key/value/date selects and typeaheads are driven through the real PF controls (scoped by ouiaId); filter chips and onSearch are asserted via the rendered DOM. Behaviour and assertions are preserved.
Contributor
There was a problem hiding this comment.
Pull request overview
Migrates the components/Search UI test suites from Enzyme (mountWithContexts) to React Testing Library (renderWithContexts), continuing the ongoing enzyme → RTL conversion work without changing production code.
Changes:
- Converted
Searchcomponent tests to RTL, driving real PatternFly Select/Chip interactions via OUIA selectors and DOM assertions. - Converted
AdvancedSearchtests to RTL, exercising the three typeahead Selects and value submission through the rendered UI. - Updated assertions to validate filter chips and callbacks via rendered output rather than Enzyme prop inspection.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| awx/ui/src/components/Search/Search.test.js | Rewrites Search tests to RTL, using DOM-driven interactions and assertions for chips/callbacks. |
| awx/ui/src/components/Search/AdvancedSearch.test.js | Rewrites AdvancedSearch tests to RTL, interacting with PF typeaheads via OUIA scoping. |
Comment on lines
+234
to
+237
| // empty-value chip has no visible text, so scope to the rendered chip and | ||
| // click its close button (the only button inside the chip) | ||
| const chip = document.querySelector('.pf-c-chip'); | ||
| await user.click(within(chip).getByRole('button')); |
Comment on lines
+9
to
+13
| async function selectFrom(user, ouiaId, optionName) { | ||
| const wrap = document.querySelector(`[data-ouia-component-id="${ouiaId}"]`); | ||
| await user.click(within(wrap).getByRole('button', { name: 'Options menu' })); | ||
| fireEvent.click(await screen.findByRole('option', { name: optionName })); | ||
| } |
Comment on lines
+45
to
+49
| await user.click( | ||
| within(keyWrap).getByRole('button', { name: 'Options menu' }) | ||
| ); | ||
| // 'bar' is in both lists but must appear only once -> foo, bar, baz | ||
| expect(screen.getAllByRole('option')).toHaveLength(3); |
Comment on lines
+229
to
+232
| await user.click(within(wrap).getByRole('button', { name: 'Options menu' })); | ||
| // with negative filtering off, only "and" and "or" remain (no "not") | ||
| const options = screen.getAllByRole('option'); | ||
| expect(options).toHaveLength(2); |
Comment on lines
+258
to
+262
| await user.click(within(wrap).getByRole('button', { name: 'Options menu' })); | ||
| // with fuzzy filtering off, the "search" (fuzzy id/name/description) option | ||
| // is removed -> name__icontains, name, id remain | ||
| const options = screen.getAllByRole('option'); | ||
| expect(options).toHaveLength(3); |
Assert exactly one chip before clicking its close button; use user.click for option selection in selectFrom; scope option counts to the Select under test so options from other open Selects aren't counted.
Contributor
Author
|
Thanks for the review. Pushed a commit: assert there is exactly one chip before clicking its close button, use user.click for the option selection in selectFrom, and scope the option counts to the select under test so options from other open selects are not counted. |
cigamit
approved these changes
Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SUMMARY
Converts the Search component test suite (
components/Search) from enzyme to React Testing Library, continuing the enzyme → RTL migration (components, one directory per PR).Files migrated off
mountWithContexts/enzyme ontorenderWithContexts:Search,AdvancedSearch.The search-column key Select, value input/date input/operator Select, and the AdvancedSearch type/key/lookup typeaheads are driven through the real PF controls (scoped by
data-ouia-component-id); filter chips and theonSearchcallback are asserted via the rendered DOM. Behaviour and assertions are preserved.ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION
npm testforcomponents/Search: 3 suites, 29 tests, all passing (the 2 converted suites + the pre-existinggetChipsByKeyutil test). ESLint clean (--no-ignore) on the converted files. No production code changed — test-only.