enzyme -> RTL: convert the Host screen suites - #446
Merged
Conversation
Migrate the Host screen's test suite off enzyme/mountWithContexts onto renderWithContexts (React Testing Library): HostList + item (incl. the enable/disable toggle), HostDetail, HostFacts, HostAdd/Edit (HostForm mocked), SmartInventoryButton and HostGroups list/item. Behaviour and assertions are preserved; interactions go through accessible roles and real user events.
Contributor
There was a problem hiding this comment.
Pull request overview
Migrates the Host screen test suites from enzyme (mountWithContexts) to React Testing Library (renderWithContexts), aligning Host UI tests with the ongoing incremental enzyme → RTL strategy and updating assertions to use accessible roles and user-event interactions.
Changes:
- Rewrote Host List/Item and Smart Inventory tests to use RTL queries and real user interactions (selection vs toggle disambiguation, bulk delete, navigation).
- Updated Host Groups tests to mount under a real v6 route (v5-compat) and exercise associate/disassociate flows via the modal UI.
- Converted Host Add/Edit/Detail/Facts tests to RTL patterns, including mocking
components/HostFormwhere needed to drive submit/cancel/error branches.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| awx/ui/src/screens/Host/HostList/SmartInventoryButton.test.js | Converts Smart Inventory button test to RTL role-based query + user-event click. |
| awx/ui/src/screens/Host/HostList/HostListItem.test.js | Converts list item rendering assertions (link, description, edit visibility, toggle) to RTL. |
| awx/ui/src/screens/Host/HostList/HostList.test.js | Converts Host list suite to RTL, including selection, delete modal flow, and navigation assertions. |
| awx/ui/src/screens/Host/HostGroups/HostGroupsList.test.js | Converts Host groups list suite to RTL under a v6 route and updates associate/disassociate modal flows. |
| awx/ui/src/screens/Host/HostGroups/HostGroupItem.test.js | Converts Host group row tests to RTL (render + edit link visibility). |
| awx/ui/src/screens/Host/HostFacts/HostFacts.test.js | Converts facts load/error coverage to RTL; asserts label due to react-ace jsdom limitations. |
| awx/ui/src/screens/Host/HostEdit/HostEdit.test.js | Converts Host edit suite to RTL using a mocked HostForm to trigger submit/cancel/error branches. |
| awx/ui/src/screens/Host/HostDetail/HostDetail.test.js | Converts Host detail suite to RTL and adds shared assertDetail helper usage. |
| awx/ui/src/screens/Host/HostAdd/HostAdd.test.js | Converts Host add suite to RTL using a mocked HostForm to trigger submit/cancel/error branches. |
Comment on lines
+278
to
+282
| await user.click( | ||
| screen.getByRole('button', { name: 'confirm disassociate' }) | ||
| ); | ||
| await act(async () => { | ||
| wrapper | ||
| .find('button[aria-label="confirm disassociate"]') | ||
| .simulate('click'); | ||
| }); | ||
| wrapper.update(); | ||
| expect(wrapper.find('AlertModal ErrorDetail').length).toBe(1); | ||
|
|
||
| expect(await screen.findByText('Error!')).toBeInTheDocument(); |
Contributor
Author
|
Thanks for the review. The disassociate-error test now closes the Error modal while still mounted and settles tooltips before finishing. |
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 Host screen's test suite from enzyme to React Testing Library, continuing the incremental enzyme → RTL migration (one screen directory per PR).
Files migrated off
mountWithContexts/enzyme ontorenderWithContexts:HostList/HostListItem— load, row selection (disambiguated from the host enable/disable toggle), bulk delete, edit-link visibilityHostDetail— detail fields, activity-stream hide behaviourHostFacts— facts load + content errorHostAdd/HostEdit— create/update API args + redirect, cancel, submit-error (components/HostFormmocked)SmartInventoryButton,HostGroupslist/item — navigation, associate modal (under a real v6 route)Interactions now go through accessible roles and real user events. Behaviour and assertions are preserved.
ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION
npm testfor the Host directory: 12 suites, 58 tests, all passing. ESLint clean. No production code changed — test-only.