enzyme -> RTL: convert the Instances screen suites - #437
Merged
Conversation
Migrate the Instances screen's test suite off enzyme/mountWithContexts onto renderWithContexts (React Testing Library): InstanceList items, InstanceDetail (health-check + capacity slider), InstanceAdd/InstanceEdit (shared InstanceForm mocked) and InstanceForm. 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
This PR continues the incremental migration of the Instances screen UI test suites from Enzyme to React Testing Library (RTL), updating tests to use accessible queries and user-driven interactions while preserving existing behavioral coverage.
Changes:
- Migrated
InstanceForm,InstanceAdd, andInstanceEdittests from enzymemountWithContextsto RTLrenderWithContexts. - Updated
InstanceListItemandInstanceDetailtests to drive PatternFly slider behavior via keyboard interaction and assert against rendered DOM. - Introduced small helper functions/stubs inside tests to keep RTL setups focused (e.g.,
computeForks, mockedInstanceForm).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| awx/ui/src/screens/Instances/Shared/InstanceForm.test.js | Converts form field and submit/cancel tests to RTL user interactions. |
| awx/ui/src/screens/Instances/InstanceList/InstanceListItem.test.js | Migrates list-row interaction tests to RTL; adds slider keyboard interactions and DOM assertions. |
| awx/ui/src/screens/Instances/InstanceEdit/InstanceEdit.test.js | Switches to RTL; stubs shared form to validate container submit/cancel/error flows. |
| awx/ui/src/screens/Instances/InstanceDetail/InstanceDetail.test.js | Converts detail screen tests to RTL, including slider and health-check error modal assertions. |
| awx/ui/src/screens/Instances/InstanceAdd/InstanceAdd.test.js | Switches to RTL; stubs shared form to validate create + navigation behavior. |
Comment on lines
207
to
216
| const slider = screen.getByRole('slider'); | ||
| slider.focus(); | ||
| // Any slider change triggers the (mocked-immediate) update which rejects. | ||
| await user.keyboard('{ArrowRight}'); | ||
|
|
||
| await waitFor(() => | ||
| expect(InstancesAPI.update).toHaveBeenCalledWith(1, { | ||
| capacity_adjustment: 1, | ||
| }) | ||
| ); |
Contributor
Author
|
Thanks for the review. The capacity test now asserts the slider value computed from the 0.1 step rather than a hard-coded 1. |
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 Instances 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:InstanceList/InstanceListItem— row data, progress bar, expanded-row details, hop-node hiding, capacity-slider fork recomputeInstanceDetail— detail fields, health-check button state + error modal, instance enable/disable toggle, capacity sliderInstanceAdd/InstanceEdit— create/update API args + redirect, cancel navigation, submit-error branch (sharedInstanceFormmocked)InstanceForm— input updates and submit payload (tooltip-labelled fields queried by id)Interactions now go through accessible roles and real user events. Behaviour and assertions are preserved.
ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION
npm testfor the Instances directory: 9 suites, 43 tests, all passing. ESLint clean. No production code changed — test-only.One list-item error-path test was adapted rather than asserting a visible modal: the component renders that
AlertModalwith noisOpenprop, so PatternFly never mounts it to the DOM (enzyme matched the closed React element; RTL sees no DOM node). The identical error branch is still exercised and the rejected API call asserted, with a code comment explaining the component quirk.