enzyme -> RTL: convert the Credential screen suites - #450
Merged
Conversation
Migrate the Credential screen's test suite off enzyme/mountWithContexts onto renderWithContexts (React Testing Library): CredentialList + item, CredentialDetail, CredentialAdd/Edit (shared CredentialForm mocked), CredentialForm with its dynamic type-driven fields, the external test modal and the credential-plugin field/prompt components. 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 Credential screen’s UI test coverage from Enzyme/mount-based patterns to React Testing Library using renderWithContexts, aligning interactions with accessible roles and realistic user events while preserving existing behavioral assertions.
Changes:
- Converted Credential shared/plugin tests (External Test modal, plugin selection/prompt/alert) to RTL queries and
userEventflows. - Updated Credential form and field tests to assert user-visible behavior (including PF Select interactions and GCE file upload handling in jsdom).
- Migrated list/detail/add/edit container tests to RTL patterns, adjusting mocks and assertions to match actual runtime wiring.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| awx/ui/src/screens/Credential/shared/ExternalTestModal.test.js | RTL migration for ExternalTestModal assertions and API payload expectations. |
| awx/ui/src/screens/Credential/shared/CredentialPlugins/CredentialPluginTestAlert.test.js | RTL assertions for success/failure alert message formatting. |
| awx/ui/src/screens/Credential/shared/CredentialPlugins/CredentialPluginSelected.test.js | RTL migration for selected plugin chip/actions behavior. |
| awx/ui/src/screens/Credential/shared/CredentialPlugins/CredentialPluginPrompt/CredentialPluginPrompt.test.js | RTL migration for wizard flow, selection, metadata entry, and submit/test behaviors. |
| awx/ui/src/screens/Credential/shared/CredentialPlugins/CredentialPluginField.test.js | RTL migration for plugin field button behavior and prompt visibility. |
| awx/ui/src/screens/Credential/shared/CredentialFormFields/CredentialField.test.js | RTL migration for encrypted-secret field behavior (replace/revert) and external-plugin affordance. |
| awx/ui/src/screens/Credential/shared/CredentialFormFields/BecomeMethodField.test.js | RTL migration for PF select open/options assertions. |
| awx/ui/src/screens/Credential/shared/CredentialForm.test.js | RTL migration for form rendering across credential types, PF select interaction, and file upload behavior. |
| awx/ui/src/screens/Credential/CredentialList/CredentialListItem.test.js | RTL migration for row actions (edit/copy) and copy error modal. |
| awx/ui/src/screens/Credential/CredentialList/CredentialList.test.js | RTL migration for list load, selection, bulk delete, and delete-error modal handling. |
| awx/ui/src/screens/Credential/CredentialEdit/CredentialEdit.test.js | RTL migration using mocked CredentialForm props to validate container wiring and submit/cancel flows. |
| awx/ui/src/screens/Credential/CredentialDetail/CredentialDetail.test.js | RTL migration for detail rendering, related delete-lookup stubbing, and delete flows. |
| awx/ui/src/screens/Credential/CredentialAdd/CredentialAdd.test.js | RTL migration using mocked CredentialForm props to validate create + redirect and cancel flow. |
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 Credential 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:CredentialList/CredentialListItem— load, selection, bulk delete + errorCredentialDetail— fields, encrypted secrets, delete + errorCredentialAdd/CredentialEdit— create/update API args + redirect, cancel, submit-error (sharedCredentialFormmocked)CredentialForm+CredentialFormFields— dynamic credential-type inputs (text/password/select/file/boolean), Replace/Revert, become methodExternalTestModal,CredentialPlugins/*— plugin selection, metadata prompt (values nested underinputs), test alertInteractions now go through accessible roles and real user events. Behaviour and assertions are preserved.
ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION
npm testfor the Credential directory: 15 suites, 78 tests, all passing. ESLint clean. No production code changed — test-only.A few internal-prop assertions (
deleteDetailsRequestslength) and "initially renders" stubs were folded into behaviour-level coverage; the Edit form-field rendering is covered byCredentialForm.test.js, so the Edit container test now asserts the props it passes to the form.