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: Update SelfReferenceRule to show entity's other property completion #34686

Merged
merged 2 commits into from
Jul 4, 2024

Conversation

rishabhrathod01
Copy link
Contributor

@rishabhrathod01 rishabhrathod01 commented Jul 3, 2024

Description

Update the selfReference autocomplete rule to show completion for the entity's other property when writing JS in one of its property.

Fixes #34684

Automation

/test js

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9780079455
Commit: 03eb92f
Cypress dashboard.
Tags: @tag.JS

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • Bug Fixes

    • Improved accuracy of autocomplete suggestions by refining self-reference detection logic.
  • Tests

    • Added new test cases to verify proper blocking of self-referencing completions.
    • Updated existing tests to include propertyPath in entity sorting validation.

@github-actions github-actions bot added the Bug Something isn't working label Jul 3, 2024
Copy link
Contributor

coderabbitai bot commented Jul 3, 2024

Walkthrough

The changes in the code update the logic in autocomplete functionality to consider both entityName and propertyPath to avoid self-referencing completions. Additionally, test cases were added to verify this behavior by altering relevant files to include this new logic and parameters. This ensures users can now see table properties in autocomplete while avoiding cyclic dependencies.

Changes

Files Change Summary
app/client/src/utils/autocomplete/AutocompleteSortRules.ts Updated NoSelfReferenceRule's computeScore method to include propertyPath in self-reference checks.
app/client/src/utils/autocomplete/__tests__/AutocompleteSortRules.test.ts Added a new test case "Blocks self reference of entity" to verify the updated self-referencing logic.
app/client/src/utils/autocomplete/__tests__/TernServer.test.ts Added propertyPath: "tableData" to an object instantiation to test the new behavior.

Sequence Diagrams

Assessment against linked issues

Objective Addressed Explanation
Show Table's property in the autocomplete for binding in its own property without cyclic dependency (#34684)

Poem

A table's tale, told so fine,
In autocomplete, it now will shine.
Its properties clear, no loops to fear,
A coder's delight, all crystal here.
With tests so bright, our path aligns,
In script and code, it intertwines.
🌟✨

Tip

AI model upgrade

gpt-4o model for reviews and chat is now live

OpenAI claims that this model is better at understanding and generating code than the previous models. Please join our Discord Community to provide any feedback or to report any issues.


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.

@github-actions github-actions bot added Autocomplete Issues related to the autocomplete Javascript Product Issues related to users writing javascript in appsmith Integrations Product Issues related to a specific integration Integrations Pod General Issues related to the Integrations Pod that don't fit into other tags. Medium Issues that frustrate users due to poor UX Task A simple Todo labels Jul 3, 2024
@rishabhrathod01 rishabhrathod01 marked this pull request as ready for review July 3, 2024 14:47
@rishabhrathod01 rishabhrathod01 added the ok-to-test Required label for CI label Jul 3, 2024
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 0b4d664 and 03eb92f.

Files selected for processing (3)
  • app/client/src/utils/autocomplete/AutocompleteSortRules.ts (1 hunks)
  • app/client/src/utils/autocomplete/tests/AutocompleteSortRules.test.ts (1 hunks)
  • app/client/src/utils/autocomplete/tests/TernServer.test.ts (1 hunks)
Additional context used
Path-based instructions (3)
app/client/src/utils/autocomplete/__tests__/AutocompleteSortRules.test.ts (1)

Pattern **/*.*: Do not use cy.wait in code.
Do call the add function.
Do not keep duplicate lines in code.
Descriptive test names are used to clearly convey the intent of each test.

app/client/src/utils/autocomplete/AutocompleteSortRules.ts (1)

Pattern **/*.*: Do not use cy.wait in code.
Do call the add function.
Do not keep duplicate lines in code.
Descriptive test names are used to clearly convey the intent of each test.

app/client/src/utils/autocomplete/__tests__/TernServer.test.ts (1)

Pattern **/*.*: Do not use cy.wait in code.
Do call the add function.
Do not keep duplicate lines in code.
Descriptive test names are used to clearly convey the intent of each test.

Learnings (1)
app/client/src/utils/autocomplete/__tests__/TernServer.test.ts (1)
Learnt from: ankitakinger
PR: appsmithorg/appsmith#29573
File: app/client/src/utils/autocomplete/__tests__/TernServer.test.ts:254-0
Timestamp: 2023-12-13T11:34:08.028Z
Learning: Integration tests cover the `hasCreateDSActionPermissionInApp` function, as clarified by the user.
Additional comments not posted (4)
app/client/src/utils/autocomplete/__tests__/AutocompleteSortRules.test.ts (2)

190-354: Test case looks good!

The test case for blocking self-reference of entities is well-implemented and follows the existing pattern.


Line range hint 417-417: Test case looks good!

The test case for scoring completions is well-implemented and follows the existing pattern.

app/client/src/utils/autocomplete/AutocompleteSortRules.ts (1)

150-154: Logic update looks good!

The update to include propertyPath in the self-reference check is correctly implemented and follows the existing pattern.

app/client/src/utils/autocomplete/__tests__/TernServer.test.ts (1)

417-417: Test case looks good!

The test case for scoring completions is well-implemented and follows the existing pattern.

@rohan-arthur
Copy link
Contributor

/build-deploy-preview skip-test=true

Copy link

github-actions bot commented Jul 4, 2024

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/9789217718.
Workflow: On demand build Docker image and deploy preview.
skip-tests: . env: .
PR: 34686.
recreate: .

Copy link

github-actions bot commented Jul 4, 2024

Deploy-Preview-URL: https://ce-34686.dp.appsmith.com

@rishabhrathod01 rishabhrathod01 merged commit 65eefed into release Jul 4, 2024
48 checks passed
@rishabhrathod01 rishabhrathod01 deleted the fix/updateSelfReferenceRule branch July 4, 2024 09:37
Shivam-z pushed a commit to Shivam-z/appsmith that referenced this pull request Jul 10, 2024
…ion (appsmithorg#34686)

## Description

Update the selfReference autocomplete rule to show completion for the
entity's other property when writing JS in one of its property.

Fixes appsmithorg#34684

## Automation

/test js

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/9780079455>
> Commit: 03eb92f
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9780079455&attempt=2"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.JS`
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Bug Fixes**
- Improved accuracy of autocomplete suggestions by refining
self-reference detection logic.

- **Tests**
- Added new test cases to verify proper blocking of self-referencing
completions.
- Updated existing tests to include `propertyPath` in entity sorting
validation.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Autocomplete Issues related to the autocomplete Bug Something isn't working Integrations Pod General Issues related to the Integrations Pod that don't fit into other tags. Integrations Product Issues related to a specific integration Javascript Product Issues related to users writing javascript in appsmith Medium Issues that frustrate users due to poor UX ok-to-test Required label for CI Task A simple Todo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Show Table's property in the autocomplete for binding in its own property
3 participants