enzyme -> RTL: convert the SelectedList component suites - #468
Conversation
Migrate components/SelectedList (SelectedList and DraggableSelectedList) off enzyme/mountWithContexts onto renderWithContexts (React Testing Library). Chips and overflow are asserted via the rendered DOM; the pre-existing drag-and-drop describe.skip is preserved. Behaviour and assertions are otherwise preserved.
There was a problem hiding this comment.
Pull request overview
Migrates the SelectedList component test suites from enzyme (mountWithContexts) to React Testing Library (renderWithContexts) as part of the ongoing enzyme → RTL conversion in awx/ui.
Changes:
- Converted
SelectedListtests to assert rendered DOM output (labels, chips, overflow) instead of enzyme prop inspection. - Updated chip removal coverage to use
userEventand accessible queries, assertingonRemovecallbacks. - Converted the (still skipped)
DraggableSelectedListsuite to RTL queries while preserving the skip status.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| awx/ui/src/components/SelectedList/SelectedList.test.js | Replaces enzyme mounting/prop assertions with RTL DOM assertions, including overflow and removal behaviors. |
| awx/ui/src/components/SelectedList/DraggableSelectedList.test.js | Updates the skipped drag-and-drop suite to RTL patterns and improves inline documentation. |
| // deprecated. Its replacement is a DragDrop component, however that component | ||
| // is not keyboard accessible. Therefore we have elected to turn off these | ||
| // tests. | ||
| // github.com/patternfly/patternfly-react/issues/6317s |
| expect(screen.getByText('bar')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('showOverflow should set showOverflow on ChipGroup', () => { |
| }); | ||
| }); | ||
|
|
||
| test('should disable remove button when dragging item', () => { |
Fix the PatternFly issue link (add https://, drop the stray trailing s); rename the SelectedList numChips-cap test and the DraggableSelectedList not-dragging test to match what they actually assert.
The suite was skipped only because PatternFly's DataList logs an onDrag deprecation warning on render that the global console trap turns into a failure. Filter just that one warning (forwarding all others) and target the reorder button by data-cy (its accessible name is overridden by aria-labelledby), so the four tests run instead of being skipped.
|
Thanks for the review. Pushed a commit: fixed the PatternFly issue link, and renamed the SelectedList numChips test and the DraggableSelectedList not-dragging test to match what they actually assert. I also enabled the DraggableSelectedList suite, which was fully skipped only because PatternFly logs an onDrag deprecation warning on render that the console trap turned into a failure. Filtering just that one warning lets the four tests run and pass. |
SUMMARY
Converts the SelectedList component test suite (
components/SelectedList) from enzyme to React Testing Library, continuing the enzyme → RTL migration (components, one directory per PR).Files migrated off
mountWithContexts/enzyme ontorenderWithContexts:SelectedList,DraggableSelectedList.Chips, the
numChipsoverflow (N moreexpander), and chip removal are asserted via the rendered DOM and theonRemovecallback. TheDraggableSelectedListsuite staysdescribe.skip(drag-and-drop has no accessible DOM trigger in jsdom — unchanged from before). Behaviour and assertions are otherwise preserved.ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION
npm testforcomponents/SelectedList: 3 passing (+4 pre-existing skips in the drag-and-drop suite). ESLint clean (--no-ignore). No production code changed — test-only.