Skip to content

enzyme -> RTL: convert the AdHocCommands component suites - #462

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

enzyme -> RTL: convert the AdHocCommands component suites#462
cigamit merged 2 commits into
ctrliq:mainfrom
blaipr:feature/rtl-components-adhoccommands

Conversation

@blaipr

@blaipr blaipr commented Jun 16, 2026

Copy link
Copy Markdown
Contributor
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 onto renderWithContexts: AdHocCommands (the Run Command launcher), AdHocCommandsWizard, and the AdHocDetailsStep, AdHocCredentialStep, AdHocExecutionEnvironmentStep steps.

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
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • UI
ADDITIONAL INFORMATION

npm test for components/AdHocCommands: 5 suites, 19 tests, all passing. ESLint clean (--no-ignore). No production code changed — test-only.

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.

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

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 to renderWithContexts/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.
@blaipr

blaipr commented Jun 17, 2026

Copy link
Copy Markdown
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
cigamit merged commit 51ead7d 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