Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add prevent validateResponseFormat() from validating custom routes #8159

Merged

Conversation

ogustavo-pereira
Copy link
Contributor

This pr makes an adjustment so that validateResponseFormat() is not used in dataProvider custom routes

  • Code ✔️
  • Test ❌
  • Documentation ❌

Closes #8083

Obs: I need to understand what is needed to document and test

Copy link
Member

@fzaninotto fzaninotto left a comment

Choose a reason for hiding this comment

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

The existing response validation logic is currently not tested, but I'd like that you add at least one test for this change. I'd put it in useDataProvider.spec.tsx, and I'd test 3 cases:

  1. a call to dataProvider.getList() returning a response with the right format doesn't return any warning
  2. a call to dataProvider.getList() returning a response without the right format does return any warning
  3. a call to dataProvider.custom() returning a response without the right format doesn't return any warning

No need to document anything.

@@ -21,6 +21,11 @@ export const fetchActionsWithArrayOfRecordsResponse = [
];
export const fetchActionsWithTotalResponse = ['getList', 'getManyReference'];

export const fetchActions = [
Copy link
Member

Choose a reason for hiding this comment

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

I'd name it reactAdminFetchActions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 448a8ec

@ogustavo-pereira
Copy link
Contributor Author

I updated the unit tests but when running the console log is showing in the test log

image

@slax57
Copy link
Contributor

slax57 commented Sep 19, 2022

@oguhpereira you can use something like this to discard console.error() during your test:

jest.spyOn(console, 'error').mockImplementationOnce(() => {});

@ogustavo-pereira
Copy link
Contributor Author

@oguhpereira you can use something like this to discard console.error() during your test:

jest.spyOn(console, 'error').mockImplementationOnce(() => {});

Done c0bc6bb @slax57

@fzaninotto fzaninotto merged commit f33dcf0 into marmelab:next Sep 20, 2022
@fzaninotto
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants