Skip to content

enzyme -> RTL: convert the Lookup component suites - #455

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

enzyme -> RTL: convert the Lookup component suites#455
cigamit merged 2 commits into
ctrliq:mainfrom
blaipr:feature/rtl-components-lookup

Conversation

@blaipr

@blaipr blaipr commented Jun 16, 2026

Copy link
Copy Markdown
Contributor
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 onto renderWithContexts: the base Lookup, 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 onChange payload. Behaviour and assertions are preserved.

ISSUE TYPE
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • UI
ADDITIONAL INFORMATION

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

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.

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 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/act patterns with RTL renderWithContexts, screen, within, and waitFor.
  • Updated Lookup modal tests to drive the UI via real button clicks and dialog interactions (Search → select → Select/Cancel).
  • Standardized API mocking to mockResolvedValue/mockResolvedValueOnce where 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.
@blaipr

blaipr commented Jun 17, 2026

Copy link
Copy Markdown
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
cigamit merged commit 44b4658 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