enzyme -> RTL: convert the JobList component suites - #461
Merged
Conversation
Migrate components/JobList (JobList, JobListItem, JobListCancelButton, and the useWsJobs websocket hook) off enzyme/mountWithContexts onto renderWithContexts (React Testing Library). Bulk delete/cancel are driven through the real toolbar -> confirm-modal path; behaviour and assertions are preserved.
Contributor
There was a problem hiding this comment.
Pull request overview
Migrates the shared JobList component test suites from Enzyme (mountWithContexts) to React Testing Library (renderWithContexts) as part of the ongoing enzyme → RTL conversion in awx/ui.
Changes:
- Converted
JobList,JobListItem, andJobListCancelButtontests to RTL-style render/query/user-event patterns. - Updated the
useWsJobshook tests to exercise the hook via a test component and assert via DOM state rather than Enzyme props. - Adjusted bulk delete/cancel coverage to drive the real toolbar → confirm-modal flows.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
awx/ui/src/components/JobList/useWsJobs.test.js |
Replaces Enzyme hook harness with RTL render + DOM assertions for websocket-driven updates. |
awx/ui/src/components/JobList/JobListItem.test.js |
Converts row rendering and relaunch/dropdown assertions from Enzyme to RTL queries. |
awx/ui/src/components/JobList/JobListCancelButton.test.js |
Converts tooltip/disabled-state and modal behavior tests to RTL user interactions. |
awx/ui/src/components/JobList/JobList.test.js |
Converts selection, bulk delete/cancel flows, and error modal assertions to RTL patterns. |
Comment on lines
23
to
31
| @@ -27,35 +29,28 @@ describe('useWsJobs hook', () => { | |||
| __esModule: true, | |||
| default: jest.fn((val) => val), | |||
| })); | |||
Comment on lines
1
to
6
| import React from 'react'; | ||
| import { act } from 'react-dom/test-utils'; | ||
| import { act, screen, waitFor } from '@testing-library/react'; | ||
| import WS from 'jest-websocket-mock'; | ||
| import { mountWithContexts } from '../../../testUtils/enzymeHelpers'; | ||
| import { renderWithContexts } from '../../../testUtils/rtlContexts'; | ||
| import useWsJobs from './useWsJobs'; | ||
|
|
Comment on lines
+256
to
+257
| await user.click(toggle); | ||
| expect(screen.getAllByRole('menuitem')).toHaveLength(3); |
Remove the ineffective beforeEach jest.mock of useThrottle and document why (activating it at module scope changes throttle timing and breaks the websocket assertions); await the relaunch menu items with findAllByRole since the PF popper renders them asynchronously.
Contributor
Author
|
Thanks for the review. Pushed a commit: removed the ineffective beforeEach mock of useThrottle and documented why (activating it at module scope changes the throttle timing and breaks the websocket assertions), and used findAllByRole for the relaunch menu since the popper renders it asynchronously. |
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 shared JobList component test suite (
components/JobList) from enzyme to React Testing Library, continuing the enzyme → RTL migration (components, one directory per PR).Files migrated off
mountWithContexts/enzyme ontorenderWithContexts:JobList,JobListItem,JobListCancelButton, and theuseWsJobswebsocket hook.Bulk delete/cancel are driven through the real toolbar → confirm-modal path (with deletable/cancelable fixtures so the buttons are enabled), selection asserted via checkbox state, relaunch via the row's Relaunch button/dropdown, and
useWsJobsexposes its result via adata-testid(RTL 12 has norenderHook). Behaviour and assertions are preserved.ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION
npm testforcomponents/JobList: 4 suites, 34 tests, all passing. ESLint clean (--no-ignore). No production code changed — test-only.