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

Refactor ReimbursementAccountPage's fetchFreePlanVerifiedBankAccount #11751

Merged
merged 18 commits into from
Nov 10, 2022

Conversation

ctkochan22
Copy link
Contributor

@ctkochan22 ctkochan22 commented Oct 12, 2022

@nkuoch @MariaHCD @youssef-lr

Details

This replaces the use of fetchFreePlanVerifiedBankAccount

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/226858

Tests / QA

Test a bank account in SETUP

  1. Start the VBBA process. Select plaid (use user_good and pass_good to get past plaid)
  2. Add any fields to the Company Step, the key is to make it past this step
  3. After submission, you should be on the RequestorStep "Personal Information"
    image
  4. Close out of the flow. Back all the way to a chat window
  5. Navigate back to the VBA flow (Settings -> Workspace settings -> Connect Bank Account -> Continue with setup)
  6. Verify that you are shown back to the Requestor Step "Personal information"
  7. Now log out to clear your cache
  8. Log back in
  9. Navigate back to the VBA flow (Settings -> Workspace settings -> Connect Bank Account)
  10. Verify that you are shown back to the Requestor Step "Personal information"

Test Requestor Step without completing Onfido

  1. With the same VBBA setup, fill out the requestor step (Do not use Alberta Charleston from the SO, use a random name)
  2. It should take you to Onfido flow
  3. Don't complete onfido. Exit the flow
  4. Navigate back to the VBA flow (Settings -> Workspace settings -> Connect Bank Account -> Continue with setup)
  5. Verify that you are brought back to the Onfido Step
  6. Log out and log back in
  7. Navigate back to the VBA flow
  8. Verify that you are brought back to the Requestor Step ("Personal information"). And everything is pre-filled
    image
  9. When you click submit, you still have to go through Onfido

Test Beneficial Owners Step

  1. Once onfido is complete, you should be moved to the ACHContract Step or Beneficial Owners Step or "Additional information"
    image
  2. Exit flow
  3. Navigate back to the VBA flow (Settings -> Workspace settings -> Connect Bank Account -> Continue with setup)
  4. Verify that you are still on that step you left off
  5. Log out and log back in
  6. Navigate back to the VBA flow
  7. Verify that you are still on that step

Test VERIFYING state

  1. So long as you did not add Alberta Charleston as the name, the VBBA should be in a VERIFYING state
  2. Verify that you are asked to provide more information:
    image
  3. Click "Yes lets chat"
  4. Navigate back to the VBA flow (Settings -> Workspace settings -> Connect Bank Account -> Continue with setup)
  5. Verify that you are still on that step/need to provide more info
  6. Log out and log back in.
  7. Navigate back to the VBA flow
  8. Verify that you are still on that step

Test PENDING state

  1. Follow the SO instructions to add a PENDING VBBA (link).
  2. Get to the Validation Step
    image
  3. Navigate away
  4. Navigate back to the VBBA flow
  5. Verify that you see the "Continue Setup"/"Start-Over".
  6. Click continue
  7. Verify that you see Validation Step "Test Transactions"
  • Verify that no errors appear in the JS console

PR Review Checklist

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 */
    • 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 reviewer 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 */
    • 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.

Screenshots

Web

Mobile Web - Chrome

Mobile Web - Safari

Desktop

https://recordit.co/fseVdmCoMz

iOS

https://recordit.co/ygknviefmP

Android

@ctkochan22 ctkochan22 self-assigned this Oct 12, 2022
@ctkochan22 ctkochan22 requested a review from a team as a code owner October 12, 2022 08:52
@melvin-bot melvin-bot bot requested review from youssef-lr and removed request for a team October 12, 2022 08:53
@ctkochan22 ctkochan22 changed the base branch from master to main October 12, 2022 08:58
@ctkochan22 ctkochan22 requested review from nkuoch and MariaHCD October 18, 2022 07:31
@ctkochan22 ctkochan22 changed the title [WIP] Refactor ReimbursementAccountPage's fetchFreePlanVerifiedBankAccount Refactor ReimbursementAccountPage's fetchFreePlanVerifiedBankAccount Oct 18, 2022
@ctkochan22
Copy link
Contributor Author

Still need to figure out QA and screenshots from every platform, but this can begin initial review I think and testing

@youssef-lr
Copy link
Contributor

I don't know what's up with my VM, I'm getting a CORS error when trying to open the VBBA page. Trying to figure out what's causing this so I can test the PR.

Copy link
Contributor

@MariaHCD MariaHCD left a comment

Choose a reason for hiding this comment

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

The code LGTM so far!

I believe we also need to refactor the usage of fetchFreePlanVerifiedBankAccount in the WorkspacePageWithSections component:

fetchData() {
const achState = lodashGet(this.props.reimbursementAccount, 'achData.state', '');
BankAccounts.fetchFreePlanVerifiedBankAccount('', achState);
}

@MariaHCD
Copy link
Contributor

I don't know what's up with my VM, I'm getting a CORS error when trying to open the VBBA page. Trying to figure out what's causing this so I can test the PR.

@youssef-lr Possibly you need to upgrade to PHP8.1?

@youssef-lr
Copy link
Contributor

youssef-lr commented Oct 21, 2022

@MariaHCD I've already did. I think I'll point App to staging to test this while I figure it out.

Copy link
Contributor

