-
Notifications
You must be signed in to change notification settings - Fork 2
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
feature/9348-DemoModeAPIOverrides #9544
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's cool to see this in action! After digging into the PR, I noticed this approach requires all existing queries, and future queries to include the code snippet that iterates through the overrideErrors
cache and throws an error if the query key exists there. Although this works, I'm not sure that this is the best pattern for mocking errors.
Instead of having a new query for storing mocked errors and requiring all query functions to check for errors in the new error query cache, I think integrating MSW for demo mode would be a better route, and would avoid the need to change query functionality to accommodate for demo mode. It would also avoid using React Query in an antipattern way as a global synchronous storage for errors. Integrating MSW would require us to change our demo mode infrastructure, but we were already planning on doing that.
We had a discovery ticket to investigate using MSW, but it doesn't seem like any follow-up tickets were made for integrating it into the repo. Ironically, I made one earlier today based off of a ticket to add documentation for demo mode. Even though it's a much bigger lift that needs to be planned for, I feel like MSW should be integrated into the repo, and the functionality for mocking API calls to return errors would stem from that integration
I agree. Ideally we would migrate over to MSW and I think we need to have that happen at some point. I do think this solution has some merit as a temporary work around until we migrate over to MSW. |
@Sparowhawk If we really want this in before the MSW migration, have you looked into using the demo store for this? Since we already use the demo store for mocking API calls, I'd imagine we could have an error state for each |
I did and this is what I found trying to do it that way.
|
I talked to Dylan and he is going to suggest a simpler route forward with this one. |
I updated it to how I think it should best be handled at least at this juncture. @dumathane |
Description of Change
Added override api screen and setup each get/fetch api to check for override api and to throw the corresponding error supplied
Screenshots/Video
Screen.Recording.2024-09-10.at.4.05.53.PM.mov
Testing
yarn test
Reviewer Validations
Currently there isn't an easily written detox solution for implementing errors from a backend. With this change, it will open us up to the availability of error testing in detox and make QA/VQA easier to manage if it's accessible through the developer menu.
PR Checklist
Reviewer: Confirm the items below as you review
For QA
Run a build for this branch