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: Added a new test case for 33601 #38234

Merged
merged 3 commits into from
Dec 19, 2024
Merged

Conversation

sagar-qa007
Copy link
Contributor

@sagar-qa007 sagar-qa007 commented Dec 18, 2024

Description

Automation for Bug: #33601

Fixes #Issue Number

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/12396301697
Commit: ddb795c
Cypress dashboard.
Tags: @tag.JS
Spec:


Wed, 18 Dec 2024 16:25:55 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced a new test case to validate the functionality of the resetWidget feature.
    • Added a structured JSON file representing an application configuration with various attributes and actions.
  • Bug Fixes

    • Implemented a test to address Bug 33601 related to the resetWidget function.

Copy link
Contributor

coderabbitai bot commented Dec 18, 2024

Walkthrough

A new Cypress end-to-end test specification has been added to address Bug 33601, focusing on the resetWidget function's behavior. The test involves importing a predefined application configuration, interacting with various UI components, and verifying widget states before and after form submission and deployment. The test aims to validate the correct handling of widget reset and asynchronous method execution.

Changes

File Change Summary
app/client/cypress/e2e/Regression/ClientSide/ActionExecution/Bug33601_spec.ts New test specification for Bug 33601, testing widget reset functionality
app/client/cypress/fixtures/resetWidgetBug33601.json New application configuration fixture with actions and widget settings

Sequence Diagram

sequenceDiagram
    participant User
    participant App
    participant Widgets
    participant Actions

    User->>App: Navigate to home page
    User->>App: Import application config
    App->>Widgets: Initialize widgets
    User->>Widgets: Enter input label
    User->>Actions: Submit form
    Actions->>Widgets: Reset widget state
    Widgets->>App: Update UI
    User->>App: Verify widget behavior
Loading

Possibly related PRs

Suggested labels

Bug

Suggested reviewers

  • ApekshaBhosale
  • NandanAnantharamu

Poem

🐞 A bug in the widget's dance,
Cypress steps in with a glance,
Reset and test, line by line,
Making sure the code's design
Flows smooth as a summer breeze! 🧪


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 573e943 and ddb795c.

📒 Files selected for processing (1)
  • app/client/cypress/e2e/Regression/ClientSide/ActionExecution/Bug33601_spec.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/cypress/e2e/Regression/ClientSide/ActionExecution/Bug33601_spec.ts

🪧 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.

@sagar-qa007 sagar-qa007 added the ok-to-test Required label for CI label Dec 18, 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 18, 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: 2

🔭 Outside diff range comments (2)
app/client/cypress/fixtures/resetWidgetBug33601.json (2)

Line range hint 4-7: Add race condition handling in myFun1

The function executes multiple asynchronous operations (resetWidget, closeModal, Api1.run) without proper synchronization. Consider using async/await or Promise chaining.

