Skip to content

test: new test case for renaming JS Object#38361

Merged
shadabbuchh merged 4 commits intoreleasefrom
renameJSObjectIssue
Dec 25, 2024
Merged

test: new test case for renaming JS Object#38361
shadabbuchh merged 4 commits intoreleasefrom
renameJSObjectIssue

Conversation

@shadabbuchh
Copy link
Contributor

@shadabbuchh shadabbuchh commented Dec 25, 2024

Description

This PR adds a test case for the bug: #38207

This PR tests the issue where renaming a JS Object via the context menu caused the focus to shift to another tab in the editor.

Changes:

  • Added test cases to validate that focus remains on the current tab while renaming JS Objects.
  • Verified the functionality by renaming multiple JS Objects and ensuring the changes are reflected without altering tab focus.

Automation

/ok-to-test tags="@tag.JS"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12492186342
Commit: 5611d13
Cypress dashboard.
Tags: @tag.JS
Spec:


Wed, 25 Dec 2024 11:16:53 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced a method to rename JavaScript objects via the context menu in the JSEditor.
    • Added a property for referencing the list of JavaScript objects.
  • Tests

    • Implemented a new test suite to validate the renaming functionality and ensure focus remains on the correct tab during the process.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 25, 2024

Walkthrough

This pull request introduces a new method RenameJSObjectFromContextMenu in the JSEditor class to enable renaming JavaScript objects through the context menu. A corresponding test suite RenameJSObjectBug38207_spec.ts has been added to validate the renaming functionality, ensuring that object names can be changed without disrupting the current workspace or causing focus shifts.

Changes

File Change Summary
app/client/cypress/support/Pages/JSEditor.ts Added listOfJsObjects property and RenameJSObjectFromContextMenu method to support JS object renaming
app/client/cypress/e2e/Regression/ClientSide/JSObject/RenameJSObjectBug38207_spec.ts New test suite to verify JS object renaming functionality

Sequence Diagram

sequenceDiagram
    participant User
    participant JSEditor
    participant ContextMenu
    User->>JSEditor: Trigger context menu
    JSEditor->>ContextMenu: Open rename option
    User->>ContextMenu: Input new name
    ContextMenu->>JSEditor: Update object name
Loading

Possibly related PRs

Suggested labels

Bug, JS Objects, Javascript Product, IDE Product

Suggested reviewers

  • ApekshaBhosale
  • sagar-qa007
  • hetunandu

Poem

🖥️ In the realm of code so bright,
A JS object takes its rename flight,
Context menu clicks with grace,
No focus lost, no tab misplaced,
Renaming dance, a coder's delight! 🎉

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@shadabbuchh shadabbuchh added the ok-to-test Required label for CI label Dec 25, 2024
@github-actions github-actions bot added skip-changelog Adding this label to a PR prevents it from being listed in the changelog Test labels Dec 25, 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

🧹 Nitpick comments (2)
app/client/cypress/e2e/Regression/ClientSide/JSObject/renameJSObjectIssue38207.ts (1)

33-38: Renaming the object and verifying.

  • Well done on verifying the renamed object with a direct assertion.
  • Consider adding a second assertion (e.g., confirming the previous name is absent) to strengthen the test.
app/client/cypress/support/Pages/JSEditor.ts (1)

39-39: Selector uses a data-testid but also includes a CSS path.
Consider refining the selector to rely strictly on a single data attribute if possible. This avoids more complex child selectors and aligns better with the recommended Cypress best practices of using stable data attributes.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 65391ab and 38f398c.

📒 Files selected for processing (2)
  • app/client/cypress/e2e/Regression/ClientSide/JSObject/renameJSObjectIssue38207.ts (1 hunks)
  • app/client/cypress/support/Pages/JSEditor.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
app/client/cypress/support/Pages/JSEditor.ts (1)

