patternfly / patternfly-react

A set of React components for the PatternFly project.
https://react-staging.patternfly.org/
MIT License
793 stars 356 forks source link

Test error: Cannot find the Button's disabled attribute #10927

Closed dlabrecq closed 3 weeks ago

dlabrecq commented 1 month ago

Please describe the issue

4 tests cannot find the Button's disabled attribute. This test worked with v5, but no longer works with v6.

Are there visuals for this issue? Please provide screenshots

Error 1 Screenshot 2024-08-28 at 6 31 05 PM

Error 2 Screenshot 2024-08-28 at 6 24 00 PM

Error 3

Screenshot 2024-08-28 at 6 29 49 PM

Error 4

Screenshot 2024-08-28 at 6 30 19 PM

Could you point to a branch or draft PR where this issue exists? Please provide a link to the code

Error 1

Error 2

Error 3

Error 4

wise-king-sullyman commented 3 weeks ago

These failures are because we added a new wrapping div around the text inside of buttons in v6, and the RTL byText query is now returning that wrapper rather than the button element itself, which is where those attributes live.

I would suggest using byRole queries instead and passing a name option searching for the text value you're currently passing into the byText query, as it will return the top level button element. Also FWIW the RTL team does suggest prioritizing the use of byRole queries over byText when possible.

dlabrecq commented 3 weeks ago

Updated to use byRole