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

Form refactor bankaccountstep #10900

Merged

Conversation

jayeshmangwani
Copy link
Contributor

Details

Fixed Issues

$ #9579

Tests

Verify that:

  • UI looks as it did before the refactor
  • Values can be added and edited
  • Errors are highlighted correctly (input border)
  • Error messages show up correctly
  • Draft values are saved properly
  • Form alerts are displayed correctly
  • Clicking the fix the errors link focuses the first input with error
  • No duplicate submission of the form occurs (when it's already submitting)
  • Verify that no errors appear in the JS console

PR Review Checklist

Contributor (PR Author) Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by tagging the marketing team on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • Any functional components have the displayName property
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

PR Reviewer Checklist

The Contributor+ will copy/paste it into a new comment and complete it after the author checklist is completed

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by tagging the marketing team on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • Any functional components have the displayName property
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

QA Steps

Verify that:

  • UI looks as it did before the refactor

  • Values can be added and edited

  • Errors are highlighted correctly (input border)

  • Error messages show up correctly

  • Draft values are saved properly

  • Form alerts are displayed correctly

  • Clicking the fix the errors link focuses the first input with error

  • No duplicate submission of the form occurs (when it's already submitting)

  • Verify that no errors appear in the JS console

Screenshots

Web

9579-web.mov

Mobile Web

9579-mWeb.mp4

Desktop

9579-desktop.mov

iOS

9579-ios.mov

Android

9579-Android.mp4

@jayeshmangwani jayeshmangwani requested a review from a team as a code owner September 8, 2022 14:17
@melvin-bot melvin-bot bot requested review from iwiznia and mananjadhav and removed request for a team September 8, 2022 14:17
@luacmartins luacmartins self-requested a review September 9, 2022 08:57
Copy link
Collaborator

@mananjadhav mananjadhav left a comment

Choose a reason for hiding this comment

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

2 questions raised, @jayeshmangwani

@jayeshmangwani
Copy link
Contributor Author

@mananjadhav conflicts resolved and latest main merged,

and I have removed 2 different keys(BANK_ACCOUNT_STEP_FORM_MANUAL, BANK_ACCOUNT_STEP_FORM_PLAID) and now using a single key REIMBURSEMENT_ACCOUNT for all the reimbursement data.

cc: @luacmartins

@mananjadhav
Copy link
Collaborator

I'll check this today again @jayeshmangwani .

Copy link
Contributor

@youssef-lr youssef-lr left a comment

Choose a reason for hiding this comment

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

LGTM overall, left a comment about the submit button that remains visible when Plaid is still loading or no account has been selected. Also, inside this function loading should be changed to isLoading so that it can be used from Form.

Copy link
Contributor

@luacmartins luacmartins left a comment

Choose a reason for hiding this comment

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

Left a small comment. Also I'm getting an error when selecting a Plaid account and clicking Save & continue

Screen Shot 2022-09-19 at 1 20 38 PM

src/pages/ReimbursementAccount/BankAccountStep.js Outdated Show resolved Hide resolved
@@ -40,6 +40,9 @@ const propTypes = {
// eslint-disable-next-line react/forbid-prop-types
draftValues: PropTypes.object,

/** Should we show the form button */
isSubmitButtonVisible: PropTypes.bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this needs to be moved below submitButtonText, as now it sits under the /* Onyx Props */ comment but it's not an Onyx prop.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this change has been done

@@ -83,9 +86,10 @@ class BankAccountStep extends React.Component {
return errors;
}

validatePlaidAccount(values) {
validatePlaidAccount() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can skip validating Plaid account, as we don't allow the user to continue unless they choose an account. I don't see a way of triggering the validation error if it exists. @luacmartins what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I think we can skip this, removed validatePlaidAccount for now

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense since we can't display that error and the user can't continue without selecting an account.

@@ -238,7 +227,6 @@ class BankAccountStep extends React.Component {
{subStep === CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID && (
<Form
formID={ONYXKEYS.REIMBURSEMENT_ACCOUNT}
validate={this.validatePlaidAccount}
Copy link
Contributor

Choose a reason for hiding this comment

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

Removing this completely will cause an error, maybe we can have it return an empty object validate={() => ({})} to satisfy Form. I still think we don't need that validation method because it will only run when selectedPlaidBankAccount is already defined.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added empty object to validate in PLAID Form

@luacmartins
Copy link
Contributor

@jayeshmangwani we have conflicts again!

@jayeshmangwani
Copy link
Contributor Author

@luacmartins conflicts resolved

luacmartins
luacmartins previously approved these changes Sep 29, 2022
@mananjadhav
Copy link
Collaborator

@youssef-lr Would you be able to get this? We should try to get this merged before we have to resolve conflicts again.

@youssef-lr
Copy link
Contributor

We're not displaying any error from the server. This is because we started returning errors instead of error, here are the changes I made to Form in another PR, let's wait for @luacmartins's input on them then we can include the changes in this PR here and we should be good to go!

Screen.Recording.2022-09-29.at.22.16.51.mov

iwiznia
iwiznia previously approved these changes Sep 30, 2022
@youssef-lr
Copy link
Contributor

@jayeshmangwani feel free to merge contents of Form and FormActions into this PR then we should be all set to merge!

@jayeshmangwani
Copy link
Contributor Author

FormActions

@youssef-lr latest code merged from main, and checked plaid and manual setup , its working fine, any changes I have to do for FormActions ?

@youssef-lr
Copy link
Contributor

So the files I've linked are from this PR and not from main, it hasn't been merged yet. The changes should support a new errors key we send from the backend to display server side errors.

There is also a separate issue to bring some more changes to Form but it's not gonna be merged yet.

So I think you can copy contents of the files I linked and push the changes then we can merge!

@jayeshmangwani jayeshmangwani dismissed stale reviews from iwiznia and luacmartins via bd2e691 September 30, 2022 18:57
@jayeshmangwani
Copy link
Contributor Author

So the files I've linked are from this PR and not from main, it hasn't been merged yet. The changes should support a new errors key we send from the backend to display server side errors.

There is also a separate issue to bring some more changes to Form but it's not gonna be merged yet.

So I think you can copy contents of the files I linked and push the changes then we can merge!

@youssef-lr Done

@jayeshmangwani
Copy link
Contributor Author

@youssef-lr fixed newline lint issue

Copy link
Contributor

@youssef-lr youssef-lr left a comment

Choose a reason for hiding this comment

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

Thanks for the changes!

@youssef-lr youssef-lr merged commit 6c81537 into Expensify:main Sep 30, 2022
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @youssef-lr in version: 1.2.11-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@mvtglobally
Copy link

@jayeshmangwani @youssef-lr @luacmartins Did you guys QA it internally? If not, can you help with QA steps. I am not able to follow what exactly we can validate here

@luacmartins
Copy link
Contributor

@mvtglobally I just QA'd this and it's a pass.

@OSBotify
Copy link
Contributor

OSBotify commented Oct 5, 2022

🚀 Deployed to production by @AndrewGable in version: 1.2.11-4 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@NikkiWines
Copy link
Contributor

👋 Hi, we've identified this PR as 1/2 of the cause of #14972. This PR changed the naming convention from acceptTerms to acceptedTerms. Since the value from the server is acceptTerms this caused us to incorrectly read the value when trying to set the state and for the bank account.

In this case, this could've been avoided by retaining the old naming convention, or by doing some more robust testing to ensure that both the draft and state values matched what we were expecting in a variety of scenarios. We've got a proposed regression test here that should cover the latter case 🙌

@@ -75,6 +80,11 @@ class Form extends React.Component {
this.touchedInputs[inputID] = true;
}

getErrorMessage() {
const latestErrorMessage = ErrorUtils.getLatestErrorMessage(this.props.formState);
return this.props.formState.error || (typeof latestErrorMessage === 'string' ? latestErrorMessage : '');
Copy link
Contributor

Choose a reason for hiding this comment

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

Doing a refactor in #20228 , I got an eslint error related to this line :

ESLint: 'formState.error' is missing in props validation (react/prop-types)

I guess this should be updated to this.props.formState.errors . But as I don't have much context, I would appreciate further clarification on this issue.

cc @jayeshmangwani @luacmartins

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jayeshmangwani feel free to merge contents of Form and FormActions into this PR then we should be all set to merge!

I am not sure about this change, I copied these changes from this Form.js file and @youssef-lr may have the full context of these changes

Copy link
Contributor

Choose a reason for hiding this comment

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

We're removing this.props.formState.error from that line in https://github.com/Expensify/App/pull/20091/files. See this comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

That’s perfect.

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.

9 participants