Pattern app/client/cypress/**/**.*: Review the following e2e test code written using the Cypress test library. Ensure that:

  • Follow best practices for Cypress code and e2e automation.
  • Avoid using cy.wait in code.
  • Avoid using cy.pause in code.
  • Avoid using agHelper.sleep().
  • Use locator variables for locators and do not use plain strings.
  • Use data-* attributes for selectors.
  • Avoid Xpaths, Attributes and CSS path.
  • Avoid selectors like .btn.submit or button[type=submit].
  • Perform logins via API with LoginFromAPI.
  • Perform logout via API with LogOutviaAPI.
  • Perform signup via API with SignupFromAPI.
  • Avoid using it.only.
  • Avoid using after and aftereach in test cases.
  • Use multiple assertions for expect statements.
  • Avoid using strings for assertions.
  • Do not use duplicate filenames even with different paths.
  • Avoid using agHelper.Sleep, this.Sleep in any file in code.
app/client/cypress/e2e/Regression/ClientSide/JSObject/renameJSObjectIssue38207.ts (1)

Pattern app/client/cypress/**/**.*: Review the following e2e test code written using the Cypress test library. Ensure that:

  • Follow best practices for Cypress code and e2e automation.
  • Avoid using cy.wait in code.
  • Avoid using cy.pause in code.
  • Avoid using agHelper.sleep().
  • Use locator variables for locators and do not use plain strings.
  • Use data-* attributes for selectors.
  • Avoid Xpaths, Attributes and CSS path.
  • Avoid selectors like .btn.submit or button[type=submit].
  • Perform logins via API with LoginFromAPI.
  • Perform logout via API with LogOutviaAPI.
  • Perform signup via API with SignupFromAPI.
  • Avoid using it.only.
  • Avoid using after and aftereach in test cases.
  • Use multiple assertions for expect statements.
  • Avoid using strings for assertions.
  • Do not use duplicate filenames even with different paths.
  • Avoid using agHelper.Sleep, this.Sleep in any file in code.
🔇 Additional comments (6)
app/client/cypress/e2e/Regression/ClientSide/JSObject/renameJSObjectIssue38207.ts (6)

1-2: Everything looks good for the import statement.


3-6: Descriptive test title.
Good job providing a clear, user-focused description in the describe block.


7-8: Single test is well-scoped.
The it block name is direct and matches the intent of the test.


9-28: Creation of the first JS Object.
No issues here. The code uses the recommended approach for generating an object in the editor.


30-31: Second JS object creation.
All good.


39-40: Test closure.
Looks neat and organized with no extraneous statements.

@shadabbuchh
Copy link
Contributor Author

/ci-test-limit-count run_count=20 update_snapshot=true specs_to_run=cypress/e2e/Regression/ClientSide/JSObject/renameJSObjectIssue38207.ts

@github-actions
Copy link

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/12490547379.
Cypress dashboard
PR: #38361 with spec: cypress/e2e/Regression/ClientSide/JSObject/renameJSObjectIssue38207.ts .

@github-actions
Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12490547379.
Cypress dashboard: Click here!
The following are new failures, please fix them before merging the PR:
To know the list of identified flaky tests - Refer here

***** Repeat Run Summary ***** Total Tests with repeat: 20 Total Passed: 20 Total Failed: 0 Total Skipped: 0 *****************************

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

🧹 Nitpick comments (2)
app/client/cypress/support/Pages/JSEditor.ts (2)

39-39: Consider making the selector more specific

The selector could be more specific to avoid potential conflicts. Consider using a dedicated data-testid for the list container itself rather than relying on nested elements.

-  public listOfJsObjects = "[data-testid='t--tabs-container']>div>span";
+  public listOfJsObjects = "[data-testid='t--js-objects-list']";

234-239: Enhance error handling and verification

