-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[Debug Mode] Add transaction and violation data to debug mode #50745
base: main
Are you sure you want to change the base?
[Debug Mode] Add transaction and violation data to debug mode #50745
Conversation
Todo:
|
I didn't have much time as I wanted to work on this today but here goes my update! Today's update:
Todo:
|
…and-violation-data-to-debug-mode # Conflicts: # src/libs/DebugUtils.ts
Today's update:
Todo:
|
Today's update:
Todo:
|
…and-violation-data-to-debug-mode
Today's update:
Todo:
|
…and-violation-data-to-debug-mode
…bug transaction violations tab
…and-violation-data-to-debug-mode # Conflicts: # src/libs/DebugUtils.ts
Today's update:
Todo:
|
…and-violation-data-to-debug-mode
… transaction violations form types
…and-violation-data-to-debug-mode
Today's update:
Todo:
|
…and-violation-data-to-debug-mode
@DylanDylann Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
The PR is now ready for review 😄 |
@pac-guerreiro Type errors please |
…and-violation-data-to-debug-mode
@@ -21,9 +22,11 @@ type ConstantSelectorProps = { | |||
/** inputID used by the Form component */ | |||
// eslint-disable-next-line react/no-unused-prop-types | |||
inputID: string; | |||
|
|||
formType: ValueOf<typeof CONST.DEBUG.FORMS>; |
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.
Please add prop description
import {DETAILS_CONSTANT_FIELDS, DETAILS_DATETIME_FIELDS, DETAILS_DISABLED_KEYS} from './const'; | ||
import ConstantSelector from './ConstantSelector'; | ||
import DateTimeSelector from './DateTimeSelector'; | ||
|
||
type DebugDetailsProps = { | ||
formType: ValueOf<typeof CONST.DEBUG.FORMS>; |
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.
Please add prop description
}; | ||
|
||
function DebugTransactionViolations({transactionID}: DebugTransactionViolationsProps) { | ||
const [transactionViolations] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, {}); |
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.
const [transactionViolations] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, {}); | |
const [transactionViolations] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`); |
onChangeText={(updatedJSON) => { | ||
try { | ||
DebugUtils.validateTransactionViolationJSON(updatedJSON); | ||
setError(''); | ||
} catch (e) { | ||
const {cause, message} = e as SyntaxError; | ||
setError(cause ? translate(message as TranslationPaths, cause as never) : message); | ||
} finally { | ||
setDraftTransactionViolation(updatedJSON); | ||
} | ||
}} |
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.
Could you extract this into separate function?
onPress={() => { | ||
const parsedTransactionViolation = DebugUtils.stringToOnyxData(draftTransactionViolation, 'object') as TransactionViolation; | ||
Debug.mergeDebugData(`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, [...(transactionViolations ?? []), parsedTransactionViolation]); | ||
Navigation.navigate(ROUTES.DEBUG_TRANSACTION_TAB_VIOLATIONS.getRoute(transactionID)); | ||
}} |
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.
Same
onSave={(data) => { | ||
const updatedTransactionViolations = [...(transactionViolations ?? [])]; | ||
updatedTransactionViolations.splice(Number(index), 1, data as TransactionViolation); | ||
Debug.setDebugData(`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, updatedTransactionViolations); | ||
}} | ||
onDelete={() => { | ||
const updatedTransactionViolations = [...(transactionViolations ?? [])]; | ||
updatedTransactionViolations.splice(Number(index), 1); | ||
Debug.setDebugData(`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, updatedTransactionViolations); | ||
}} |
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.
Same
@@ -271,7 +294,7 @@ function validateBoolean(value: string) { | |||
* Validates if a string is a valid representation of a date. | |||
*/ | |||
function validateDate(value: string) { |
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.
Did you update the unit tests to cover the changes?
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 did not but I'll confirm if it's needed, thanks! 😄
@@ -355,8 +378,8 @@ function validateArray( | |||
/** | |||
* Validates if a string is a valid representation of an object. | |||
*/ | |||
function validateObject(value: string, type: ObjectType, collectionIndexType?: 'string' | 'number') { | |||
if (value === 'undefined') { | |||
function validateObject<T extends Record<string, unknown>>(value: string, type: ObjectType<T>, collectionIndexType?: 'string' | 'number') { |
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.
Did you update the unit tests to cover the changes?
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 did not but I'll confirm if it's needed, thanks! 😄
@DylanDylann typecheck errors were resolved 😄 |
…and-violation-data-to-debug-mode # Conflicts: # tests/utils/collections/transaction.ts
@fabioh8010 all feedback addressed, thanks! 😄 Still waiting for @DylanDylann review 😄 |
Details
Fixed Issues
$#50335
PROPOSAL:
Tests
View transaction
in details tabdetails
,json
andviolations
tabsdetails
tab is saved correctlyviolations
tab, try creating and modifying a violation and check that the UI shows your changes in real timeOffline tests
Same as tests
QA Steps
Same as tests
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.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
Android: Native
Android.-.Native.mp4
Android: mWeb Chrome
Android.-.Chrome.mp4
iOS: Native
iOS.-.Native.mp4
iOS: mWeb Safari
iOS.-.Safari.mp4
MacOS: Chrome / Safari
MacOS.-.Chrome.mp4
MacOS: Desktop
MacOS.-.Native.mp4