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:default value for PhoneInput set to text which is invalid(#34594) #34742

Open
wants to merge 2 commits into
base: release
Choose a base branch
from

Conversation

Harshithazemoso
Copy link

@Harshithazemoso Harshithazemoso commented Jul 5, 2024

Description

Tip

Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team).

Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR.

Fixes #34594
or
Fixes https://github.com/appsmithorg/appsmith/issues/34594

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

/ok-to-test tags=""

🔍 Cypress test results

Caution

If you modify the content in this section, you are likely to disrupt the CI result for your PR.

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

SCREENSHOTS AFTER SOLVING THE ISSUE:
No issue when an number is entered
Screenshot from 2024-07-02 17-28-02
Shows error when a text is entered
Screenshot from 2024-07-02 17-26-20

VIDEO
VIDEO:CYPRESS TESTING

Summary by CodeRabbit

  • New Features

    • Enhanced Phone Input widget with improved default value validation and error handling.
  • Tests

    • Added test cases for Phone Input widget to ensure proper default value behavior and error message handling.
  • Bug Fixes

    • Updated error message for Phone Input widget to clearly indicate when a value must be a number.

Copy link
Contributor

coderabbitai bot commented Jul 5, 2024

Walkthrough

The changes introduce new tests, error handling, and validation features for the Phone Input widget. Specifically, the test suite has been updated to verify default values and error scenarios, while the widget's main file now ensures that default values are numbers and displays appropriate error messages when they are not.

Changes

File Change Summary
app/client/cypress/e2e/Regression/ClientSide/Widgets/PhoneInput/PhoneInput_DefaultValue_spec.ts Added test cases to verify default values and error handling for the Phone Input widget. Updated import paths.
app/client/support/Pages/PropertyPane.ts Added a new private member _propertyContentDefaultValueField for the CSS selector .t--property-control-defaultvalue.
app/client/src/widgets/PhoneInputWidget/widget/index.tsx Enhanced defaultValueValidation function to include number validation, added error handling, and messaging.
app/client/cypress/support/Objects/PhoneInputWidgetErrorMessage.ts Introduced a constant NUMBER_ERROR_MESSAGE with "This value must be number".

Sequence Diagram(s)

The changes are relatively straightforward and do not introduce a new feature or significantly modify control flow, so no sequence diagrams are necessary.

Possibly related issues

Poem

In the widgets' realm, a phone we seek,
To parse the numbers, neither bold nor meek.
With tests to verify, and handlers anew,
Default values clean, for all to view.
A rabbit's touch, so swift and neat,
Ensures our inputs won't skip a beat. 🐇📱


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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1325f65 and 18261b7.

Files selected for processing (3)
  • app/client/cypress/e2e/Regression/ClientSide/Widgets/PhoneInput/PhoneInput_DefaultValue_spec.ts (1 hunks)
  • app/client/cypress/support/Pages/PropertyPane.ts (1 hunks)
  • app/client/src/widgets/PhoneInputWidget/widget/index.tsx (2 hunks)
Files skipped from review due to trivial changes (1)
  • app/client/cypress/support/Pages/PropertyPane.ts
Additional context used
Path-based instructions (1)
app/client/cypress/e2e/Regression/ClientSide/Widgets/PhoneInput/PhoneInput_DefaultValue_spec.ts (1)

Pattern app/client/cypress/**/**.*: Follow best practices for Cypress code and e2e automation.
Avoid using cy.wait in code.
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.

Additional comments not posted (7)
app/client/cypress/e2e/Regression/ClientSide/Widgets/PhoneInput/PhoneInput_DefaultValue_spec.ts (5)

1-7: LGTM! Import addition is appropriate.

The addition of commonlocators is necessary for the tests.


9-12: LGTM! Describe block is well-structured.

The describe block is correctly structured and tagged for the Phone Input widget tests.


13-15: LGTM! Before hook setup is appropriate.

The before hook correctly initializes the state by dragging and dropping the Phone Input widget.


17-23: LGTM! Test case implementation is correct.

The test case correctly verifies the default value functionality of the Phone Input widget.


24-28: LGTM! Test case implementation is correct.

The test case correctly verifies the error handling when the default value is not a number.

app/client/src/widgets/PhoneInputWidget/widget/index.tsx (2)

55-58: LGTM! Addition of number error message is appropriate.

The number error message is correctly defined.


79-86: LGTM! Number validation logic is correctly implemented.

The function correctly parses the value as a number and validates it.


describe(
"Phone Input widget Tests",
{ tags: ["@tag.Widget", "@tag.PhoneInput"] },
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Add description to understand this spec more
  2. remove before and make everything as one test
  3. Don't use string to validate messages. use variable instead from respective files

@sagar-qa007

Copy link
Author

Choose a reason for hiding this comment

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

  1. Add description to understand this spec more
  2. remove before and make everything as one test
  3. Don't use string to validate messages. use variable instead from respective files

@sagar-qa007

hello @ApekshaBhosale can you please be more specific about the third one ,are you saying about this,
'agHelper.UpdateCodeInput(propPane._propertyContentDefaultValueField, '9872139');',
and
'agHelper.VerifyEvaluatedErrorMessage('This value must be number');'

Copy link
Contributor

@ApekshaBhosale ApekshaBhosale Jul 5, 2024

Choose a reason for hiding this comment

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

i am talking about 'agHelper.VerifyEvaluatedErrorMessage('This value must be number');' ===> This value must be number

Copy link
Author

@Harshithazemoso Harshithazemoso Jul 5, 2024

Choose a reason for hiding this comment

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

Everywhere they are using the string @ApekshaBhosale , I think its not declared anywhere ,I couldnt find any file where its declared ,can I declare it in a file can I use it here ?

@Harshithazemoso
Copy link
Author

hello @ApekshaBhosale made changes as suggested ,can you review it now

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 18261b7 and ddd06eb.

Files selected for processing (2)
  • app/client/cypress/e2e/Regression/ClientSide/Widgets/PhoneInput/PhoneInput_DefaultValue_spec.ts (1 hunks)
  • app/client/cypress/support/Objects/PhoneInputWidgetErrorMessage.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • app/client/cypress/support/Objects/PhoneInputWidgetErrorMessage.ts
Files skipped from review as they are similar to previous changes (1)
  • app/client/cypress/e2e/Regression/ClientSide/Widgets/PhoneInput/PhoneInput_DefaultValue_spec.ts

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

2 participants