The method could be improved with better error handling and verification:

  1. Use constants for menu items
  2. Add error handling for element not found
  3. Verify the rename operation success
  public RenameJSObjectFromContextMenu(renameVal: string) {
-    cy.get(this.contextMenuTriggerLocator).click();
-    cy.contains("Rename").should("be.visible").click();
-    cy.get(this._jsObjTxt).clear().type(renameVal, { force: true }).blur();
-    PageLeftPane.assertPresence(renameVal);
+    const RENAME_MENU_ITEM = "Rename";
+    cy.get(this.contextMenuTriggerLocator)
+      .should("exist")
+      .click();
+    cy.contains(RENAME_MENU_ITEM)
+      .should("be.visible")
+      .click();
+    cy.get(this._jsObjTxt)
+      .should("exist")
+      .clear()
+      .type(renameVal, { force: true })
+      .should("have.value", renameVal)
+      .blur();
+    // Verify rename in both editor and left pane
+    cy.get(this._jsObjName).should("have.text", renameVal);
+    PageLeftPane.assertPresence(renameVal);
  }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 38f398c and 28a1a5a.

📒 Files selected for processing (2)
  • app/client/cypress/e2e/Regression/ClientSide/JSObject/renameJSObjectIssue38207.ts (1 hunks)
  • app/client/cypress/support/Pages/JSEditor.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/cypress/e2e/Regression/ClientSide/JSObject/renameJSObjectIssue38207.ts
🧰 Additional context used
📓 Path-based instructions (1)
app/client/cypress/support/Pages/JSEditor.ts (1)

Pattern app/client/cypress/**/**.*: Review the following e2e test code written using the Cypress test library. Ensure that:

  • Follow best practices for Cypress code and e2e automation.
  • Avoid using cy.wait in code.
  • Avoid using cy.pause in code.
  • Avoid using agHelper.sleep().
  • Use locator variables for locators and do not use plain strings.
  • Use data-* attributes for selectors.
  • Avoid Xpaths, Attributes and CSS path.
  • Avoid selectors like .btn.submit or button[type=submit].
  • Perform logins via API with LoginFromAPI.
  • Perform logout via API with LogOutviaAPI.
  • Perform signup via API with SignupFromAPI.
  • Avoid using it.only.
  • Avoid using after and aftereach in test cases.
  • Use multiple assertions for expect statements.
  • Avoid using strings for assertions.
  • Do not use duplicate filenames even with different paths.
  • Avoid using agHelper.Sleep, this.Sleep in any file in code.

@shadabbuchh
Copy link
Contributor Author

/ci-test-limit-count run_count=20 update_snapshot=true specs_to_run=cypress/e2e/Regression/ClientSide/JSObject/RenameJSObjectIssue38207.ts

@github-actions
Copy link

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/12491412689.
Cypress dashboard
PR: #38361 with spec: cypress/e2e/Regression/ClientSide/JSObject/RenameJSObjectIssue38207.ts .

@shadabbuchh
Copy link
Contributor Author

/ci-test-limit-count run_count=20 update_snapshot=true specs_to_run=cypress/e2e/Regression/ClientSide/JSObject/RenameJSObjectBug38207_spec.ts runId=12491412689

@github-actions
Copy link

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/12492200618.
Cypress dashboard
PR: #38361 with spec: cypress/e2e/Regression/ClientSide/JSObject/RenameJSObjectBug38207_spec.ts .

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

🧹 Nitpick comments (2)
app/client/cypress/e2e/Regression/ClientSide/JSObject/RenameJSObjectBug38207_spec.ts (2)

7-28: Consider splitting the test scenario into smaller tests.

The single it block contains multiple actions: creating multiple JS objects and renaming them. Splitting these steps into different test blocks can make the tests easier to read, isolate failures more effectively, and simplify maintenance.


26-26: Minor typo in comment.

Spelling error in the comment: "3rd JS Objcte" should be "3rd JS Object".

-      // Validate the new name of the 3rd JS Objcte
+      // Validate the new name of the 3rd JS Object
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a1a596 and 5611d13.

