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 ValidationStep Form #10946

Merged
merged 28 commits into from
Oct 4, 2022
Merged

Conversation

youssef-lr
Copy link
Contributor

@youssef-lr youssef-lr commented Sep 12, 2022

Details

Fixed Issues

$ #9582

Tests

Add a bank account to your account until you reach the validation step that asks for 3 amounts.

  • Verify that when you submit the form, the inputs are highlighted in red an and error text is shown below them when:
  1. The input is empty.
  2. The e validation amounts are incorrect, verify also that in this case, the error message coming from the backend is displayed.
  • Verify that 'Fix errors' button focuses on the first input with an error.
  • Verify that drafts are saved properly: enter valid amounts and refresh the page, make sure the amounts entered still show up.
  • 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

With a bank account that is awaiting validation codes, head to https://staging.new.expensify.com/bank-account/BankAccountStep

  • Verify that when you submit the form, the inputs are highlighted in red an and error text is shown below them when:
  1. The input is empty.
  2. The e validation amounts are incorrect, verify also that in this case, the error message coming from the backend is displayed.
  • Verify that 'Fix errors' button focuses on the first input with an error.
  • Verify that drafts are saved properly: enter valid amounts and refresh the page, make sure the amounts entered still show up.
  • Verify that no errors appear in the JS console

Screenshots

Web

Screen.Recording.2022-09-22.at.22.24.27.mov

Mobile Web

Desktop

iOS

Android

@youssef-lr youssef-lr requested a review from a team September 13, 2022 13:17
@melvin-bot melvin-bot bot requested review from Justicea83 and removed request for a team September 13, 2022 13:17
@youssef-lr youssef-lr self-assigned this Sep 13, 2022
@youssef-lr youssef-lr changed the title Refactor ValidationStep Form [WIP] Refactor ValidationStep Form Sep 13, 2022
@youssef-lr youssef-lr marked this pull request as ready for review September 13, 2022 21:08
@youssef-lr youssef-lr requested a review from a team as a code owner September 13, 2022 21:08
@melvin-bot melvin-bot bot requested review from marcochavezf and removed request for a team September 13, 2022 21:09
@youssef-lr youssef-lr changed the title [WIP] Refactor ValidationStep Form Refactor ValidationStep Form Sep 13, 2022
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.

Thanks for working on this! Left a few comments.

Copy link
Contributor

@marcochavezf marcochavezf left a comment

Choose a reason for hiding this comment

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

Looks good! I left a few comments 👍🏽

Edit: Lol I didn't notice that @luacmartins already left some comments a few mins ago (Also I noticed some of them are similar 😄)

Comment on lines 19 to 26
/**
* @param {String} formID
* @param {String} errors
*/
function setErrors(formID, errors) {
Onyx.merge(formID, {errors});
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Why did we create this? I think that we should update the existing setErrorMessage function to conform with the new format we have for errors. We are still early on in the form refactors so it shouldn't be hard to update other instances.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it. I will work on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done @luacmartins. Also updated my PR here to use errors.

marcochavezf
marcochavezf previously approved these changes Sep 23, 2022
*/
function setErrorMessage(formID, error) {
Onyx.merge(formID, {error});
function setErrorMessage(formID, errors) {
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 should rename this to setErrors since that better describes this method now and update other usages of it to pass an object instead of string. I think the only other usages are in Form.stories.js and seems to use these args

@luacmartins
Copy link
Contributor

Conflicts

@youssef-lr
Copy link
Contributor Author

youssef-lr commented Sep 26, 2022

Yup coming from this PR, I'll work on merging the changes into the refactored form.

@luacmartins
Copy link
Contributor

@youssef-lr is this ready for another review?

@youssef-lr
Copy link
Contributor Author

@luacmartins yes, I tested it and seems to work well. However, I'm slightly bothered by the flickering of the screen after we submit valid codes. The view switches back to the validation step for a second then switches to the success page. This is happening on main too, see the recording below:

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

@luacmartins luacmartins self-requested a review September 29, 2022 22:46
@luacmartins
Copy link
Contributor

@youssef-lr if this is on main, you could either try to solve the issue in this PR or log another issue and try to solve that separately. Up to you.

@luacmartins
Copy link
Contributor

@youssef-lr let me know when the conflicts are resolved and this is ready for another review!

@youssef-lr
Copy link
Contributor Author

if this is on main, you could either try to solve the issue in this PR or log another issue and try to solve that separately. Up to you.

I will create a separate issue for this.

Let me know when the conflicts are resolved and this is ready for another review!

All set!

@@ -10,9 +10,9 @@ function setIsLoading(formID, isLoading) {

/**
* @param {String} formID
* @param {Object} errors
* @param {String} errors
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be an object, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

woops yes, fixed.

@youssef-lr
Copy link
Contributor Author

@Justicea83 @marcochavezf bump! :)

Copy link
Contributor

@Justicea83 Justicea83 left a comment

Choose a reason for hiding this comment

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

LGTM!

@luacmartins luacmartins merged commit 43b5092 into main Oct 4, 2022
@luacmartins luacmartins deleted the youssef_refactor_validation_step_form branch October 4, 2022 16:02
@OSBotify
Copy link
Contributor

OSBotify commented Oct 4, 2022

✋ 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

OSBotify commented Oct 6, 2022

🚀 Deployed to staging by @luacmartins in version: 1.2.12-0 🚀

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

@kavimuru
Copy link

kavimuru commented Oct 6, 2022

@youssef-lr We are not able to test the last step in the PR Verify that drafts are saved properly: enter valid amounts and refresh the page, make sure the amounts entered still show up. . When type 2 in all the fields are also showing error.

Recording.1630.mp4

@luacmartins
Copy link
Contributor

Verify that drafts are saved properly: enter valid amounts and refresh the page, make sure the amounts entered still show up.

@kavimuru the tester should refresh the page and confirm that the amounts entered are still visible. They do not need to submit the form with these amounts, since the amounts are obviously wrong.

@OSBotify
Copy link
Contributor

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

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

smrutiparida pushed a commit to autosave-app/App that referenced this pull request Oct 13, 2022
…lidation_step_form

Refactor ValidationStep Form
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.

6 participants