fix: Use ButtonWrapper for pagination buttons#4698
Conversation
avinashbot
left a comment
There was a problem hiding this comment.
Note: pagination renders bare elements rather than the Button component, so ButtonWrapper methods that depend on Button-component internals (findLoadingIndicator, findTextRegion, findDisabledReason) are not meaningful for pagination buttons. The commonly needed methods (isDisabled, click, getElement, keyboard/focus helpers) all work.
Doesn't this seem brittle? It seems like a sensible assumption for a Cloudscape dev that component wrapper classes only map to the components exactly, so this might subtly break in the future, especially for methods that we don't test.
This is definitely prettier than my idea though (#4673). Do you think a new "NativeButtonWrapper" that ButtonWrapper could extend from could be possible?
oh interesting, I'd not realized we use plain |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4698 +/- ##
=======================================
Coverage 97.57% 97.57%
=======================================
Files 948 948
Lines 30507 30511 +4
Branches 11164 11165 +1
=======================================
+ Hits 29767 29771 +4
Misses 693 693
Partials 47 47 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
avinashbot
left a comment
There was a problem hiding this comment.
I guess there's a backwards compatibility possibility when moving from ElementWrapper to ComponentWrapper, but realistically, I don't see how anyone could be using those, so it should be fine.
Description
Pagination's page-button finders returned
ElementWrapper, so consumers couldn't callisDisabled()— the buttons usearia-disabledrather than the nativedisabledattribute (see #4576). This adds a pagination-scopedPaginationButtonWrapper(exposingisDisabled()) and returns it fromfindPreviousPageButton,findNextPageButton,findPageNumberByIndex,findCurrentPage, andfindPageNumbers. Pagination renders bare<button>s rather than theButtoncomponent, so a dedicated wrapper is used instead of reusingButtonWrapper(findJumpToPageButtonstill returnsButtonWrapper, as it wraps an actualButton). Non-breaking, sincePaginationButtonWrapper extends ElementWrapper.How has this been tested?
Updated the pagination tests to assert disabled state via
isDisabled(), and added prev/next focus-retention tests (#4576 switched toaria-disabledto keep focus but shipped without a test for it).