Skip to content

enzyme -> RTL: convert the Credential screen suites - #450

Merged
cigamit merged 1 commit into
ctrliq:mainfrom
blaipr:feature/rtl-batch-credential
Jun 18, 2026
Merged

enzyme -> RTL: convert the Credential screen suites#450
cigamit merged 1 commit into
ctrliq:mainfrom
blaipr:feature/rtl-batch-credential

Conversation

@blaipr

@blaipr blaipr commented Jun 16, 2026

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

  • CredentialList / CredentialListItem — load, selection, bulk delete + error
  • CredentialDetail — fields, encrypted secrets, delete + error
  • CredentialAdd / CredentialEdit — create/update API args + redirect, cancel, submit-error (shared CredentialForm mocked)
  • CredentialForm + CredentialFormFields — dynamic credential-type inputs (text/password/select/file/boolean), Replace/Revert, become method
  • ExternalTestModal, CredentialPlugins/* — plugin selection, metadata prompt (values nested under inputs), test alert

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 Credential directory: 15 suites, 78 tests, all passing. ESLint clean. No production code changed — test-only.

A few internal-prop assertions (deleteDetailsRequests length) and "initially renders" stubs were folded into behaviour-level coverage; the Edit form-field rendering is covered by CredentialForm.test.js, so the Edit container test now asserts the props it passes to the form.

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.

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 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 userEvent flows.
  • 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
cigamit merged commit abdbca8 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