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: fix cypress tests for custom widgets #39905

Conversation

rahulbarwal
Copy link
Contributor

@rahulbarwal rahulbarwal commented Mar 25, 2025

Description

Updates the specs with new doc structure in custom widget.

Fixes #Issue Number
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

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

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/14126379520
Commit: c043c29
Cypress dashboard.
Tags: @tag.Widget
Spec:


Fri, 28 Mar 2025 11:26:17 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features
    • Introduced a new text display within the custom widget to showcase the current tip index.
  • Refactor
    • Enhanced the custom widget’s layout and styling, resulting in a cleaner interface and more consistent appearance for a smoother user experience.
    • Updated import statements for React and ReactDOM to improve consistency and clarity in the code.

@rahulbarwal rahulbarwal requested review from jacquesikot and jsartisan and removed request for ApekshaBhosale March 25, 2025 10:10
@rahulbarwal rahulbarwal self-assigned this Mar 25, 2025
@rahulbarwal rahulbarwal added the Custom Widgets For all issues related to the custom widget project label Mar 25, 2025
Copy link
Contributor

coderabbitai bot commented Mar 25, 2025

Walkthrough

This pull request updates both the Cypress tests and the widget configuration. The Cypress test file updates selectors from targeting paragraph elements (.tip-container p) to a new content class (.tip-container .content) to match changes in the DOM structure. The widget JSON fixture file is restructured, with enhancements to CSS and JavaScript, the replacement of certain components (e.g., Card to div, Button to button), and the introduction of a new TEXT_WIDGET. No public API declarations were altered.

Changes

File(s) Summary
app/client/cypress/e2e/.../CustomWidgetDefaultComponent_spec.ts Updated selectors in Cypress tests from .tip-container p to .tip-container .content for both default and published mode components.
app/client/cypress/fixtures/.../customWidget.json Restructured widget configuration with updated CSS/JS (Card → div, Button → button), enhanced styling, and added a new TEXT_WIDGET alongside the existing CUSTOM_WIDGET.
app/client/src/pages/Editor/CustomWidgetBuilder/Editor/Header/CodeTemplates/Templates/anvilTemplates/react.ts Updated import statements for React and ReactDOM from CDN to esm.sh format, renaming reactDom to ReactDOM.
app/client/src/pages/Editor/CustomWidgetBuilder/Editor/Header/CodeTemplates/Templates/react.ts Updated import statements for React and ReactDOM from CDN to esm.sh format, renaming reactDom to ReactDOM.
app/client/src/widgets/CustomWidget/widget/defaultApp.ts Updated import statements for React and ReactDOM from CDN to esm.sh format, renaming reactDom to ReactDOM.

Sequence Diagram(s)

Loading
sequenceDiagram
    participant T as Cypress Test
    participant W as Widget Component
    participant C as JSON Config

    T->>W: Load custom widget page
    W->>C: Fetch updated widget configuration
    C-->>W: Return restructured JSON (includes new TEXT_WIDGET)
    W->>T: Render widget with new `.content` element in tip-container
    T->>W: Query `.tip-container .content`
    T-->>W: Assert expected text content

Possibly related PRs

  • test: custom widget regression tests #39101: The changes in the main PR, which modify selectors in Cypress tests for a custom widget, are related to the changes in the retrieved PR that introduces new tests for validating the property pane of the same custom widget.
  • chore: Anvil on canvas UI tests #35342: The changes in the main PR, which modify selectors in Cypress tests for the custom widget, are related to the retrieved PR that introduces new tests for the Anvil editor's UI.
  • chore: Remove 3rd party dependencies from Custom widget #39894: The changes in the main PR, which involve modifying selectors in Cypress tests for the custom widget, are related to the updates in the retrieved PR that also focus on restructuring the custom widget's layout and styling.

Suggested labels

Bug, Widgets Product, Query & Widgets Pod

Suggested reviewers

  • ApekshaBhosale
  • NandanAnantharamu
  • sagar-qa007

Poem

In the realm of code so bright,
A selector’s change sets tests alight.
JSON reformed with style anew,
Widgets and text come into view.
Code sings in harmony – cheers to this update!
🚀🎉


🪧 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@rahulbarwal rahulbarwal changed the title tests: fix cypress tests for custom widgets test: fix cypress tests for custom widgets Mar 25, 2025
@github-actions github-actions bot added skip-changelog Adding this label to a PR prevents it from being listed in the changelog Test labels Mar 25, 2025
@rahulbarwal rahulbarwal added ok-to-test Required label for CI and removed skip-changelog Adding this label to a PR prevents it from being listed in the changelog Test labels Mar 25, 2025
@github-actions github-actions bot added skip-changelog Adding this label to a PR prevents it from being listed in the changelog Test labels Mar 25, 2025
@rahulbarwal
Copy link
Contributor Author

/ci-test-limit-count run_count=20 update_snapshot=false specs_to_run=cypress/e2e/Regression/ClientSide/Widgets/Custom/CustomWidgetDefaultComponent_spec.ts

@rahulbarwal
Copy link
Contributor Author

/ci-test-limit-count run_count=20 update_snapshot=false specs_to_run=cypress/e2e/Regression/ClientSide/Widgets/Custom/CustomWidgetEditorPropertyPane_spec.ts

Copy link

Copy link

jsartisan
jsartisan previously approved these changes Mar 25, 2025
Copy link

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

Copy link

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

@rahulbarwal
Copy link
Contributor Author

/ci-test-limit-count run_count=20 update_snapshot=false specs_to_run=cypress/e2e/Regression/ClientSide/Widgets/Custom/CustomWidgetDefaultComponent_spec.ts

@rahulbarwal
Copy link
Contributor Author

/ci-test-limit-count run_count=20 update_snapshot=false specs_to_run=cypress/e2e/Regression/ClientSide/Widgets/Custom/CustomWidgetEditorPropertyPane_spec.ts

Copy link

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

🧹 Nitpick comments (1)
app/client/cypress/fixtures/customWidget.json (1)

64-68: CSS Formatting Consistency in Source Documents
Both srcDoc and uncompiledSrcDoc provide similar CSS definitions; however, there is a minor inconsistency in their formatting (e.g., spaces versus tabs). For easier maintenance and clarity, consider standardizing the CSS formatting between these sections.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between f2eb1f5 and c043c29.

📒 Files selected for processing (4)
  • app/client/cypress/fixtures/customWidget.json (2 hunks)
  • app/client/src/pages/Editor/CustomWidgetBuilder/Editor/Header/CodeTemplates/Templates/anvilTemplates/react.ts (2 hunks)
  • app/client/src/pages/Editor/CustomWidgetBuilder/Editor/Header/CodeTemplates/Templates/react.ts (2 hunks)
  • app/client/src/widgets/CustomWidget/widget/defaultApp.ts (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`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. ...

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/customWidget.json
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-build / client-build
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (11)
app/client/src/pages/Editor/CustomWidgetBuilder/Editor/Header/CodeTemplates/Templates/anvilTemplates/react.ts (2)

91-92: Import statements modernized

The imports have been updated from JSDelivr CDN to ESM.sh and reactDom variable is now properly capitalized as ReactDOM to follow React naming conventions.


135-135: Variable reference updated

Reference updated from reactDom to ReactDOM to match the import statement.

app/client/src/widgets/CustomWidget/widget/defaultApp.ts (4)

86-87: Import statements modernized

The imports have been updated from JSDelivr CDN to ESM.sh and reactDom variable is now properly capitalized as ReactDOM to follow React naming conventions.


130-130: Variable reference updated

Reference updated from reactDom to ReactDOM to match the import statement.


215-216: Import statements modernized in compiled code

Similar updates to the imports in the compiled section of the code, ensuring consistency throughout the file.


257-257: Variable reference updated in compiled code

Reference updated from reactDom to ReactDOM in the compiled section, maintaining consistency.

app/client/src/pages/Editor/CustomWidgetBuilder/Editor/Header/CodeTemplates/Templates/react.ts (2)

88-89: Import statements modernized

The imports have been updated from JSDelivr CDN to ESM.sh and reactDom variable is now properly capitalized as ReactDOM to follow React naming conventions.


132-132: Variable reference updated

Reference updated from reactDom to ReactDOM to match the import statement.

app/client/cypress/fixtures/customWidget.json (3)

23-80: Custom Widget ("Custom1") Configuration and Source Document Update
The CUSTOM_WIDGET "Custom1" now features an enriched configuration. The updated srcDoc contains enhanced CSS (e.g., added padding, improved box-sizing, and background settings) along with streamlined HTML and React-based JS logic for managing the tip index. The integration with the appsmith model and event system appears consistent with the new documentation structure.


81-140: New Text Widget ("Text1") Configuration
The new TEXT_WIDGET "Text1" is properly added to display the current index from the CUSTOM_WIDGET via the binding {{Custom1.model.currentIndex}}. All visual and dynamic properties (font size, style, responsiveness, etc.) are defined appropriately. Ensure that these properties and the binding syntax continue to align with both updated documentation and the selectors used in the Cypress tests.


142-142: DSL Block Closure Verification
The closing brace for the DSL block (line 142) is correctly placed. Ensure that the overall JSON structure validates against the expected schema for custom widget fixtures.

@rahulbarwal
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

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

Copy link

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

Copy link

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

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

Copy link

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

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

@rahulbarwal rahulbarwal added the Query & Widgets Pod All issues related to Query, JS, Eval, and Widgets label Mar 28, 2025
@rahulbarwal rahulbarwal merged commit b9c05c1 into release Mar 28, 2025
75 checks passed
@rahulbarwal rahulbarwal deleted the rahulbarwal/fix-cypress-tests-related-to-custom-widget-due-to-new-structure branch March 28, 2025 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Custom Widgets For all issues related to the custom widget project ok-to-test Required label for CI Query & Widgets Pod All issues related to Query, JS, Eval, and Widgets 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.

3 participants