Skip to content

enzyme -> RTL: convert the Organization screen suites - #447

Merged
cigamit merged 3 commits into
ctrliq:mainfrom
blaipr:feature/rtl-batch-organization
Jun 18, 2026
Merged

enzyme -> RTL: convert the Organization screen suites#447
cigamit merged 3 commits into
ctrliq:mainfrom
blaipr:feature/rtl-batch-organization

Conversation

@blaipr

@blaipr blaipr commented Jun 16, 2026

Copy link
Copy Markdown
Contributor
SUMMARY

Converts the Organization 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:

  • OrganizationList / OrganizationListItem — load, selection, bulk delete + related-delete-request count, deletion error
  • OrganizationDetail — detail fields, empty instance-groups/galaxy-credentials, related-delete-request count
  • OrganizationAdd / OrganizationEdit — create/update with instance-group associate/disassociate, galaxy credentials, max-hosts (shared OrganizationForm mocked)
  • OrganizationForm — fields, lookups (mocked), default galaxy credential, instance group add
  • OrganizationExecEnvList + item, OrganizationTeamList + item — list idioms

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

Two redundant tests were folded rather than duplicated: an Add-mode "AnsibleSelect does not render" assertion (it tested the real form's internal rendering, which is now mocked in the Add container suite and covered by the OrganizationForm suite) and two trivial "should mount successfully" duplicates subsumed by stronger row-render assertions.

Migrate the Organization screen's test suite off enzyme/mountWithContexts
onto renderWithContexts (React Testing Library): OrganizationList + item,
OrganizationDetail, OrganizationAdd/Edit (shared OrganizationForm mocked),
OrganizationForm, and the ExecEnv and Teams sublists. 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 Organization screen’s UI test suites from enzyme (mountWithContexts) to React Testing Library (renderWithContexts), aligning tests with accessible queries and real user interactions while keeping coverage focused on behavior.

Changes:

  • Converted Organization list/detail/add/edit/form tests to RTL patterns (screen, userEvent, waitFor) with mocked lookups where needed.
  • Updated Organization teams and execution environments list/item suites to RTL table idioms and error rendering assertions.
  • Refactored some assertions to be more user-facing (roles/labels) and reduced redundant mount-only tests.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
awx/ui/src/screens/Organization/shared/OrganizationForm.test.js RTL conversion with deterministic lookup mocks and user-event driven form assertions
awx/ui/src/screens/Organization/OrganizationTeams/OrgnizationTeamListItem.test.js RTL conversion of team list row assertions
awx/ui/src/screens/Organization/OrganizationTeams/OrganizationTeamList.test.js RTL conversion for team list loading, rendering, and error states
awx/ui/src/screens/Organization/OrganizationList/OrganizationListItem.test.js RTL conversion for org list row rendering and edit capability checks
awx/ui/src/screens/Organization/OrganizationList/OrganizationList.test.js RTL conversion for list loading, selection, bulk delete, and error modal behavior
awx/ui/src/screens/Organization/OrganizationExecEnvList/OrganizationExecEnvListItem.test.js RTL conversion for execution environment row rendering assertions
awx/ui/src/screens/Organization/OrganizationExecEnvList/OrganizationExecEnvList.test.js RTL conversion for execution environments list rendering and add-button visibility
awx/ui/src/screens/Organization/OrganizationEdit/OrganizationEdit.test.js RTL conversion using a mocked OrganizationForm to drive submit/cancel behavior
awx/ui/src/screens/Organization/OrganizationDetail/OrganizationDetail.test.js RTL conversion for details rendering, delete flows, and permission-gated actions
awx/ui/src/screens/Organization/OrganizationAdd/OrganizationAdd.test.js RTL conversion using a mocked OrganizationForm to drive create/cancel flows

Comment on lines 92 to 96
renderWithContexts(<OrganizationDetail organization={mockOrganization} />);
const editButton = await screen.findByRole('link', { name: 'Edit' });
expect(editButton).toHaveTextContent('Edit');
expect(editButton).toHaveAttribute('href', '/organizations/undefined/edit');
});
Comment on lines 216 to 218
const onSubmit = jest.fn();
OrganizationsAPI.update.mockResolvedValue(1, mockDataForm);
OrganizationsAPI.associateInstanceGroup.mockResolvedValue('done');
Comment on lines +179 to +180
expect(await screen.findByText('Error!')).toBeInTheDocument();
await settleTooltips();
@@ -1,57 +1,41 @@
import React from 'react';
blaipr added 2 commits June 17, 2026 11:34
Render OrganizationDetail under a real route so the Edit link resolves /organizations/12/edit (not undefined); drop the dead settleTooltips() call on the open error modal; pass a single value to OrganizationsAPI.update.mockResolvedValue; rename the misspelled OrgnizationTeamListItem test file.
Render OrganizationDetail under a real route so the Edit link resolves /organizations/12/edit (not undefined); drop the dead settleTooltips() call on the open error modal; pass a single value to OrganizationsAPI.update.mockResolvedValue.
@blaipr

blaipr commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Pushed a commit: OrganizationDetail renders under a real route so the Edit link resolves to /organizations/12/edit instead of undefined, the dead settleTooltips call on the still-open error modal is dropped, update.mockResolvedValue now takes a single value, and the misspelled OrgnizationTeamListItem test file is renamed to OrganizationTeamListItem.

@cigamit
cigamit merged commit c72db3b 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