-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add error-specific validation message in site identification page #91748
Add error-specific validation message in site identification page #91748
Conversation
Jetpack Cloud live (direct link)
Automattic for Agencies live (direct link)
|
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Sections (~1615 bytes added 📈 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
WDYT about requesting a copy review (pfGA22-2-p2) of these error messages first? And it looks like there are some test failures. |
Thanks @donnapep! All tests are green now.
This is a TIL, thanks for sharing it! Just wondering if it would be worth running these through Bohdan/Jana first before submitting for review, WDYT? |
We can just go straight to the copy review folks as they're the copy experts. 🙂 |
Thanks, on it! |
👋🏻 I did a quick test of the behavior. I found it somewhat distracting to see the error message update as I typed. Could we change it so that the message only changes after clicking the button? |
Thanks for checking @donnapep, I've changed the behavior here f5b85cf so that it only appears when you click the button and message disappears when you change something in the input field. I've seen this behavior on many login pages. In case you prefer this message to stay until the next click, LMK! |
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 left some suggestions
@@ -69,13 +72,124 @@ const CaptureInput: FunctionComponent< Props > = ( props ) => { | |||
} | |||
} | |||
|
|||
function isIDN( url: 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.
Can we have this function outside the component body?
Each render is recreating the function.
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.
Thanks, I've handled it here 228d668
} | ||
|
||
// TODO: Just return the translated string directly from getValidationMessage once we have translations for all messages. | ||
const errorMessages = { |
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.
Suggestion: Move all error message logic to a private component, since is this pretty big.
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.
Thank you, done here 228d668
); | ||
} ); | ||
|
||
test( 'should show error for missing top-level domain', async () => { |
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.
Usually, we use the it
instead of test
the file already has scenarios with it
.
test( 'should show error for missing top-level domain', async () => { | |
it.( 'shows error for missing top-level domain', async () => { |
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.
Done under it.each here 3447cd3
} ); | ||
|
||
test( 'should show error for missing top-level domain event when protocol is present', async () => { | ||
await enterUrlAndContinue( 'https://myblog' ); |
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 use dinamic to test all scenarios:
Example:
it.each([
{scenario: 'A', input: 'XXX', error: 'YYY'},
{scenario: 'B', input: 'BB', error: 'ZZZ'},
])(' show error ', ({scenario, input, expected}) => {
await enterUrlAndContinue( input );
expect(
screen.getByText( error )
).toBeInTheDocument();
});
Docs here https://jestjs.io/docs/api#testeachtablename-fn-timeout
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.
Very good suggestion, thank you! Done here 3447cd3
I couldn't get the Looks like your URL has some invalid characters (like ~ or ^). message to trigger with Also, I had some strange behavior when testing that is not related to this PR, but perhaps you may still have insight into. I added |
@Imran92 Given the strings have already been approved in 1NK0CW5QEL336zXL4QfQdiNCDNQhVO2uWJbjEap3rLNM-gdoc, I'm going ahead and adding the "String Freeze" label. Hopefully they'll be translated by the time you're back, and then we can get rid of the additional complexity / duplicated strings prior to merge. |
This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/14781025 Some locales (Hebrew, Japanese) have been temporarily machine-translated due to translator availability. All other translations are usually ready within a few days. Untranslated and machine-translated strings will be sent for translation next Monday and are expected to be completed by the following Friday. Thank you @Imran92 for including a screenshot in the description! This is really helpful for our translators. |
Translation for this Pull Request has now been finished. |
Very good and valid question, yep that'll be bad if that happens. Actually, this was my first fear as well, so to completely avoid that, I only try to detect the type of error when the existing main validation regex detects an error. Only when the
Yap, Right, that will probably be the case |
I am seeing no associated translation strings here https://translate.wordpress.com/deliverables/overview/14781025 . |
We are using the string freeze label instead
I re-tested and can confirm that the internationalized domain name message and the generic error message are showing in English, so there's some problem there. Maybe we should check with the i18n team. Also, any thoughts on #91748 (comment)? |
For French, none of the error messages are translated. |
Thanks for finding it Donna, fixed it here
Nice finding! I wasn't sure what was happening here, so I investigated the issue and found the reason. Apparently, if the URL that is put in the input field redirects to some other URL, we replace the input URL with the final redirected URL. The URL you put there (supsup.com) is on sell by brandbucket.com, so if anyone tries to access the URL, they redirect it to the purchase page. The same will happen if you try with "dubico.com" or "yazani.com" etc. Same happens if we try to access a WPCOM site with the wpcomstaging URL when it has a different primary domain. I'm not sure if it is an expected behavior or a bug though :p |
I'd consider this a bug as it was pretty confusing for me as a user. I'm going to create an issue for it. |
@Imran92 What's the plan for figuring out the translation issue? If we can't solve it in a timely manner, then let's revert the change that removed the use of |
Yap falling back to the update: I did a quick test and seems the issue is resolved. But I'll test again tomorrow |
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.
Everything looks good! Let's
Related to #91479
Proposed Changes
Added error-specific validation messages for the following scenarios.
I have replaced "Incomplete URL Error" from the issue with Wrong Protocol because otherwise the error is too ambiguous and broad to detect. But I am a bit unsure about using the word "Protocol" in the error message, looks too technical. I only kept it because we show it only when the user has already used the wrong protocol and it conveys the exact reason. But LMK if you think a different and less technical message should be shown.
Also, detecting missing TLD is super tricky. For example, "test.com" is valid but "test.wpcomstaging" is not even though both of them has the same structure as a string. So it's not too correct when implemented with regex or some other way through code. But it should be helpful because our error log says users mostly write URLs like this "myblog" instead of "myblog.com" in which case, it'll be helpful.
Also, I've included an example of a valid URL with each error message to better convey to the user how a URL looks.
Why are these changes being made?
To enable the user to better understand what's wrong with the URL they have input.
Screenshots
Testing Instructions
https://wordpress.com/me/account
Screen.Recording.2024-06-14.at.4.32.22.PM.mov
Pre-merge Checklist