Skip to content

Fix compatibility of unit tests with react-hook-form 7.56.x#10742

Merged
djhi merged 8 commits intomasterfrom
fix-tests-with-rhf-7.56
May 14, 2025
Merged

Fix compatibility of unit tests with react-hook-form 7.56.x#10742
djhi merged 8 commits intomasterfrom
fix-tests-with-rhf-7.56

Conversation

@slax57
Copy link
Contributor

@slax57 slax57 commented May 13, 2025

Problem

Upgrading react-hook-form to v7.56.x breaks some unit tests.

Failing test suites:

packages/ra-ui-materialui/src/input/ArrayInput/SimpleFormIterator.spec.tsx
packages/ra-ui-materialui/src/input/SelectArrayInput.spec.tsx
packages/ra-ui-materialui/src/input/NumberInput.spec.tsx
packages/ra-core/src/controller/input/useReferenceInputController.spec.tsx
packages/ra-ui-materialui/src/list/filter/FilterButton.spec.tsx (flaky)

Solutions

SimpleFormIterator

Regression brought by #9795, somehow unseen 🤷 🤔

SelectArrayInput

Same: not sure how we did not see that...
The code of the story used by the test was wrong... 🤔

NumberInput

This one is actually a RHF regression, I've opened an issue:

react-hook-form/react-hook-form#12815

useReferenceInputController

Render count needs to be increased from 3 to 4. Fixed by simply awaiting the expected call.

FilterButton

Flaky tests.
Fixed by adding timeouts.

How To Test

  1. yarn up react-hook-form
  2. make test-unit
  3. All tests should pass, except NumberInput

Additional Checks

  • The PR targets master for a bugfix or a documentation fix, or next for a feature
  • The PR includes unit tests (if not possible, describe why)
  • The PR includes one or several stories (if not possible, describe why)
  • The documentation is up to date
  • Make sure the changes do not break with RHF 7.53.0 (i.e. wait for the CI to run)

Also, please make sure to read the contributing guidelines.

@slax57 slax57 added WIP Work In Progress RFR Ready For Review and removed WIP Work In Progress labels May 13, 2025
// Make sure it's not a FormDataConsumer
// @ts-ignore
!Children.only(children).type !== FormDataConsumer
Children.only(children).type !== FormDataConsumer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you try to find a way to remove the ts-ignore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, this is out of scope for this PR IMO

@djhi djhi added this to the 5.8.2 milestone May 14, 2025
@djhi djhi merged commit 9c5e3bb into master May 14, 2025
16 checks passed
@djhi djhi deleted the fix-tests-with-rhf-7.56 branch May 14, 2025 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RFR Ready For Review

Development

Successfully merging this pull request may close these issues.

2 participants