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

fix: add regex check on phone number change #34715

Open
wants to merge 1 commit into
base: release
Choose a base branch
from

Conversation

SaiCharanChetpelly31
Copy link
Contributor

@SaiCharanChetpelly31 SaiCharanChetpelly31 commented Jul 4, 2024

Fixes - 25911

Summary by CodeRabbit

  • New Features

    • Added validation for phone input to ensure only numeric values are accepted.
  • Tests

    • Updated test scenario to wait for toast message to disappear before clearing input with a non-numeric value.

Copy link
Contributor

coderabbitai bot commented Jul 4, 2024

Walkthrough

The latest changes enhance the phone input widget by adding validation logic that checks against a regex pattern before updating the text property. Additionally, test modifications include waiting for toast messages to disappear before clearing non-numeric values in the phone input field.

Changes

File Path Change Summary
app/client/cypress/e2e/Regression/ClientSide/Widgets/... Added functionality to wait for a toast message to disappear before clearing non-numeric input.
app/client/src/widgets/PhoneInputWidget/widget/index.tsx Introduced regex pattern validation before updating the text property in PhoneInputWidget

Poem

🌟 Within the widget, checks now run,
Regex dances, validation begun.
In the test, we wait, for a toast to fade,
Cleaning numbers in a thoughtful cascade.
Progress shines, the app now bright,
With every change, it reaches new height.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range and nitpick comments (1)
app/client/cypress/e2e/Regression/ClientSide/Widgets/PhoneInput/PhoneInput_Part2_spec.ts (1)

295-297: Avoid using cy.wait in Cypress tests.

Using cy.wait can lead to flaky tests. Instead, use dynamic waits to ensure the toast message disappears before proceeding.

Consider using cy.get() with should('not.exist') to wait for the toast message to disappear.

-  agHelper.Sleep(2000);
+  cy.get(locators._toastMsg).should('not.exist');
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6c48a39 and b0963bb.

Files selected for processing (2)
  • app/client/cypress/e2e/Regression/ClientSide/Widgets/PhoneInput/PhoneInput_Part2_spec.ts (1 hunks)
  • app/client/src/widgets/PhoneInputWidget/widget/index.tsx (1 hunks)
Additional context used
Path-based instructions (1)
app/client/cypress/e2e/Regression/ClientSide/Widgets/PhoneInput/PhoneInput_Part2_spec.ts (1)

Pattern app/client/cypress/**/*.*: Follow best practices for Cypress code and e2e automation.
Avoid using cy.wait.
Use variables for locators, not strings.
Use data-* attributes for selectors; avoid Xpaths and CSS attributes.
Avoid selectors like .btn.submit or button[type=submit].
Perform logins via API with LoginFromAPI.
Only interact with controlled sites/servers.
Ensure tests can run with it.only and are independent.
Use before, beforeEach, after, afterEach correctly; clean state before tests.
Check new specs for flakiness by running them 10 times on CI.
Use multiple assertions; don't treat Cypress as unit tests.
Use constants for strings.
Include datasource operations in before hooks.

Learnings (1)
app/client/cypress/e2e/Regression/ClientSide/Widgets/PhoneInput/PhoneInput_Part2_spec.ts (1)
Learnt from: Aishwarya-U-R
PR: appsmithorg/appsmith#29405
File: app/client/cypress/e2e/Regression/ClientSide/Widgets/Radio/Radio2_spec.ts:404-407
Timestamp: 2023-12-08T09:01:51.841Z
Learning: The `Radio2_spec.ts` file is not part of the initial phase for the removal of static waits in the pull request titled "test: Cypress | Replace static with Dynamic waits - Part 1".
Additional comments not posted (1)
app/client/src/widgets/PhoneInputWidget/widget/index.tsx (1)

411-419: Ensure the regex pattern is appropriate for phone number validation.

The regex pattern /^(?!\s)[\d\s()+-]*$/ allows digits, spaces, parentheses, plus signs, and hyphens. Ensure this pattern meets the validation requirements for phone numbers.

@SaiCharanChetpelly31
Copy link
Contributor Author

HI @ApekshaBhosale

I hope this message finds you well.
As I am at the initial stage of contributing to the project, I am eager to receive your feedback and make any necessary adjustments to align with the project's standards.

Your review is highly valued, and I am committed to ensuring this contribution meets our collective goals. I would greatly appreciate it if you could take some time to review the PR at your earliest convenience.

Thank you for your attention to this matter, and I look forward to your feedback.

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.

None yet

1 participant