-
Notifications
You must be signed in to change notification settings - Fork 4.5k
TESTING EXTERNAL SCRIPT: external merge request from Contributor #37185
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
Changes from all commits
b0963bb
ed41946
beea37b
659af9d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -411,13 +411,18 @@ class PhoneInputWidget extends BaseInputWidget< | |
| "value", | ||
| parseIncompletePhoneNumber(formattedValue), | ||
| ); | ||
| this.props.updateWidgetMetaProperty("text", formattedValue, { | ||
| triggerPropertyName: "onTextChanged", | ||
| dynamicString: this.props.onTextChanged, | ||
| event: { | ||
| type: EventType.ON_TEXT_CHANGE, | ||
| }, | ||
| }); | ||
| // This regular expression validates that the input: | ||
| // - Does not start with a whitespace character | ||
| // - Contains only digits, spaces, parentheses, plus, and minus symbols | ||
| if (/^(?!\s)[\d\s()+-]*$/.test(value)) { | ||
| this.props.updateWidgetMetaProperty("text", formattedValue, { | ||
| triggerPropertyName: "onTextChanged", | ||
| dynamicString: this.props.onTextChanged, | ||
| event: { | ||
| type: EventType.ON_TEXT_CHANGE, | ||
| }, | ||
| }); | ||
| } | ||
|
Comment on lines
+414
to
+425
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Class, let's improve our phone number validation! 📱 Good work on adding input validation! However, let's make it even better with these educational improvements:
+// Validates phone number input:
+// - No leading whitespace
+// - Only allows digits, spaces, parentheses, plus, and minus symbols
+const PHONE_NUMBER_PATTERN = /^(?!\s)[\d\s()+-]*$/;
+
onValueChange = (value: string) => {
// ... existing code ...
- if (/^(?!\s)[\d\s()+-]*$/.test(value)) {
+ if (PHONE_NUMBER_PATTERN.test(value)) {
if (PHONE_NUMBER_PATTERN.test(value)) {
this.props.updateWidgetMetaProperty("text", formattedValue, {
triggerPropertyName: "onTextChanged",
dynamicString: this.props.onTextChanged,
event: {
type: EventType.ON_TEXT_CHANGE,
},
});
+ } else {
+ // Notify user about invalid input
+ this.props.updateWidgetMetaProperty("errorMessage", "Please enter a valid phone number");
}
Would you like me to help implement any of these improvements?
|
||
| if (!this.props.isDirty) { | ||
| this.props.updateWidgetMetaProperty("isDirty", true); | ||
| } | ||
|
|
||
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.
Address Potential Flaky Test
In lines 295-297:
To ensure the test is not flaky:
cy.get(locators._toastMsg).should("not.exist");with a more robust wait that accounts for potential delays in toast disappearance.