appsmith icon indicating copy to clipboard operation
appsmith copied to clipboard

fix: Wrong evaluated value after binding checkbox group widget with…

Open Shivam-z opened this issue 1 year ago • 18 comments

Description

  • In this PR I have fixed wrong evaluated value after binding checkbox group widget with query

Output: Loom

[!TIP]
Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team).

Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR.

Fixes #24620
or
Fixes https://github.com/appsmithorg/appsmith/issues/24620

[!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=""

:mag: Cypress test results

[!CAUTION]
If you modify the content in this section, you are likely to disrupt the CI result for your PR.

Communication

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

  • [ ] Yes
  • [x] No

Shivam-z avatar Jun 03 '24 01:06 Shivam-z

Walkthrough

This update to the project involves various enhancements and bug fixes across different files and workflows. Key changes include modifications to GitHub Actions workflows, the addition and adjustment of Cypress end-to-end tests, updates to Docker configurations, and improvements to widget functionalities within the application. Additionally, the project has seen updates to test scripts and node modules, along with the inclusion of new tests for several Anvil widgets and scenarios.

Changes

File(s) / Directory Change Summary
app/client/src/widgets/CheckboxGroupWidget/widget/index.tsx Added findIndex import and logic to validate/update selectedValues based on options.
.github/workflows/build-client-server.yml Removed matrix configuration from specific job definitions.
.github/workflows/build-docker-image.yml Added step to remove specific Docker images before saving cicontainer image to tar file.
.github/workflows/ci-debugging.yml, .github/workflows/ci-test-limited.yml Changed Docker container port mapping for port 5432 to port 5433.
.github/workflows/ci-test-custom-script.yml, .github/workflows/pr-cypress.yml Added spec parameter, modified port numbers, logic for Cypress tags, and snapshot upload on failure.
.github/workflows/on-demand-build-docker-image-deploy-preview.yml Added DP_POSTGRES_URL environment variable to deployment configuration.
.github/workflows/pr-automation.yml Adjusted event triggers, job configurations, script executions, and handling of specific tags.
.github/workflows/scripts/test-tag-parser.js, .github/workflows/scripts/write-cypress-status.js Updated parseTags function and script logic/exports for managing test response alerts.
.github/workflows/server-build.yml Updated changed-files action version, modified handling of changed files output.
CODEOWNERS Added @sagar-qa007 to app/client/cypress section for ownership assignments.
Dockerfile Ensured all custom command-scripts in /opt/bin/ have executable permissions.
app/client/cypress/Dockerfile Updated to include specific versions for Yarn, Node, Cypress, and Chromium installation.
app/client/cypress/e2e/Regression/ClientSide/Anvil/Widgets/... Introduced new tests for various Anvil widgets covering Canvas, Preview, and Deploy modes.
app/client/cypress/e2e/Regression/ClientSide/BugTests/..., app/client/cypress/e2e/Regression/ClientSide/ExplorerTests/... Added propPane.ToggleJSMode calls and adjusted widget/catalog entries.
app/client/cypress/e2e/Regression/ClientSide/Git/..., app/client/cypress/e2e/Regression/ClientSide/Widgets/... Updated assertions/selector calls, modified visibility checks, and enabled filtering for TableV2.
app/client/cypress/e2e/Regression/ClientSide/Widgets/Switch/SwitchGroup1_spec.ts Updated expected text values and element visibility assertions in test cases.

Sequence Diagram(s)

No sequence diagrams provided due to the varied nature of the changes.

Poem

In the world of code, changes flow,
GitHub actions set to go,
Widgets dance with newfound grace,
Anvil tests in every place,
Docker files and ports align,
Progress marches, oh so fine.
🌟🚀🐇✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

coderabbitai[bot] avatar Jun 03 '24 01:06 coderabbitai[bot]

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

github-actions[bot] avatar Jun 10 '24 16:06 github-actions[bot]

/build-deploy-preview

ramsaptami avatar Jun 11 '24 07:06 ramsaptami

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

github-actions[bot] avatar Jun 11 '24 07:06 github-actions[bot]

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

github-actions[bot] avatar Jun 11 '24 07:06 github-actions[bot]

Fix works on fixed mode, needs to be propagated to Anvil too cc: @jsartisan @KelvinOm

ramsaptami avatar Jun 11 '24 08:06 ramsaptami

@Shivam-z The solution does not work properly. Check the video. A better approach would be a custom validator for the defaultSelectedValues property.

https://github.com/appsmithorg/appsmith/assets/6636360/4962a637-8919-408f-9437-0ed1cec838ef

jsartisan avatar Jun 11 '24 10:06 jsartisan

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

github-actions[bot] avatar Jun 19 '24 16:06 github-actions[bot]

Closing the PR as the solution does not solve the issue properly.

jsartisan avatar Jun 20 '24 08:06 jsartisan

@jsartisan sorry, I was bit busy with the other work , i.e could not able to looked into this PR. can you give me some time to look into this issue and for a better solution. Please reopen this PR.

Shivam-z avatar Jun 20 '24 08:06 Shivam-z

@jsartisan I have modified defaultSelectedValuesValidation could you please review that.

Shivam-z avatar Jun 24 '24 04:06 Shivam-z

The solution looks good to me. Two things

  1. the validation is always valid. even when the value is not an array.
  2. When the options change, it does not trigger the validation again. The solution to this is to add depencyMap:
static getDependencyMap(): Record<string, string[]> {
    return {
      defaultSelectedValues: ["options"],
    };
  }

jsartisan avatar Jun 25 '24 06:06 jsartisan

Hi @jsartisan , I fixed the second suggestion you gave me. can you give me more clarification on first suggestion "the validation is always valid. even when the value is not an array."

here which value you are talking about ? is it defaultSelectedValues ? If it is defaultSelectedValues , then in case of checkBoxGroup Widget it should be an array only right ?

Shivam-z avatar Jun 25 '24 08:06 Shivam-z

Hey, couldn't get time to check again. Regarding this"the validation is always valid. even when the value is not an array.", i think it's fine.

@ramsaptami can you check this PR as well? Codewise it looks okay. Need some help in checking validations for queries.

jsartisan avatar Jun 28 '24 05:06 jsartisan

/build-deploy-preview skip-tests=true

ramsaptami avatar Jun 28 '24 09:06 ramsaptami

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

github-actions[bot] avatar Jun 28 '24 09:06 github-actions[bot]

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

github-actions[bot] avatar Jun 28 '24 09:06 github-actions[bot]

  • default value when different from derived value is not retained in selectedValues property
  • binding a different query refreshes the 'selectedValues' property image

cc: @jsartisan

ramsaptami avatar Jun 28 '24 10:06 ramsaptami

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

github-actions[bot] avatar Jul 06 '24 16:07 github-actions[bot]

@jsartisan can you please look into this PR and tell me whether it is good or I need to rectify something.

Shivam-z avatar Jul 08 '24 02:07 Shivam-z

@Shivam-z Can you check the comments by Saptami? The solution is failing in a few cases.

jsartisan avatar Jul 08 '24 11:07 jsartisan

@jsartisan The comments given by @ramsaptami is the expected behaviour not the bug.

  • In the previous version it was showing the defaultValues as selectedValues even though the derived did not contain those default values . For ex: derivedValues: {1,2,3} , defaultValues:{2,3,4} . so selectedValues should be {2,3} but previously it was {2,3,4} i.e 4 was not retained.
  • In the previous version when binding a different query it was not refreshing the 'selectedValues' property but now it is fixed.

Shivam-z avatar Jul 08 '24 13:07 Shivam-z

@Shivam-z Code looks good to me but I ran the tests on a separate PR and found there is one test that is constantly failing

cypress/e2e/Regression/ClientSide/Widgets/Switch/SwitchGroup1_spec.ts

https://github.com/appsmithorg/appsmith/assets/6636360/c9d1efbd-a662-42fb-966c-7823d2cb992c

Check the video.

Btw Sorry for the back and forth, I know it's taking time.

jsartisan avatar Jul 10 '24 06:07 jsartisan

Hi @jsartisan , I have updated some code in the cypress test case for SwitchGroup1_spec.ts file and it is running fine in my local. can you please check this PR.

Shivam-z avatar Jul 10 '24 10:07 Shivam-z

@Shivam-z something wrong with your PR. It's now showing 616 files. Can you rebase latest release into your branch

jsartisan avatar Jul 11 '24 07:07 jsartisan

I want to create a PR from your PR and run tests on it like we did previously but now your PR is showing 616 files changed.

jsartisan avatar Jul 11 '24 07:07 jsartisan

@jsartisan updated file changes

Shivam-z avatar Jul 11 '24 08:07 Shivam-z

@Shivam-z all tests passing now. What was the issue? Also, can we add a test for it? Just to cover the bug we are solving with this PR.

jsartisan avatar Jul 12 '24 10:07 jsartisan

Hi @jsartisan , some assertions were failing in Switch/SwitchGroup1_spec.ts and it was expecting different color value because of the functionality added in this PR and due to this the test cases were failing earlier , but now it is fixed.

Regarding test to cover this functionality , I have already added one test case in : app/client/src/widgets/CheckboxGroupWidget/widget/index.test.tsx , which justifies this functionality.

Shivam-z avatar Jul 15 '24 07:07 Shivam-z