LG-9782: Phone number validity error does not describe how to correct the error#8525
LG-9782: Phone number validity error does not describe how to correct the error#8525
Conversation
changelog: Improvements, accessibility, phone number validity error does not describe how to correct the error
8333073 to
4ee812b
Compare
| expect(phoneNumber.validity.valid).to.be.true(); | ||
| expect(phoneNumber.validity.valid).to.be.false(); |
There was a problem hiding this comment.
The intent of this assertion was to verify that it becomes valid again after entering a complete, valid number.
Could we keep the initial behavior where it validates against a single digit, and then the full number? Since I would expect entering just '5' should have the same behavior.
|
|
||
| getInvalidFormatMessage(countryCode: CountryCode): string { | ||
| return countryCode === 'US' | ||
| ? this.strings.invalid_phone_us || '' |
There was a problem hiding this comment.
Another approach to writing this function, and simplifying the string specifications, might be the following:
getInvalidFormatMessage(countryCode: CountryCode): string {
return countryCode === 'US'
? t('errors.messages.invalid_phone_number.us')
: t('errors.messages.invalid_phone_number.international');
}
Along with adding import { t } from '@18f/identity-i18n'; in the same file.
Glancing at the code quickly, I think that would make it simpler. Maybe I'm overlooking a dependency elsewhere.
There was a problem hiding this comment.
This is possible, but we're maintaining the strings specifications in phone_input_component.rb
|
|
||
| await userEvent.type(phoneNumber, '5'); | ||
| expect(phoneNumber.validationMessage).to.equal('Phone number is not valid'); | ||
| expect(phoneNumber.validationMessage).to.equal('Enter a 10 digit phone number.'); |
There was a problem hiding this comment.
It might be good to create a separate test case for international validation, so that we're checking both, similar to what you had before with the revisions "it validates input for US numbers".
We're testing this indirectly with the test case below ("with single option, it validates phone from region"), but could be good to have the standalone test for the non-singular context.
Basically copy this test case and have two versions:
it('validates input for U.S. number')it('validates input for international number')
Or:
context('with international number', () => {
it('validates input', () => {
// ...
});
});
🎫 Ticket
LG-9782
🛠 Summary of changes
This PR enhances the error message when the user enters an invalid phone number
📜 Testing Plan
Creating an account
From the home screen, follow all instructions to create an account. When on the "Authentication method setup" setup screen, select "Text or voice message"
For US phone number error message:
202555or any combination of numbers with a US area code and is shorter than 10 digits.For non-US numbers:
To toggle for entering a non-US phone number, you can do the following:
+51for Peru+51 333👀 Screenshots
If relevant, include a screenshot or screen capture of the changes.
Before:
After: