enzyme -> RTL: convert the Team screen suites - #436
Merged
Conversation
Migrate the Team screen's test suite off enzyme/mountWithContexts onto renderWithContexts (React Testing Library): TeamList, TeamListItem, TeamDetail, TeamAdd, TeamEdit, TeamForm, TeamRoleListItem and TeamRolesList. Behaviour and assertions are preserved; list/detail interactions now go through accessible roles and real user events.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR continues the UI test-suite migration away from Enzyme by converting the Team screen tests to React Testing Library. The updates align tests with user-visible behavior by exercising accessible roles and real user events, without changing production code.
Changes:
- Migrated Team screen-related test suites from Enzyme
mountWithContextsto RTLrenderWithContexts. - Updated assertions to use RTL queries (
screen,within,waitFor) and user interactions (userEvent). - Simplified/mocked form interactions in add/edit tests to focus on API calls, navigation, and error surfacing.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| awx/ui/src/screens/Team/TeamRoles/TeamRolesList.test.js | Converts Team roles list tests to RTL, including detail URLs, add-button visibility, and disassociate flows. |
| awx/ui/src/screens/Team/TeamRoles/TeamRoleListItem.test.js | Converts role row rendering tests to RTL and asserts link/chip behavior via roles. |
| awx/ui/src/screens/Team/TeamList/TeamListItem.test.js | Converts list item rendering and edit-capability visibility tests to RTL. |
| awx/ui/src/screens/Team/TeamList/TeamList.test.js | Converts Team list suite to RTL including selection, select-all, delete/confirm, refetch, and add-button visibility. |
| awx/ui/src/screens/Team/TeamEdit/TeamEdit.test.js | Converts edit flow tests to RTL with a mocked TeamForm to validate update + navigation + submit error. |
| awx/ui/src/screens/Team/TeamDetail/TeamDetail.test.js | Converts detail rendering and delete/error flows to RTL and uses shared RTL helpers for Detail assertions. |
| awx/ui/src/screens/Team/TeamAdd/TeamAdd.test.js | Converts add flow tests to RTL with a mocked TeamForm to validate create + redirect + submit error. |
| awx/ui/src/screens/Team/Team.test.js | Minor assertion/comment tweak while keeping RTL-based route/param behavior coverage. |
| awx/ui/src/screens/Team/shared/TeamForm.test.js | Converts TeamForm interaction tests to RTL (field editing + Save/Cancel handlers). |
Comment on lines
+13
to
+24
| const makeTeam = (overrides = {}) => ({ | ||
| name: 'Foo', | ||
| description: 'Bar', | ||
| created: '2015-07-07T17:21:26.429745Z', | ||
| modified: '2019-08-11T19:47:37.980466Z', | ||
| summary_fields: { | ||
| organization: { id: 1, name: 'Default' }, | ||
| user_capabilities: { edit: true, delete: true }, | ||
| ...(overrides.summary_fields || {}), | ||
| }, | ||
| ...overrides, | ||
| }); |
Contributor
Author
|
Thanks for the review. makeTeam now applies the overrides before the summary_fields merge, so a summary_fields override no longer clobbers the merged value. |
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 Team 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:TeamList/TeamListItem— load, row selection, select-all, bulk delete + re-fetch, deletion-error modal, add-button visibilityTeamDetail— detail fields, edit-button visibility, delete + deletion-error dialogTeamAdd/TeamEdit— submit-to-API + redirect, cancel navigation, submit-error surface (sharedTeamFormmocked)TeamForm— input updates, Save/Cancel handlersTeamRoleListItem/TeamRolesList— row data, detail URLs, disassociate modal + API call, disassociation error, sys-admin empty stateInteractions now go through accessible roles and real user events. Behaviour and assertions are preserved.
ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION
npm testfor the Team directory: 10 suites, 43 tests, all passing. ESLint clean. No production code changed — test-only.