📒 Files selected for processing (1)
  • app/client/cypress/e2e/Regression/ClientSide/JSObject/RenameJSObjectBug38207_spec.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
app/client/cypress/e2e/Regression/ClientSide/JSObject/RenameJSObjectBug38207_spec.ts (1)

Pattern app/client/cypress/**/**.*: Review the following e2e test code written using the Cypress test library. Ensure that:

  • Follow best practices for Cypress code and e2e automation.
  • Avoid using cy.wait in code.
  • Avoid using cy.pause in code.
  • Avoid using agHelper.sleep().
  • Use locator variables for locators and do not use plain strings.
  • Use data-* attributes for selectors.
  • Avoid Xpaths, Attributes and CSS path.
  • Avoid selectors like .btn.submit or button[type=submit].
  • Perform logins via API with LoginFromAPI.
  • Perform logout via API with LogOutviaAPI.
  • Perform signup via API with SignupFromAPI.
  • Avoid using it.only.
  • Avoid using after and aftereach in test cases.
  • Use multiple assertions for expect statements.
  • Avoid using strings for assertions.
  • Do not use duplicate filenames even with different paths.
  • Avoid using agHelper.Sleep, this.Sleep in any file in code.
🔇 Additional comments (1)
app/client/cypress/e2e/Regression/ClientSide/JSObject/RenameJSObjectBug38207_spec.ts (1)

1-2: Looks good!

The import statement follows the recommended structure and references the shared objects module appropriately.

@github-actions
Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12492200618.
Cypress dashboard: Click here!
The following are new failures, please fix them before merging the PR:
To know the list of identified flaky tests - Refer here

***** Repeat Run Summary ***** Total Tests with repeat: 20 Total Passed: 20 Total Failed: 0 Total Skipped: 0 *****************************

@shadabbuchh shadabbuchh merged commit 199233b into release Dec 25, 2024
@shadabbuchh shadabbuchh deleted the renameJSObjectIssue branch December 25, 2024 11:23
NandanAnantharamu pushed a commit that referenced this pull request Dec 27, 2024
## Description

This PR adds a test case for the bug:
#38207

This PR tests the issue where renaming a JS Object via the context menu
caused the focus to shift to another tab in the editor.

Changes:

- Added test cases to validate that focus remains on the current tab
while renaming JS Objects.
- Verified the functionality by renaming multiple JS Objects and
ensuring the changes are reflected without altering tab focus.


## Automation

/ok-to-test tags="@tag.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/12492186342>
> Commit: 5611d13
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12492186342&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.JS`
> Spec:
> <hr>Wed, 25 Dec 2024 11:16:53 UTC
<!-- 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

- **New Features**
- Introduced a method to rename JavaScript objects via the context menu
in the JSEditor.
	- Added a property for referencing the list of JavaScript objects.

- **Tests**
- Implemented a new test suite to validate the renaming functionality
and ensure focus remains on the correct tab during the process.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Feb 7, 2025
## Description

This PR adds a test case for the bug:
appsmithorg#38207

This PR tests the issue where renaming a JS Object via the context menu
caused the focus to shift to another tab in the editor.

Changes:

- Added test cases to validate that focus remains on the current tab
while renaming JS Objects.
- Verified the functionality by renaming multiple JS Objects and
ensuring the changes are reflected without altering tab focus.


## Automation

/ok-to-test tags="@tag.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/12492186342>
> Commit: 5611d13
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12492186342&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.JS`
> Spec:
> <hr>Wed, 25 Dec 2024 11:16:53 UTC
<!-- 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

- **New Features**
- Introduced a method to rename JavaScript objects via the context menu
in the JSEditor.
	- Added a property for referencing the list of JavaScript objects.

- **Tests**
- Implemented a new test suite to validate the renaming functionality
and ensure focus remains on the correct tab during the process.
<!-- 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

ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog Test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants