enzyme -> RTL: convert the AdHocCommands component suites - #462
Merged
cigamit merged 2 commits intoJun 18, 2026
Conversation
Migrate components/AdHocCommands (the Run Command launcher, its wizard, and the module/credential/execution-environment steps) off enzyme/mountWithContexts onto renderWithContexts (React Testing Library). The wizard is driven through the real Next/Launch controls and selects; the launch payload is asserted. Behaviour and assertions are preserved.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR continues the UI test migration from Enzyme to React Testing Library (RTL) by converting the AdHocCommands component suite, covering the wizard flow and its step components. It keeps behavior-oriented assertions (driving the wizard via real buttons/inputs) while removing Enzyme-specific helpers.
Changes:
- Migrates AdHocCommands and wizard step test suites from
mountWithContexts/Enzyme torenderWithContexts/RTL. - Updates tests to advance the wizard through real UI interactions and assert the resulting launch payload.
- Adds RTL-specific handling for PatternFly tooltip timing (
settleTooltips) to avoid unmount warnings.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| awx/ui/src/components/AdHocCommands/AdHocExecutionEnironmentStep.test.js | Converts execution environment step tests from Enzyme to RTL. |
| awx/ui/src/components/AdHocCommands/AdHocDetailsStep.test.js | Converts details step tests to RTL with user-driven form interactions. |
| awx/ui/src/components/AdHocCommands/AdHocCredentialStep.test.js | Converts credential step tests from Enzyme to RTL. |
| awx/ui/src/components/AdHocCommands/AdHocCommandsWizard.test.js | Reworks wizard tests to step through UI and assert launch payloads/errors. |
| awx/ui/src/components/AdHocCommands/AdHocCommands.test.js | Converts top-level AdHocCommands tests to RTL, including launching and error flows. |
| expect(screen.getByText('Extra variables')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('shold update form values', async () => { |
Comment on lines
+97
to
+99
| // verbosity options come from VerbositySelectField; "1" maps to "1 (Verbose)" | ||
| await user.selectOptions(verbositySelect, '1 (Verbose)'); | ||
| await user.clear(forksInput); |
Comment on lines
+41
to
+44
| await user.selectOptions(document.querySelector('#module_name'), 'command'); | ||
| await user.type(document.querySelector('#module_args'), 'foo'); | ||
| await user.selectOptions(document.querySelector('#verbosity'), '1 (Verbose)'); | ||
| } |
Comment on lines
+62
to
+65
| await user.selectOptions(document.querySelector('#module_name'), 'command'); | ||
| await user.type(document.querySelector('#module_args'), 'foo'); | ||
| await user.selectOptions(document.querySelector('#verbosity'), '1 (Verbose)'); | ||
| await user.click(screen.getByRole('button', { name: 'Next' })); |
Comment on lines
223
to
226
| // step 4: credential passwords - the ssh password field is rendered | ||
| const sshPassword = await waitFor(() => | ||
| document.querySelector('input[name="credential_passwords.ssh_password"]') | ||
| ); |
Fix a test-name typo; select verbosity by its stable option value (1) instead of the i18n label; assert the ssh password field inside waitFor so a null querySelector can't resolve early.
Contributor
Author
|
Thanks for the review. Pushed a commit: fixed the test-name typo, selected verbosity by its stable option value, and asserted the ssh password field inside waitFor so a null querySelector cannot resolve early. |
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 AdHocCommands component test suite (
components/AdHocCommands) from enzyme to React Testing Library, continuing the enzyme → RTL migration (components, one directory per PR).Files migrated off
mountWithContexts/enzyme ontorenderWithContexts:AdHocCommands(the Run Command launcher),AdHocCommandsWizard, and theAdHocDetailsStep,AdHocCredentialStep,AdHocExecutionEnvironmentStepsteps.The wizard is stepped through with the real Next/Launch buttons and
FormSelect/radio selections; the launch payload is asserted (verbosity is the option-key string'1', matching runtime). Behaviour and assertions are preserved.ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION
npm testforcomponents/AdHocCommands: 5 suites, 19 tests, all passing. ESLint clean (--no-ignore). No production code changed — test-only.