-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[NO QA] Add an enhanced mock for ReportUtils to fix tests #68768
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
89d7eb3
Add an enhanced mock for ReportUtils to fix tests
AndrewGable 61e3368
Fix types
AndrewGable 007f63b
Remove comment to trigger tests
AndrewGable 8ab5571
Remove unrelated diff
AndrewGable 5aa82c6
Add comment describing mock
AndrewGable 0bc862d
Merge branch 'main' into andrew-perf-tests
AndrewGable 8558ca3
Clean up code comments even more
AndrewGable File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do these need to be mocked because they use the router, and the router is not available in the unit test environment?
I'd love it if all mocks actually included a thorough explanation of why they are necessary.
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.
hmm i think comment should be a NAB and the proper solution can be discussed and applied in a follow up. I say this because we mocked it before and we're just fixing the mock to unblock other PRs.
Uh oh!
There was an error while loading. Please reload this page.
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.
im not an expert on jest but i did a quick check. From my understanding the reason we're written it this way is cause we use the actual methods of ReportUtils like
getTitleReportField. It doesn't use the router so its safe for the test to use.Additionally we mock some of the methods like isExpenseReport to always true so that setup is perhaps easier in this test.
Also yeah i agree, having this in a comment would be helpful.
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.
Thanks for adding a comment, but I don't think it helps me understand why the mock is necessary, or why only these two methods are turned into noops. Chirag's explanation comes close... but I still don't know that I get it.
Why is this important? In order to try and answer that, I'd need to hunt through a ton of code to try and figure it out. Also, it's not clear what
parseReprotRouteParamshas to do with these methods.I think that the comment should explain the mocked methods, specifically
isExpenseReportandgetTitleReportField, rather than just saying all the other exports are untouched (which is pretty obvious from just looking at the mock).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.
Updated