Skip to content

enzyme -> RTL: convert the WorkflowApproval screen suites - #445

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

enzyme -> RTL: convert the WorkflowApproval screen suites#445
cigamit merged 2 commits into
ctrliq:mainfrom
blaipr:feature/rtl-batch-workflow-approval

Conversation

@blaipr

@blaipr blaipr commented Jun 16, 2026

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

  • approve/deny buttons (shared + list variants) — enabled/disabled state by accessible name, tooltip on hover
  • WorkflowApprovalList / WorkflowApprovalListItem — load, selection, bulk delete + deletion error, approve/deny API calls
  • WorkflowApprovalDetail — 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
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • UI
ADDITIONAL INFORMATION

npm test for the WorkflowApproval directory: 11 suites, 61 tests, all passing. ESLint clean. No production code changed — test-only.

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.

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.

⚠️ 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, and userEvent.
  • 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 VariablesDetail for 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.

Comment on lines +92 to 96
await user.click(screen.getByRole('button', { name: 'Delete' }));
await user.click(
await screen.findByRole('button', { name: 'confirm delete' })
);

Comment on lines +120 to 124
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' })
);
@blaipr

blaipr commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

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.

@cigamit
cigamit merged commit 07dfe96 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