Skip to content

enzyme -> RTL: convert the JobList component suites - #461

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

enzyme -> RTL: convert the JobList component suites#461
cigamit merged 2 commits into
ctrliq:mainfrom
blaipr:feature/rtl-components-joblist

Conversation

@blaipr

@blaipr blaipr commented Jun 16, 2026

Copy link
Copy Markdown
Contributor
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 onto renderWithContexts: JobList, JobListItem, JobListCancelButton, and the useWsJobs websocket 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 useWsJobs exposes its result via a data-testid (RTL 12 has no renderHook). Behaviour and assertions are preserved.

ISSUE TYPE
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • UI
ADDITIONAL INFORMATION

npm test for components/JobList: 4 suites, 34 tests, all passing. ESLint clean (--no-ignore). No production code changed — test-only.

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.

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 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, and JobListCancelButton tests to RTL-style render/query/user-event patterns.
  • Updated the useWsJobs hook 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.
@blaipr

blaipr commented Jun 17, 2026

Copy link
Copy Markdown
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
cigamit merged commit 5298f1c 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