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 Select's role #10926

Closed dlabrecq closed 3 weeks ago

dlabrecq commented 1 month ago

Please describe the issue

Test fails due to Unable to find role="option" error, related to Select. This test worked with v5, but no longer works with v6.

Are there visuals for this issue? Please provide screenshots

Error Screenshot 2024-08-28 at 12 03 45 PM

Screenshot 2024-08-28 at 12 03 59 PM

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

Test https://github.com/dlabrecq/koku-ui/blob/pf-v6/src/routes/settings/costModels/costModel/updateRateModel.test.tsx#L300

Tested component https://github.com/dlabrecq/koku-ui/blob/pf-v6/src/routes/settings/costModels/components/rateForm/rateForm.tsx#L130

The tested component drills down to this Select https://github.com/dlabrecq/koku-ui/blob/pf-v6/src/routes/components/selectWrapper/selectWrapper.tsx#L100

wise-king-sullyman commented 3 weeks ago

This failure appears to be caused because the Popper menu is being set to aria-disabled after a selection is made, causing the RTL query to not be able to find the menu options without the {hidden: true} option being passed. This behavior started occurring with our change to Poppers default appendTo value and can be resolved by either passing that hidden option to the RTL queries or changing the Select's appendTo back to inline.

Also it seems to be a strange interaction between the internals of Popper and Jest/JSDOM as I haven't been able to reproduce this in a real browser, if anyone is though please let me know.

kmcfaul commented 3 weeks ago

#4277 will track the work to improve documentation.