-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Implement ViolationUtils lib #31656
Implement ViolationUtils lib #31656
Conversation
…ation-utils Implement ViolationUtils lib Expensify#31083
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
…ons/violation-utils # Conflicts: # src/ONYXKEYS.ts
…tions/violation-utils
# Conflicts: # src/ONYXKEYS.ts
I see that there is no way to test it but is is possible to have temporary test by manually changing some code locally? |
Not really -- it doesn't have any effects on the user interface. These are essentially helper functions. There are some other PRs coming that will call this code and it will be tested as part of those. |
For instance this issue relies on this code and will call it: #31084 |
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.
Can you add unit tests for getViolationForField and getViolationsOnyxData?
Add all possible violations Co-authored-by: Carlos Alvarez <cead22@gmail.com>
|
||
const ViolationsUtils = { | ||
getViolationForField(transactionViolations: TransactionViolation[], field: ViolationField, translate: (key: string) => string): string[] { | ||
return transactionViolations.filter((violation) => possibleViolationsByField[field]?.includes(violation.name)).map((violation) => translate(violation.name)); |
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.
I also don't like using lodash/invertBy
fix: improve JSDoc on getViolationsOnyxData Co-authored-by: Carlos Alvarez <cead22@gmail.com>
sure, will do during weekend |
Co-authored-by: Carlos Alvarez <cead22@gmail.com>
@situchan do you think you'll be able to review today? |
yes on it now |
Co-authored-by: Carlos Alvarez <cead22@gmail.com>
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / Safaritest.movMacOS: Desktop |
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.
App working fine after injecting useViolations
hook in any component rendered during app play
Please update issue title to [No QA] so that QA team won't get confused what to test
We did not find an internal engineer to review this PR, trying to assign a random engineer to #31083 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
Applied prettier and merged main. |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Cherry-picked to staging by https://github.com/yuwenmemon in version: 1.4.7-4 🚀
@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes. |
🚀 Deployed to staging by https://github.com/cead22 in version: 1.4.8-0 🚀
|
🚀 Deployed to production by https://github.com/yuwenmemon in version: 1.4.8-3 🚀
|
🚀 Deployed to production by https://github.com/yuwenmemon in version: 1.4.8-3 🚀
|
Details
This PR implements the ViolationUtils lib, as specified in this issue.
Notes on Implementation
Created
useViolationsHook
for use in `getI wrapped
getViolationsForField
in a hook to make it more idiomatic for react.Changes to Onyx Types
Added
PolicyCategories
typegetViolationsOnyxData
PolicyTags
as an exampleAdded
TRANSACTION_VIOLATIONS
toONXYKEYS.COLLECTION
transactionViolations_
to follow the patternCreated
TransactionViolation
and related typesTransactionViolation
type and string literal unions for the various types as discussed hereFixed Issues
$ #31083
Tests
Unit tests are provided
Offline tests
This code is not called yet by the application, so there is no way to test it.
QA Steps
This code is not called yet by the application, so there is no way to test it.
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
No visible changes