-function () {
-  resetWidget("List1", true);
-  closeModal(Modal1.name);
-  Api1.run();
+async function () {
+  await resetWidget("List1", true);
+  await closeModal(Modal1.name);
+  await Api1.run();
}

Line range hint 249-252: Add onClick handler for Modal's confirm button

The confirm button (Button3) in Modal1 lacks an onClick handler, making it non-functional.

-"buttonColor":"{{appsmith.theme.colors.primaryColor}}",
+"buttonColor":"{{appsmith.theme.colors.primaryColor}}",
+"onClick": "{{JSObject1.myFun1()}}",
🧹 Nitpick comments (3)
app/client/cypress/fixtures/resetWidgetBug33601.json (2)

1-1: Consider using environment variables for API endpoints

The API endpoint "https://docs.appsmith.com" should be configured using environment variables to support different environments (dev, staging, prod).


Line range hint 8-14: Move test data to a separate fixture file

The List widget's test data should be moved to a separate fixture file for better maintainability and reusability.

Create a new file listData.json:

{
  "items": [
    {
      "id": "001",
      "name": "Blue",
      "img": "https://assets.appsmith.com/widgets/default.png"
    }
  ]
}
app/client/cypress/e2e/Regression/ClientSide/ActionExecution/Bug33601_spec.ts (1)

13-24: Consider moving setup steps to beforeEach

While the setup is correct, consider moving the navigation and import steps to a beforeEach block for better test organization and reusability.

 describe(
   "Bug:33601: resetWidget function causes the next async method to be undefined",
   { tags: ["@tag.JS"] },
   () => {
+    beforeEach(() => {
+      homePage.NavigateToHome();
+      homePage.ImportApp("resetWidgetBug33601.json");
+    });
+
     it("1. Bug 33601", () => {
-      homePage.NavigateToHome();
-      homePage.ImportApp("resetWidgetBug33601.json");
       EditorNavigation.SelectEntityByName("List1", EntityType.Widget);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 836b544 and 573e943.

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

1-11: LGTM! Well-organized imports

The imports are properly structured and use appropriate destructuring from core objects.

Comment on lines 25 to 46
agHelper.EnterInputText("Label", "Widget Input2");
EditorNavigation.SelectEntityByName("Button1", EntityType.Widget);
cy.get(locators._widgetInputSelector("inputwidgetv2"))
.first()
.invoke("attr", "value")
.should("contain", "Widget Input2");
agHelper
.GetAttribute(locators._imgWidgetInsideList, "src")
.then((labelValue) => {
expect(labelValue).not.to.contain("data:image/png;base64");
});

agHelper.ClickButton("Submit");
cy.get(locators._widgetInputSelector("inputwidgetv2"))
.first()
.invoke("attr", "value")
.should("be.empty");
agHelper
.GetAttribute(locators._imgWidgetInsideList, "src")
.then((labelValue) => {
expect(labelValue).to.contain("data:image/png;base64");
});
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 and maintainability

Several improvements needed to align with Cypress best practices:

  1. Extract repeated selectors into constants
  2. Use data-cy attributes instead of widget selectors
  3. Consider using cy.should() for assertions instead of then()
+const INPUT_SELECTOR = '[data-cy="input-widget-first"]';
+const IMG_SELECTOR = '[data-cy="list-img-widget"]';

-cy.get(locators._widgetInputSelector("inputwidgetv2"))
+cy.get(INPUT_SELECTOR)
   .first()
   .invoke("attr", "value")
   .should("contain", "Widget Input2");

-agHelper.GetAttribute(locators._imgWidgetInsideList, "src")
+cy.get(IMG_SELECTOR)
   .should("have.attr", "src")
   .and("not.contain", "data:image/png;base64");

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

Copy link
Collaborator

@NandanAnantharamu NandanAnantharamu left a comment

Choose a reason for hiding this comment

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

Lgtm

Copy link
Collaborator

@NandanAnantharamu NandanAnantharamu left a comment

Choose a reason for hiding this comment

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

Lgtm

@sagar-qa007 sagar-qa007 merged commit fa96b4a into release Dec 19, 2024
44 checks passed
@sagar-qa007 sagar-qa007 deleted the test/resetwidgetbug branch December 19, 2024 03:18
NandanAnantharamu pushed a commit that referenced this pull request Dec 27, 2024
## Description
Automation for Bug: #33601


Fixes #[`Issue Number`
](#38071)

## 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/12396301697>
> Commit: ddb795c
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12396301697&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.JS`
> Spec:
> <hr>Wed, 18 Dec 2024 16:25:55 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 new test case to validate the functionality of the
`resetWidget` feature.
- Added a structured JSON file representing an application configuration
with various attributes and actions.

- **Bug Fixes**
- Implemented a test to address Bug 33601 related to the `resetWidget`
function.
<!-- 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
Automation for Bug: appsmithorg#33601


Fixes #[`Issue Number`
](appsmithorg#38071)

## 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/12396301697>
> Commit: ddb795c
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12396301697&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.JS`
> Spec:
> <hr>Wed, 18 Dec 2024 16:25:55 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 new test case to validate the functionality of the
`resetWidget` feature.
- Added a structured JSON file representing an application configuration
with various attributes and actions.

- **Bug Fixes**
- Implemented a test to address Bug 33601 related to the `resetWidget`
function.
<!-- 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