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

Add error-specific validation message in site identification page #91748

Merged
merged 20 commits into from
Jun 26, 2024

Conversation

Imran92
Copy link
Contributor

@Imran92 Imran92 commented Jun 13, 2024

Related to #91479

Proposed Changes

Added error-specific validation messages for the following scenarios.

  1. Input is an Email
  2. Input has invalid characters
  3. Wrong Protocol (FTP://, file:// etc.)
  4. Missing TLD
  5. IDN URLs (Either has non ASCII characters in URL or hostname starts with xn--)
  6. General error message for fallback

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

Screenshot 2024-06-18 at 7 58 38 AM

Screenshot 2024-06-18 at 7 59 14 AM

Screenshot 2024-06-18 at 7 59 38 AM

Screenshot 2024-06-18 at 8 00 05 AM

Screenshot 2024-06-18 at 8 00 32 AM

Screenshot 2024-06-18 at 8 01 10 AM

Testing Instructions

  • Make sure your language is English in https://wordpress.com/me/account
  • In the migration flow (take any migration path, for example http://calypso.localhost:3000/start), navigate to the Site Identification step
  • In the URL field, try different wrong URLs (Please check the Proposed Changes section above). For example - myblog, https://myblog, https://myblog^, email@myblog.com etc.
  • You should see different error messages depending on the URL
  • Change the language to some other language in https://wordpress.com/me/account
  • Go to the site identification page and try different wrong URLs again
  • Make sure you see the old error message
Screen.Recording.2024-06-14.at.4.32.22.PM.mov

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

@Imran92 Imran92 requested a review from a team June 13, 2024 07:08
@Imran92 Imran92 self-assigned this Jun 13, 2024
@Imran92 Imran92 requested a review from a team as a code owner June 13, 2024 07:08
@matticbot matticbot added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Jun 13, 2024
@matticbot
Copy link
Contributor

matticbot commented Jun 13, 2024

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~1615 bytes added 📈 [gzipped])

name                     parsed_size           gzip_size
import-hosted-site-flow      +1221 B  (+0.1%)     +551 B  (+0.2%)
import-flow                  +1221 B  (+0.0%)     +511 B  (+0.1%)
import                       +1221 B  (+0.2%)     +553 B  (+0.3%)

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.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@donnapep
Copy link
Contributor

donnapep commented Jun 13, 2024

WDYT about requesting a copy review (pfGA22-2-p2) of these error messages first?

And it looks like there are some test failures.

@Imran92
Copy link
Contributor Author

Imran92 commented Jun 13, 2024

Thanks @donnapep! All tests are green now.

WDYT about requesting a copy review (pfGA22-2-p2) of these error messages first?

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?

@donnapep
Copy link
Contributor

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. 🙂

@Imran92
Copy link
Contributor Author

Imran92 commented Jun 13, 2024

We can just go straight to the copy review folks as they're the copy experts. 🙂

Thanks, on it!

@donnapep
Copy link
Contributor

👋🏻 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?

@Imran92
Copy link
Contributor Author

Imran92 commented Jun 14, 2024

👋🏻 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!

Copy link
Contributor

@gabrielcaires gabrielcaires left a 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 ) {
Copy link
Contributor

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.

Copy link
Contributor Author

@Imran92 Imran92 Jun 14, 2024

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 = {
Copy link
Contributor

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.

Copy link
Contributor Author

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 () => {
Copy link
Contributor

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.

Suggested change
test( 'should show error for missing top-level domain', async () => {
it.( 'shows error for missing top-level domain', async () => {

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 under it.each here 3447cd3

} );

test( 'should show error for missing top-level domain event when protocol is present', async () => {
await enterUrlAndContinue( 'https://myblog' );
Copy link
Contributor

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

Copy link
Contributor Author

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

@donnapep
Copy link
Contributor

donnapep commented Jun 17, 2024

I couldn't get the Looks like your URL has some invalid characters (like ~ or ^). message to trigger with
the following:

Screenshot 2024-06-17 at 3 32 08 PM

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 supsup.com as the URL, and on the next screen I clicked the Back button. When I went to the previous screen, my URL was now set to https://www.brandbucket.com/names/supsup?source=ext/, which is really weird. Wondering if we saw a URL like that at all in the error data? Seems like a potential bug to me:

Screenshot 2024-06-17 at 3 46 43 PM

@donnapep
Copy link
Contributor

@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.

@donnapep donnapep added the [Status] String Freeze Add the [Status] String Freeze label to your PR to ensure new strings are translated before merging label Jun 17, 2024
@a8ci18n
Copy link

a8ci18n commented Jun 17, 2024

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.

@a8ci18n
Copy link

a8ci18n commented Jun 23, 2024

Translation for this Pull Request has now been finished.

@Imran92
Copy link
Contributor Author

Imran92 commented Jun 24, 2024

Is there any chance we would show the message even if the URL was valid, and so the user wouldn't be able to move on? Because if so, that would be bad. 🙅🏻

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 isError flag is true, then we try to figure out the proper message for it -

const tempValidationMessage = isValid
			? ''
			: getValidationMessage( url, translate, hasEnTranslation );

But I'm thinking that it would be more the opposite case where we wouldn't catch some missing TLDs, so the user would see the default error message instead. Does that all sound correct?

Yap, Right, that will probably be the case

@Imran92 Imran92 closed this Jun 24, 2024
@Imran92 Imran92 reopened this Jun 24, 2024
@github-actions github-actions bot removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Status] String Freeze Add the [Status] String Freeze label to your PR to ensure new strings are translated before merging labels Jun 24, 2024
@Imran92
Copy link
Contributor Author

Imran92 commented Jun 24, 2024

Translation for this Pull Request has now been finished.

I am seeing no associated translation strings here https://translate.wordpress.com/deliverables/overview/14781025 .

We are using the string freeze label instead
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jun 24, 2024
@Imran92 Imran92 added the [Status] String Freeze Add the [Status] String Freeze label to your PR to ensure new strings are translated before merging label Jun 24, 2024
@donnapep
Copy link
Contributor

donnapep commented Jun 24, 2024

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)?

Screenshot 2024-06-24 at 11 37 56 AM

Screenshot 2024-06-24 at 11 38 07 AM

@donnapep
Copy link
Contributor

For French, none of the error messages are translated.

@Imran92
Copy link
Contributor Author

Imran92 commented Jun 25, 2024

I couldn't get the Looks like your URL has some invalid characters (like ~ or ^). message to trigger with the following:

Thanks for finding it Donna, fixed it here

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 supsup.com as the URL, and on the next screen I clicked the Back button. When I went to the previous screen, my URL was now set to https://www.brandbucket.com/names/supsup?source=ext/, which is really weird. Wondering if we saw a URL like that at all in the error data? Seems like a potential bug to me:

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

@donnapep
Copy link
Contributor

I'm not sure if it is an expected behavior or a bug though

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.

@donnapep
Copy link
Contributor

@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 useHasEnTranslation and ship for English users only. Either way, let's please ship by the end of the week. 🙇🏻‍♀️

@Imran92
Copy link
Contributor Author

Imran92 commented Jun 25, 2024

@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 useHasEnTranslation and ship for English users only. Either way, let's please ship by the end of the week. 🙇🏻‍♀️

Yap falling back to the useHasEnTranslation is my plan if it doesn't get sorted out soon. I've done some investigation already and found that even though the translations are marked as completed in the deliverables for all locales, the strings didn't get included in all translation bundles. I've commented with my findings in the i18n internal channel and they said they'll look into the deployed translations. Hopefully, that'll sort it. p1719343082673409-slack-C02AED43D

update: I did a quick test and seems the issue is resolved. But I'll test again tomorrow

Copy link
Contributor

@donnapep donnapep left a 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 :shipit:

@Imran92 Imran92 merged commit 0d7c7bd into trunk Jun 26, 2024
10 of 11 checks passed
@Imran92 Imran92 deleted the add/validation-message-for-url-identification branch June 26, 2024 13:03
@github-actions github-actions bot removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Status] String Freeze Add the [Status] String Freeze label to your PR to ensure new strings are translated before merging labels Jun 26, 2024
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.

Task: Show more informative error messages for commonly made URL mistakes
5 participants