react-admin icon indicating copy to clipboard operation
react-admin copied to clipboard

Fix type error when queryOptions enable is set to false

Open yanchesky opened this issue 3 years ago • 5 comments

Fixes https://github.com/marmelab/react-admin/issues/7986

yanchesky avatar Jul 18 '22 21:07 yanchesky

Thanks for the error report and the PR! Would you mind trying to add a unit test for this case?

djhi avatar Jul 19 '22 07:07 djhi

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

yanchesky avatar Jul 21 '22 07:07 yanchesky

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)

  1. Create history and pass it to the CoreAdminContext component.
  2. pass disableSyncWithLocation prop 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",
      },
    ],
  ],

yanchesky avatar Jul 26 '22 05:07 yanchesky

Hi

ITopGun avatar Jul 27 '22 14:07 ITopGun

Could you resolve the conflict?

WiXSL avatar Sep 07 '22 12:09 WiXSL

Thanks!

fzaninotto avatar Sep 23 '22 07:09 fzaninotto