Skip to content

enzyme -> RTL: convert the Team screen suites - #436

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

enzyme -> RTL: convert the Team screen suites#436
cigamit merged 2 commits into
ctrliq:mainfrom
blaipr:feature/rtl-batch-team

Conversation

@blaipr

@blaipr blaipr commented Jun 16, 2026

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

  • TeamList / TeamListItem — load, row selection, select-all, bulk delete + re-fetch, deletion-error modal, add-button visibility
  • TeamDetail — detail fields, edit-button visibility, delete + deletion-error dialog
  • TeamAdd / TeamEdit — submit-to-API + redirect, cancel navigation, submit-error surface (shared TeamForm mocked)
  • TeamForm — input updates, Save/Cancel handlers
  • TeamRoleListItem / TeamRolesList — row data, detail URLs, disassociate modal + API call, disassociation error, sys-admin empty state

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

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.
@blaipr blaipr changed the title Convert Team screen tests from enzyme to React Testing Library enzyme -> RTL: convert the Team screen suites Jun 16, 2026
@cigamit
cigamit requested a review from Copilot June 17, 2026 07:34

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

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 mountWithContexts to RTL renderWithContexts.
  • 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,
});
@blaipr

blaipr commented Jun 17, 2026

Copy link
Copy Markdown
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
cigamit merged commit 29cc05a 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