-
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
[AddressPage] Zip Code regex based validation #15880
[AddressPage] Zip Code regex based validation #15880
Conversation
@Beamanator @eVoloshchak One of you needs to 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] |
@@ -97,7 +104,6 @@ class AddressPage extends Component { | |||
const requiredFields = [ | |||
'addressLine1', | |||
'city', | |||
'zipPostCode', |
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.
We want to possibly allow empty values for zip code where there is no postal code system. Waiting for clarification on the expected behaviour here before moving ahead with this case.
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.
Removing this here is fine but I think it's still better to show fieldRequired
error than incorrectZipFormat
when country supports postal code and this field is empty. 2 options to fix:
- insert
zipPostCode
conditionally inrequireFields
- validate emptiness first before this line:
if (!countrySpecificZipRegex.test(values.zipPostCode.trim())) {
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 was thinking we could also go down another route, instead of hiding the field, how about we disable it instead and show that "This country does not require a postal code" in place of the format hint?
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.
You can ask that on slack thread. IMO it still doesn't make sense to show that field to users who are never familiar with postal code.
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.
Agree with @0xmiroslav is we know the country does not have a Zip code, we should ideally not show it. But if that is too complicated of a solution, we could go with the fieldRequired
for countries supporting which have zipCode
I'm waiting for clarification on the expected behaviour in cases where the postal code system does not exist for a country, asked here in slack. Will add the videos once this is resolved. cc @Beamanator @0xmiroslav |
Resolved, created a separate object for storing regexes. |
Bug: Screen.Recording.2023-03-14.at.12.29.51.mov(notice how Angola is correctly displayed for a split second, and then it changes back to Ukraine, which is the previous address) |
@eVoloshchak Thanks for testing it out! Yes, I'm aware of this bug right now. This happens because when we save an empty zip code, the backend changes have still not been deployed to allow empty zip code values. Thus, the new address is not saved and it reverts back to the previous address. The behaviour for empty zip code values is still being discussed in slack |
Just to clarify, not sure why @eVoloshchak was assigned here (something wrong with pullbear). I am C+ on the linked issue and already reviewed proposals. |
Oh, I was thinking this is an internal PR since I wasn't assigned to the issue. Must be something with Melvin |
@0xmiroslav this should be fixed now, right? |
@mountiny Right. All similar issues on which I tagged you (sorry annoying you so many times) should be fixed now. Thanks |
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.
@0xmiroslav @Prince-Mendiratta This is looking good to me, left some comments, I thin @Beamanator should be working with limited availability this week.
What is left to resolve on this PR?
@@ -97,7 +104,6 @@ class AddressPage extends Component { | |||
const requiredFields = [ | |||
'addressLine1', | |||
'city', | |||
'zipPostCode', |
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.
Agree with @0xmiroslav is we know the country does not have a Zip code, we should ideally not show it. But if that is too complicated of a solution, we could go with the fieldRequired
for countries supporting which have zipCode
@Prince-Mendiratta can you please resolve the Github comments that have been resolved? I see a lot still open and now that I have the time to jump back into reviewing I'm a bit confused if I should check all open comment threads or not :D |
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.
Sorry to jump in after a long delay and request changes, but I think we can make some of this a bit cleaner :D
@Beamanator Hi, welcome back! Most of the comments were just me communicating the logic behind some logic, have resolved those to keep the ones still relevant open! |
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.
Overall looking great! added 1 tiny comment, but requesting changes b/c linting is failing :D
also @Prince-Mendiratta why are you force-pushing some changes? You shouldn't ever need to do that 🤔 But maybe I'm missing something
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.
Nice, looking good to me! @0xmiroslav can you please do the platform tests when you have time? 👍
Aah we're also waiting on the back-end change to allow zip code to be empty, right? I'll get right on that |
@Beamanator As far as I know, you're never supposed to force push on the main/master branch, the history on feature branches aren't that important so shouldn't be an issue. As for why I force pushed, I pulled the latest changes on the main branch to resolve conflicts and instead of merging, I rebase the feature branch to avoid that "merged main" commit. This removes the GPG signature so I have to rebase my commits again to GPG sign them, thus requiring to force push the changes. I usually stop doing rebases and start with merges once the number/timeline of commits become relevant and important. Hope this makes sense. If you feel that I'm doing something incorrectly, please do point out! |
Yup, also can we confirm the final behaviour for countries with no postal system on backend and frontend? cc @0xmiroslav |
right, I am about to perform full review after backend deploy so was waiting for you 🙂 |
Back-end PR is on staging! 💪 |
Great! will wrap this up today |
@Prince-Mendiratta please pull from main |
and don't use force-push from now on |
@0xmiroslav updated! I will upload the videos as well soon. |
All videos updated in the PR description. @0xmiroslav kindly enable the "Use staging server" toggle when testing as the backend PR is on staging for now. Also, @Beamanator I think we need not wait for the backend PR to hit prod once this is merged since the only case that is significant for the backend changes to be required would be empty zip code, which is not that important and can be deployed to prod as the lifecycle continues. |
@Prince-Mendiratta can we be more specific in test step? (tester doesn't know which country doesn't support zipcode) |
@0xmiroslav updated with a few notable ones. |
Signed-off-by: Prince Mendiratta <prince.mendi@gmail.com>
Signed-off-by: Prince Mendiratta <prince.mendi@gmail.com>
@0xmiroslav updated as per discussions in slack! |
Signed-off-by: Prince Mendiratta <prince.mendi@gmail.com>
Reviewer Checklist
Screenshots/VideosWebweb.movMobile Web - Chromemchrome.movMobile Web - Safarimsafari.movDesktopdesktop.moviOSios.movAndroidandroid.mov |
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.
Latest changes look good, tests well in all possible cases.
@Prince-Mendiratta let's add setting "Use Staging Server" preference in Tests step in case backend won't be deployed to production before QA.
cc: @Beamanator
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.
Big one, great job @Prince-Mendiratta
All yours @Beamanator
Reviewing in a few minute! 👍 |
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.
Yep looking good to go let's merge this! 🥳
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/Beamanator in version: 1.2.94-0 🚀
|
🚀 Deployed to production by https://github.com/thienlnam in version: 1.2.94-3 🚀
|
This PR caused a regression. Some zip code samples were incorrect. |
Details
With this PR, we are making the following changes:
Fixed Issues
$ #14958
PROPOSAL: #14958 (comment)
Tests
For the testing, you can also use ChatGPT to generate random address from a specific country (very helpful tip).
ChatGPT prompt:
Generate 5 random addresses from {country}
All fields except zip code input:
All tests are based on Step 0 as the pre requisite.
0. Go to Settings > Profile > Personal Details > Home Address.
Test 1
Test 2
Address Line 2
andZip / Postcode
, where we allow empty values.Extensive tests specifically for zip code field:
Test 1
Address Line 1
.Test 2
Country
dropdown.Format:
is updated accordingly.Broadly, the countries can be classified into two parts:
A few sample for the same are:
You can also choose and test any country at random as well.
Repeat all the above tests in the Spanish language as well.
Offline tests
N/A. Changes do not depend/affect on the connectivity status of the component.
QA Steps
Make sure that the "Use Staging Server" toggle is turned ON in Settings > Preferences as this PR is dependent on a backend change, which might or might not be deployed to prod by the time this reaches QA.
Same as above.
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)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)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)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
Web
web.mp4
Mobile Web - Chrome
android-mWeb.mp4
Mobile Web - Safari
iOS-mWeb.mp4
Desktop
desktop.mp4
iOS
ios.mp4
Android
android.mp4