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

test: adding tests for JsObjects regression #38103

Closed
wants to merge 6 commits into from

Conversation

NandanAnantharamu
Copy link
Collaborator

@NandanAnantharamu NandanAnantharamu commented Dec 11, 2024

Summary by CodeRabbit

  • New Features
    • Introduced a new test suite for validating JavaScript Object functionalities, enhancing automated testing coverage.
  • Bug Fixes
    • Updated UI element selectors in the JSEditor for improved interaction handling.
  • Chores
    • Modified the limited-tests configuration to include the new JSObject test suite.

Warning

Tests have not run on the HEAD 1cf2727 yet


Fri, 13 Dec 2024 04:58:15 UTC

Copy link
Contributor

coderabbitai bot commented Dec 11, 2024

Walkthrough

This pull request introduces a new test suite for JavaScript Object (JSObject) functionality using Cypress, consisting of four test cases that validate various interactions with JSObjects. Additionally, it updates the limited-tests.txt file to include the new test specification and modifies the JSEditor class to enhance UI element management related to JSObjects.

Changes

File Path Change Summary
app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_Tests_spec.ts Added a new test suite titled "Validate JSObj" with four test cases for JSObject functionalities, including creation, alert verification, moving objects, and binding to UI widgets.
app/client/cypress/limited-tests.txt Updated the test specification path from Fork_Template_spec.js to JSObject_Tests_spec.ts for limited test runs.
app/client/cypress/support/Pages/JSEditor.ts Modified runButtonLocator and settingsTriggerLocator, added new private properties for managing JSObject interactions, and updated the CreateJSObject method to use the new properties.

Possibly related PRs

Suggested labels

ok-to-test, JS Objects

Suggested reviewers

  • ApekshaBhosale
  • sagar-qa007

Poem

In the land of code where JSObjects play,
New tests arise to brighten the day.
With alerts and moves, they dance and they twirl,
Validating functions in a testing whirl.
So let’s celebrate this code so fine,
For in every test, our features will shine! 🌟


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. (Experiment)
  • @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.

@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 11, 2024
@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit-count run_count=02

Copy link

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: 2

🧹 Outside diff range and nitpick comments (1)
app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_Tests_spec.ts (1)

80-86: Use constants for test data

Extract string literals into constants to improve maintainability:

+const TOAST_MESSAGE = "Hi";
+const BUTTON_OFFSET = { x: 500, y: 100 };

 it("4. Verify JSObject binding", () => {
   PageLeftPane.switchSegment(PagePaneSegment.UI);
-  entityExplorer.DragDropWidgetNVerify(draggableWidgets.BUTTON, 500, 100);
+  entityExplorer.DragDropWidgetNVerify(draggableWidgets.BUTTON, BUTTON_OFFSET.x, BUTTON_OFFSET.y);
   propPane.EnterJSContext("onClick", "{{JSObject11.myFun1();}}", true, false);
   agHelper.GetNClick(locators._widgetInDeployed("buttonwidget"));
-  agHelper.ValidateToastMessage("Hi");
+  agHelper.ValidateToastMessage(TOAST_MESSAGE);
 });
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 61c90ce and 291e1d0.

📒 Files selected for processing (3)
  • app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_Tests_spec.ts (1 hunks)
  • app/client/cypress/limited-tests.txt (1 hunks)
  • app/client/cypress/support/Pages/JSEditor.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