@MariaHCD MariaHCD left a comment

Choose a reason for hiding this comment

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

Tested this locally:

  1. Test a bank account in SETUP: worked as expected
  2. Test Requestor Step without completing Onfido: worked as expected, except for logging out and logging back in. The personal information form did not have the form data pre-filled
New.Expensify.2.webm
  1. Test Beneficial Owners Step: worked as expected
  2. Test PENDING state: haven't tested this yet. We can remove At the moment, the SO instructions to add a PENDING VBBA is broken since that bug has been fixed.

nkuoch
nkuoch previously approved these changes Oct 21, 2022
@ctkochan22
Copy link
Contributor Author

This should be ready to go @MariaHCD @nkuoch

The only issue to note is, as noted in this bug https://github.com/Expensify/Expensify/issues/238317 . When testing and you sign in for the first time, there will be no VBBA and we will not fetch it at any point until we click "Continue Setup". This means, we won't see the option to continue previous setup or start over

@@ -58,7 +58,7 @@ function getNextStep(updatedACHData) {
return currentStep;
}

if (currentStep === CONST.BANK_ACCOUNT.STEP.VALIDATION && updatedACHData.bankAccountInReview) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you make sure no other places used bankAccountInReview?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I need to undo this. We actually removed bankAccountInReview completely from the web/auth side.

And looking at this page, I don't think this method is used anymore? Its used in setupWithdrawalAccount(), but that is no longer being used I don't 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.

I'm going to undo this change

Copy link
Contributor

Choose a reason for hiding this comment

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

setupWithdrawalAccount() isn't being used anymore, created an issue to remove this file completely: https://github.com/Expensify/Expensify/issues/240702

Copy link
Contributor

@MariaHCD MariaHCD left a comment

Choose a reason for hiding this comment

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

Could you also update the Jest unit tests? We're currently using fetchFreePlanVerifiedBankAccount in ReimbursementAccountTest.js

Can we also get rid of tests/unit/fetchFreePlanVerifiedBankAccountTest.js?

@ctkochan22
Copy link
Contributor Author

Could you also update the Jest unit tests? We're currently using fetchFreePlanVerifiedBankAccount in ReimbursementAccountTest.js

I'm not super familiar with Jest tests. But it seems like it doesn't actually hit an API? If that is the case, is there much to test? We handle so much of it on the php side.

@MariaHCD
Copy link
Contributor

MariaHCD commented Nov 8, 2022

I'm not super familiar with Jest tests. But it seems like it doesn't actually hit an API? If that is the case, is there much to test? We handle so much of it on the php side.

Ah, good point. We're just mocking the API responses in the Jest tests. And since most of the logic is now in the API, we shouldn't need these tests anymore, correct?

@MariaHCD
Copy link
Contributor

MariaHCD commented Nov 8, 2022

@ctkochan22 Could you re-fill the PR author checklist? Perhaps it's outdated which is why the test is failing.

@MariaHCD
Copy link
Contributor

MariaHCD commented Nov 8, 2022

Noticed when testing this that if you log out and then back in again, the forms that you completed before are no longer populated with the data:

Screen.Recording.2022-11-08.at.5.46.25.PM.mov

@ctkochan22
Copy link
Contributor Author

Woah, this is happening because the path here is incorrect.

|| lodashGet(props, ['reimbursementAccount', 'achData', fieldName], defaultValue);

Was that changed recently?

@ctkochan22
Copy link
Contributor Author

@youssef-lr Can you test this today please? 🙇

@youssef-lr
Copy link
Contributor

@ckscanlon testing now!

@MariaHCD
Copy link
Contributor

MariaHCD commented Nov 9, 2022

Heads up @youssef-lr, if you run into this error: #11751 (comment)

You can test with the Web-E PR: https://github.com/Expensify/Web-Expensify/pull/35506 and it will work

@youssef-lr
Copy link
Contributor

youssef-lr commented Nov 9, 2022

@ckscanlon after running the query in the last step, this is what I'm seeing, am I missing something? All other tests worked as expected. cc @MariaHCD I think Chris is offline.
Screen Shot 2022-11-09 at 15 06 28

@ctkochan22
Copy link
Contributor Author

@youssef-lr Is the bank account ending in 9378 the new bank account in the validate state?

@ctkochan22
Copy link
Contributor Author

@youssef-lr my bad, the test steps were outdated. Please try the last step when you can! And this PR should be ready to go!

@ctkochan22
Copy link
Contributor Author

I'm not sure why this PR didn't have a C+ assigned

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.

Tested well!

@youssef-lr
Copy link
Contributor

PR Reviewer Checklist

  • 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 included screenshots or videos 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 adding the Waiting for Copy label for a copy review 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 */
    • 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.

@youssef-lr youssef-lr merged commit 0c65dbe into main Nov 10, 2022
@youssef-lr youssef-lr deleted the ckt_fetchFreePlan_reimbursementPage_2 branch November 10, 2022 14:07
@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.27-0 🚀

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

key: ONYXKEYS.REIMBURSEMENT_ACCOUNT,
value: {
errors: null,
isLoading: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

is it this @ctkochan22 ?

Are we stuck in the isLoading state?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but upon any sort of completion it should be set to false

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @roryabraham in version: 1.2.27-4 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @roryabraham in version: 1.2.27-4 🚀

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

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.

7 participants