react-admin
react-admin copied to clipboard
Fix type error when queryOptions enable is set to false
Fixes https://github.com/marmelab/react-admin/issues/7986
Thanks for the error report and the PR! Would you mind trying to add a unit test for this case?
Fixing failed unit test might be cumbersome 🤔. I have run it on the local machine and out of 10 tests on unchanged code:
- 4 times all tests passed
- 3 times "should notify if passed an error with a message that makes the authProvider throw" test failed
- 2 times "should take only last change in case of a burst of changes (case of inputs being currently edited)" test failed
- 1 time both 👆 failed
I couldn't find the exact reason why the test should take only last change in case of a burst of changes (case of inputs being currently edited) sometimes fails. I've run this test only and it never failed. I suspect that it may be related to react-router-dom because right before the test fails, the error is raised An update to HistoryRouter inside a test was not wrapped in act. However, this error occurs even if the test passes so I'm not sure about this.
However, knowing that I've come up with 2 solutions that make this test suite work. (By work I mean 10 test runs without any fail)
- Create
historyand pass it to the CoreAdminContext component. - pass
disableSyncWithLocationprop to the ListController component.
If that is ok with you I will make a commit fixing it.
Snapshot of the mock requests that cause the test to fail:
"calls": Array [
Array [
"posts.listParams",
Object {
"filter": Object {},
"order": "ASC",
"page": 1,
"perPage": 10,
"sort": "id",
},
],
Array [
"posts.listParams",
Object {
"filter": Object {
"q": "hello",
},
"order": "ASC",
"page": 1,
"perPage": 10,
"sort": "id",
},
],
],
Hi
Could you resolve the conflict?
Thanks!