-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Conversation
WalkthroughA new Cypress end-to-end test specification has been added to address Bug 33601, focusing on the Changes
Sequence DiagramsequenceDiagram
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
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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 myFun1The 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 buttonThe 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 endpointsThe 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 fileThe 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 beforeEachWhile 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
📒 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.
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"); | ||
}); |
There was a problem hiding this comment.
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:
- Extract repeated selectors into constants
- Use data-cy attributes instead of widget selectors
- 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.
app/client/cypress/e2e/Regression/ClientSide/ActionExecution/Bug33601_spec.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm
## 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 -->
## 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 -->
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?
Summary by CodeRabbit
New Features
resetWidget
feature.Bug Fixes
resetWidget
function.