enzyme -> RTL: convert the AppContainer component suites - #460
Merged
Conversation
Migrate components/AppContainer (BrandLogo, NavExpandableGroup, PageHeaderToolbar, AppContainer shell, useWsPendingApprovalCount) off enzyme/mountWithContexts onto renderWithContexts (React Testing Library). Nav/menus/About modal driven through real toggles; active nav asserted via aria-current; behaviour and assertions are preserved.
Contributor
There was a problem hiding this comment.
Pull request overview
Migrates the components/AppContainer test suites from Enzyme (mountWithContexts) to React Testing Library (renderWithContexts), aligning these component tests with the ongoing Enzyme → RTL migration strategy in the UI codebase.
Changes:
- Converted AppContainer-related component tests to RTL queries and user-event driven interactions.
- Updated navigation/menu assertions to rely on DOM attributes/roles (e.g.,
aria-current,role="menuitem",href) instead of Enzyme props. - Refactored the websocket hook test harness to assert rendered output via RTL.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| awx/ui/src/components/AppContainer/useWsPendingApprovalCount.test.js | RTL migration for websocket hook tests; replaces Enzyme prop assertions with DOM assertions. |
| awx/ui/src/components/AppContainer/PageHeaderToolbar.test.js | RTL migration for toolbar dropdowns and workflow-approval badge assertions. |
| awx/ui/src/components/AppContainer/NavExpandableGroup.test.js | RTL migration for nav link assertions and active-state checks via aria-current. |
| awx/ui/src/components/AppContainer/BrandLogo.test.js | RTL migration for BrandLogo rendering assertions. |
| awx/ui/src/components/AppContainer/AppContainer.test.js | RTL migration for AppContainer shell, About modal, and logout flows. |
Comments suppressed due to low confidence (1)
awx/ui/src/components/AppContainer/useWsPendingApprovalCount.test.js:88
- This test is named as if it verifies a refetch on workflow_approval websocket messages, but it currently doesn't assert that fetchApprovalsCount is called (the key expectation is commented out). Since useThrottle is mocked to return immediately, you should be able to assert the call after sending the message by wrapping it in async act.
// Send the websocket message
act(() => {
mockServer.send(
JSON.stringify({
unified_job_id: 2,
type: 'workflow_approval',
| expect(fiz).not.toHaveAttribute('aria-current', 'page'); | ||
| }); | ||
|
|
||
| test('when location is /foo/1/bar/fiz isActive returns false', () => { |
Comment on lines
+159
to
+160
| const dialog = await screen.findByRole('dialog'); | ||
| expect(dialog.querySelector('pre').textContent).toContain('< AWX 222 >'); |
Rename the NavExpandableGroup test to reflect that /foo stays active as a prefix match; use the version variable instead of hard-coding 222.
Contributor
Author
|
Thanks for the review. Pushed a commit: renamed the NavExpandableGroup test to reflect that /foo stays active as a prefix match, and used the version variable instead of hard-coding 222. |
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 AppContainer component test suite (
components/AppContainer) from enzyme to React Testing Library, continuing the enzyme → RTL migration (components, one directory per PR).Files migrated off
mountWithContexts/enzyme ontorenderWithContexts:BrandLogo,NavExpandableGroup,PageHeaderToolbar, theAppContainershell, anduseWsPendingApprovalCount.Navigation, the help/user dropdowns, and the About modal are driven through their real toggles; active nav is asserted via
aria-current, menu items viarole="menuitem"+href, logout via the session mock, and the approval badge via its element text. Behaviour and assertions are preserved.ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION
npm testforcomponents/AppContainer: 5 suites, 17 tests, all passing. ESLint clean (--no-ignore). No production code changed — test-only.