enzyme -> RTL: convert the Lookup component suites - #455
Merged
Conversation
Migrate components/Lookup (the base Lookup plus the typed lookups: Organization, Project, Credential, Inventory, ExecutionEnvironment, Application, InstanceGroups, Peers, MultiCredentials, and HostListItem) off enzyme/mountWithContexts onto renderWithContexts (React Testing Library). Lookup modals are driven through the real Search/Select flow; behaviour and assertions are preserved.
Contributor
There was a problem hiding this comment.
Pull request overview
Migrates the components/Lookup test suites from enzyme-based mounting (mountWithContexts) to React Testing Library (renderWithContexts), updating assertions and interactions to use RTL queries and userEvent while preserving existing behavioral intent.
Changes:
- Replaced enzyme
mountWithContexts/actpatterns with RTLrenderWithContexts,screen,within, andwaitFor. - Updated Lookup modal tests to drive the UI via real button clicks and dialog interactions (Search → select → Select/Cancel).
- Standardized API mocking to
mockResolvedValue/mockResolvedValueOncewhere appropriate and adjusted assertions to async rendering.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| awx/ui/src/components/Lookup/Lookup.test.js | Rewrites core Lookup behavior tests (modal open/close, chip removal, canDelete, loading-disable) using RTL. |
| awx/ui/src/components/Lookup/HostListItem.test.js | Converts HostListItem rendering assertions to role-based RTL cell checks. |
| awx/ui/src/components/Lookup/ProjectLookup.test.js | Migrates ProjectLookup suite to RTL and updates auto-populate / enabled/disabled / helper-text assertions. |
| awx/ui/src/components/Lookup/OrganizationLookup.test.js | Migrates OrganizationLookup suite to RTL and updates auto-populate behavior assertions. |
| awx/ui/src/components/Lookup/CredentialLookup.test.js | Migrates CredentialLookup suite to RTL, including auto-select behavior and defaultProps checks. |
| awx/ui/src/components/Lookup/InventoryLookup.test.js | Migrates InventoryLookup suite to RTL and updates API call assertions and disabled-state checks. |
| awx/ui/src/components/Lookup/ExecutionEnvironmentLookup.test.js | Migrates ExecutionEnvironmentLookup suite to RTL and updates organization/project-derived API assertions. |
| awx/ui/src/components/Lookup/InstanceGroupsLookup.test.js | Migrates InstanceGroupsLookup suite to RTL and updates prompt checkbox assertions. |
| awx/ui/src/components/Lookup/PeersLookup.test.js | Migrates PeersLookup suite to RTL and updates “prompt on launch” absence checks. |
| awx/ui/src/components/Lookup/MultiCredentialsLookup.test.js | Migrates MultiCredentialsLookup suite to RTL, covering chip removal, category switching, query param reset, and vault selection behaviors. |
| awx/ui/src/components/Lookup/ApplicationLookup.test.js | Migrates ApplicationLookup suite to RTL and updates fixtures/mocking for fetch behavior. |
Comment on lines
+24
to
+27
| { | ||
| id: 4, | ||
| name: 'application that should not crach', | ||
| description: '', |
Comment on lines
+33
to
+37
| beforeEach(() => { | ||
| ApplicationsAPI.read.mockResolvedValueOnce(fetchedApplications); | ||
| ApplicationsAPI.readOptions = { | ||
| data: { actions: { GET: {} }, related_search_fields: [] }, | ||
| }; |
Call ApplicationsAPI.readOptions() (it was awaited un-called, so OPTIONS data was never fetched) to match the other lookups; mock it via mockResolvedValue in the test and fix a fixture typo.
Contributor
Author
|
Thanks for the review. Pushed a commit: ApplicationLookup now calls readOptions() (it was awaited without being called, so options were never fetched), the test mocks it with mockResolvedValue, and the fixture typo is fixed. |
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 Lookup component test suite (
components/Lookup) from enzyme to React Testing Library, continuing the enzyme → RTL migration (components, one directory per PR).Files migrated off
mountWithContexts/enzyme ontorenderWithContexts: the baseLookup,HostListItem, and the typed lookups — Organization, Project, Credential, Inventory, ExecutionEnvironment, Application, InstanceGroups, Peers, and MultiCredentials.Lookup modals are driven through the real Search → row-select → Select flow; disabled state is asserted on the Search button, labels by visible text, and auto-populate via the
onChangepayload. Behaviour and assertions are preserved.ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION
npm testforcomponents/Lookup: 13 suites, 92 tests, all passing. ESLint clean (--no-ignore). No production code changed — test-only.