Skip to content

enzyme -> RTL: convert the Host screen suites - #446

Merged
cigamit merged 2 commits into
ctrliq:mainfrom
blaipr:feature/rtl-batch-host
Jun 18, 2026
Merged

enzyme -> RTL: convert the Host screen suites#446
cigamit merged 2 commits into
ctrliq:mainfrom
blaipr:feature/rtl-batch-host

Conversation

@blaipr

@blaipr blaipr commented Jun 16, 2026

Copy link
Copy Markdown
Contributor
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 onto renderWithContexts:

  • HostList / HostListItem — load, row selection (disambiguated from the host enable/disable toggle), bulk delete, edit-link visibility
  • HostDetail — detail fields, activity-stream hide behaviour
  • HostFacts — facts load + content error
  • HostAdd / HostEdit — create/update API args + redirect, cancel, submit-error (components/HostForm mocked)
  • SmartInventoryButton, HostGroups list/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
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • UI
ADDITIONAL INFORMATION

npm test for the Host directory: 12 suites, 58 tests, all passing. ESLint clean. No production code changed — test-only.

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/HostForm where 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();
@blaipr

blaipr commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. The disassociate-error test now closes the Error modal while still mounted and settles tooltips before finishing.

@cigamit
cigamit merged commit 6e2a9e2 into ctrliq:main Jun 18, 2026
@cigamit cigamit self-assigned this Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants