enzyme -> RTL: convert the WorkflowApproval screen suites - #445
Conversation
Migrate the WorkflowApproval screen's test suite off enzyme/mountWithContexts onto renderWithContexts (React Testing Library): approve/deny buttons, WorkflowApprovalList + item, the detail view, and the useWsWorkflowApprovals hook. Behaviour and assertions are preserved; interactions go through accessible roles and real user events.
There was a problem hiding this comment.
⚠️ Not ready to approve
The WorkflowApprovalList delete-flow RTL tests need additional modal/tooltip settling to avoid known PatternFly tooltip-on-focus flake patterns that can fail subsequent tests.
Pull request overview
Migrates the WorkflowApproval screen’s unit/integration tests from Enzyme (mountWithContexts) to React Testing Library (renderWithContexts), aligning the suite with accessible queries and user-driven interactions as part of the incremental Enzyme → RTL conversion effort.
Changes:
- Converted list, list-item, and shared approve/deny button tests to RTL using
screen,within, anduserEvent. - Updated list flows to exercise selection and bulk delete via DOM interactions and accessible roles/names.
- Updated detail and websocket-hook tests to assert rendered output (including mocking
VariablesDetailfor jsdom visibility).
File summaries
| File | Description |
|---|---|
| awx/ui/src/screens/WorkflowApproval/WorkflowApprovalList/WorkflowApprovalListItem.test.js | Replaces Enzyme component introspection with DOM assertions for list item status rendering. |
| awx/ui/src/screens/WorkflowApproval/WorkflowApprovalList/WorkflowApprovalListDenyButton.test.js | Converts deny toolbar button tests to RTL with role/name queries and user hover for tooltip. |
| awx/ui/src/screens/WorkflowApproval/WorkflowApprovalList/WorkflowApprovalListApproveButton.test.js | Converts approve toolbar button tests to RTL with role/name queries and hover tooltip assertion. |
| awx/ui/src/screens/WorkflowApproval/WorkflowApprovalList/WorkflowApprovalList.test.js | Reworks list behavior tests (load, select, select-all, bulk delete, deletion error) to use real user interactions. |
| awx/ui/src/screens/WorkflowApproval/WorkflowApprovalList/useWsWorkflowApprovals.test.js | Converts websocket hook tests to RTL by rendering hook output into the DOM for assertions. |
| awx/ui/src/screens/WorkflowApproval/WorkflowApprovalDetail/WorkflowApprovalDetail.test.js | Converts detail view tests to RTL and mocks VariablesDetail to assert extra vars under jsdom. |
| awx/ui/src/screens/WorkflowApproval/shared/WorkflowDenyButton.test.js | Converts shared deny button tests to RTL, validating disabled state via accessible name and API call behavior. |
| awx/ui/src/screens/WorkflowApproval/shared/WorkflowApprovalButton.test.js | Converts shared approve button tests to RTL, validating disabled state and API call behavior. |
Copilot's findings
- Files reviewed: 8/8 changed files
- Comments generated: 2
Note
Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.
| await user.click(screen.getByRole('button', { name: 'Delete' })); | ||
| await user.click( | ||
| await screen.findByRole('button', { name: 'confirm delete' }) | ||
| ); | ||
|
|
| expect(screen.getByRole('button', { name: 'Delete' })).toBeEnabled(); | ||
| await user.click(screen.getByRole('button', { name: 'Delete' })); | ||
| await user.click( | ||
| await screen.findByRole('button', { name: 'confirm delete' }) | ||
| ); |
|
Thanks for the review. Both deletion tests close the error modal and call settleTooltips after confirming, so the focus-restore tooltip is settled before the test ends. |
SUMMARY
Converts the WorkflowApproval 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:WorkflowApprovalList/WorkflowApprovalListItem— load, selection, bulk delete + deletion error, approve/deny API callsWorkflowApprovalDetail— detail fields, variables (CodeEditor mocked for value assertion)useWsWorkflowApprovals— websocket connect/refetch (hook result rendered to a testid)Interactions now go through accessible roles and real user events. Behaviour and assertions are preserved.
ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION
npm testfor the WorkflowApproval directory: 11 suites, 61 tests, all passing. ESLint clean. No production code changed — test-only.