app/client/cypress/limited-tests.txt (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/JSObject_Tests_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.
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.
🔇 Additional comments (2)
app/client/cypress/support/Pages/JSEditor.ts (1)

92-94: LGTM: Well-structured locator additions

The new locators follow best practices by using data-testid attributes and maintaining consistent naming conventions.

app/client/cypress/limited-tests.txt (1)

2-2: LGTM: Valid test specification update

The test specification path is correctly updated while maintaining the file's structure and documentation.

Comment on lines +61 to +65
it("2. Verify alert message on page load", () => {
// Verify alert message on page load
EditorNavigation.NavigateToPage("Page1", true);
agHelper.ValidateToastMessage("Hi");
});
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve test reliability by removing implicit waits

The test relies on the alert message appearing after page navigation. Consider using Cypress's built-in retry-ability instead of implicit waits:

-EditorNavigation.NavigateToPage("Page1", true);
-agHelper.ValidateToastMessage("Hi");
+EditorNavigation.NavigateToPage("Page1", true);
+agHelper.WaitUntilToastMessageAppears("Hi");

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines 19 to 59
it("1. Verify adding JSObject and more actions options", () => {
PageLeftPane.switchSegment(PagePaneSegment.JS);
jsEditor.CreateJSObject(
`setInterval(() => {
showAlert("Hi", "error")
}, 2500, "Int")`,
{
paste: true,
completeReplace: false,
toRun: true,
shouldCreateNewJSObj: true,
},
);
jsEditor.EnableDisableAsyncFuncSettings("myFun1");

// Add new JSObject
PageList.AddNewPage("New blank page");
PageLeftPane.switchSegment(PagePaneSegment.JS);
agHelper.GetNClick(locators._createNew);
agHelper.GetNClick(jsEditor._addJSObj);
agHelper.AssertContains("JSObject2", "exist", ".t--entity-name");
agHelper.GetNClick(EditorNavigation.locators.MinimizeBtn);
agHelper.GetNClick(jsEditor._addJSObj);
agHelper.GetNClick(EditorNavigation.locators.MaximizeBtn);
agHelper.AssertContains("JSObject3", "exist", ".t--entity-name");

// Verify menu item
agHelper.GetNClick(jsEditor._jsPageActions, 0, true);
agHelper.AssertContains("Rename", "exist", HomePage.portalMenuItem);
agHelper.AssertContains("Show bindings", "exist", HomePage.portalMenuItem);
agHelper.AssertContains("Copy to page", "exist", HomePage.portalMenuItem);
agHelper.AssertContains("Move to page", "exist", HomePage.portalMenuItem);
agHelper.AssertContains("Delete", "exist", HomePage.portalMenuItem);

agHelper.GetNClick(jsEditor._moreActions, 0, true);
agHelper.AssertContains("Rename", "exist", HomePage.portalMenuItem);
agHelper.AssertContains("Copy to page", "exist", HomePage.portalMenuItem);
agHelper.AssertContains("Move to page", "exist", HomePage.portalMenuItem);
agHelper.AssertContains("Prettify code", "exist", HomePage.portalMenuItem);
agHelper.AssertContains("Delete", "exist", HomePage.portalMenuItem);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Test case needs improvements to follow best practices

  1. Use data-testid attributes instead of class selectors:
-agHelper.AssertContains("JSObject2", "exist", ".t--entity-name");
+agHelper.AssertContains("JSObject2", "exist", "[data-testid='entity-name']");
  1. Avoid using string selectors for menu items:
-`${HomePage.portalMenuItem}:contains("Move to page")`
+locators._moveToPageMenuItem
  1. Split the test into smaller, more focused test cases for better maintainability.

Committable suggestion skipped: line range outside the PR's diff.

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit

Copy link

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit

12 similar comments
@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit

Copy link

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit

Copy link

Copy link

Copy link

Copy link

Copy link

Copy link

Copy link

Copy link

Copy link

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12275377616.
Cypress dashboard url: Click here!
All Cypress tests have passed 🎉🎉🎉

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

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit-count run_count=02

Copy link

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: 1

🧹 Outside diff range and nitpick comments (1)
app/client/cypress/support/Objects/CommonLocators.ts (1)

Line range hint 1-450: Consider standardizing data-testid prefix pattern

The codebase shows inconsistent usage of the 't--' prefix in data-testid attributes. Some locators use it (e.g., _entityItem, _saveDatasource) while others don't. Consider standardizing this pattern across all locators for better maintainability.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 291e1d0 and 22c8b62.

📒 Files selected for processing (3)
  • app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_Tests_spec.ts (1 hunks)
  • app/client/cypress/support/Objects/CommonLocators.ts (1 hunks)
  • app/client/cypress/support/Pages/JSEditor.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • app/client/cypress/support/Pages/JSEditor.ts
  • app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_Tests_spec.ts
🧰 Additional context used
📓 Path-based instructions (1)
app/client/cypress/support/Objects/CommonLocators.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.

@@ -70,7 +70,7 @@ export class CommonLocators {
this._toastMsg + ":contains('" + toastText + "')";
//_specificToast = (toastText: string | RegExp) => this._toastMsg + ":contains("+ (typeof toastText == 'string' ? "'"+ toastText+"'" : toastText)+ ")"//not working!
_empty = "span[name='no-response']";
_contextMenuInPane = "[data-testid='t--more-action-trigger']";
_contextMenuInPane = "[data-testid='more-action-trigger']";
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Inconsistent selector patterns found in the codebase

The change introduces inconsistency in selector patterns:

  • JSEditor.ts has both old (t--more-action-trigger) and new (more-action-trigger) patterns
  • CommonLocators.ts and most other files consistently use the t-- prefix
  • The component itself uses the new pattern without t--
  • app/client/cypress/support/Pages/JSEditor.ts: Contains duplicate selectors with different patterns
  • app/client/cypress/support/Objects/CommonLocators.ts: Should maintain consistency with other locators that use t-- prefix
🔗 Analysis chain

Verify the impact of removing 't--' prefix from data-testid

The selector change from 't--more-action-trigger' to 'more-action-trigger' might break existing tests. Let's verify all usages of this locator.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any usage of the old selector pattern in test files
# and verify if the new selector exists in the codebase

echo "Checking for old selector usage in test files..."
rg -l "t--more-action-trigger" "app/client/cypress/e2e"

echo "Verifying new selector exists in the codebase..."
rg -l "data-testid=\"more-action-trigger\"" "app/client"

Length of output: 432


Script:

#!/bin/bash
# Let's check the actual implementation in JSEditor.ts to understand how the selector is used
echo "Checking JSEditor.ts implementation..."
rg -A 5 "more-action-trigger" "app/client/cypress/support/Pages/JSEditor.ts"

# Also check the component implementation
echo "Checking MoreActionsMenu.tsx implementation..."
rg -A 5 "more-action-trigger" "app/client/src/pages/Editor/Explorer/Actions/MoreActionsMenu.tsx"

# Let's verify if there are any other similar locators in CommonLocators.ts
echo "Checking other locators in CommonLocators..."
rg "data-testid='t--" "app/client/cypress/support/Objects/CommonLocators.ts"

Length of output: 1920

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12298347303.
Cypress dashboard url: Click here!
All Cypress tests have passed 🎉🎉🎉

***** Repeat Run Summary ***** Total Tests with repeat: 8 Total Passed: 0 Total Failed: 8 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: 2

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 22c8b62 and 4000628.

📒 Files selected for processing (1)
  • app/client/cypress/support/Pages/JSEditor.ts (2 hunks)
🧰 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.

Comment on lines +92 to +94
_addJSObj = '[data-testid="t--ide-tabs-add-button"]';
_jsPageActions = ".entity-context-menu";
_moreActions = '[data-testid="t--more-action-trigger"]';
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use data-testid instead of class selector

The _jsPageActions property uses a class selector which goes against the coding guidelines.

Apply this diff:

   _addJSObj = '[data-testid="t--ide-tabs-add-button"]';
-  _jsPageActions = ".entity-context-menu";
+  _jsPageActions = '[data-testid="t--entity-context-menu"]';
   _moreActions = '[data-testid="t--more-action-trigger"]';
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
_addJSObj = '[data-testid="t--ide-tabs-add-button"]';
_jsPageActions = ".entity-context-menu";
_moreActions = '[data-testid="t--more-action-trigger"]';
_addJSObj = '[data-testid="t--ide-tabs-add-button"]';
_jsPageActions = '[data-testid="t--entity-context-menu"]';
_moreActions = '[data-testid="t--more-action-trigger"]';

Comment on lines 35 to 36
public runButtonLocator = ".run-js-action";
public settingsTriggerLocator = "[data-testid='t--js-settings-trigger'";
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix selector issues in locators

  1. runButtonLocator should use data-testid instead of class selector as per guidelines
  2. settingsTriggerLocator is missing closing bracket

Apply this diff to fix the issues:

-  public runButtonLocator = ".run-js-action";
-  public settingsTriggerLocator = "[data-testid='t--js-settings-trigger'";
+  public runButtonLocator = "[data-testid='t--run-js-action']";
+  public settingsTriggerLocator = "[data-testid='t--js-settings-trigger']";
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public runButtonLocator = ".run-js-action";
public settingsTriggerLocator = "[data-testid='t--js-settings-trigger'";
public runButtonLocator = "[data-testid='t--run-js-action']";
public settingsTriggerLocator = "[data-testid='t--js-settings-trigger']";

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit-count run_count=01

Copy link

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12301488337.
Cypress dashboard url: Click here!
All Cypress tests have passed 🎉🎉🎉

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

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit-count run_count=01

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: 3

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between bef8061 and 1cf2727.

📒 Files selected for processing (1)
  • app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_Tests_spec.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_Tests_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 (2)
app/client/cypress/e2e/Regression/ClientSide/JSObject/JSObject_Tests_spec.ts (2)

61-65: 🛠️ Refactor suggestion

Improve test reliability by removing implicit waits

The test relies on the alert message appearing after page navigation. Consider using Cypress's built-in retry-ability instead of implicit waits.

-EditorNavigation.NavigateToPage("Page1", true);
-agHelper.ValidateToastMessage("Hi");
+EditorNavigation.NavigateToPage("Page1", true);
+agHelper.WaitUntilToastMessageAppears("Hi");

85-85: 🛠️ Refactor suggestion

Use explicit wait for toast message

Replace ValidateToastMessage with WaitUntilToastMessageAppears for better test reliability.

-agHelper.ValidateToastMessage("Hi");
+agHelper.WaitUntilToastMessageAppears("Hi");

Likely invalid or redundant comment.

PageLeftPane.switchSegment(PagePaneSegment.JS);
agHelper.GetNClick(locators._createNew);
agHelper.GetNClick(jsEditor._addJSObj);
agHelper.AssertContains("JSObject2", "exist", ".t--entity-name");
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use data-testid attributes instead of class selectors

Using class selectors (.t--entity-name) is against the provided coding guidelines. Use data-testid attributes instead.

-agHelper.AssertContains("JSObject2", "exist", ".t--entity-name");
+agHelper.AssertContains("JSObject2", "exist", "[data-testid='entity-name']");
-agHelper.AssertContains("JSObject3", "exist", ".t--entity-name");
+agHelper.AssertContains("JSObject3", "exist", "[data-testid='entity-name']");

Also applies to: 43-43

Comment on lines +70 to +73
agHelper.HoverElement(
`${HomePage.portalMenuItem}:contains("Move to page")`,
);
agHelper.GetNClick(`${HomePage.portalMenuItem}:contains("Page2")`);
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Replace string selectors with data attributes

Using string concatenation and CSS contains selectors is against best practices. Use data-testid attributes instead.

-agHelper.HoverElement(
-  `${HomePage.portalMenuItem}:contains("Move to page")`,
-);
-agHelper.GetNClick(`${HomePage.portalMenuItem}:contains("Page2")`);
+agHelper.HoverElement("[data-testid='move-to-page-menu-item']");
+agHelper.GetNClick("[data-testid='page2-menu-item']");

-agHelper.GetNClick(`.t--entity-name:contains("JSObject11")`);
+agHelper.GetNClick("[data-testid='js-object-11']");

Also applies to: 76-76

Comment on lines +16 to +18
describe("Validate JSObj", {}, () => {
before(() => {});

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove empty before hook

The empty before hook serves no purpose and should be removed as per best practices.

-describe("Validate JSObj", {}, () => {
-  before(() => {});
+describe("Validate JSObj", {}, () => {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
describe("Validate JSObj", {}, () => {
before(() => {});
describe("Validate JSObj", {}, () => {

Copy link

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12309867869.
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: 4 Total Passed: 4 Total Failed: 0 Total Skipped: 0 *****************************

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit-count run_count=15

Copy link

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12312490858.
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: 60 Total Passed: 60 Total Failed: 0 Total Skipped: 0 *****************************

Copy link

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

@github-actions github-actions bot added the Stale label Dec 20, 2024
Copy link

This PR has been closed because of inactivity.

@github-actions github-actions bot closed this Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog Adding this label to a PR prevents it from being listed in the changelog Stale Test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant