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

feat: Allow table search to include label and value for tables with select column type #36061

Merged
merged 10 commits into from
Sep 12, 2024

Conversation

jacquesikot
Copy link
Contributor

@jacquesikot jacquesikot commented Sep 3, 2024

Description

Problem
The search functionality in the table widget does not properly search through the label values in columns with the select type. Currently, it only searches using the underlying value property, leading to inconsistent and inaccurate search results.

Root Cause
A recent PR updated the table widget to display label values instead of the raw values in select columns. However, this change inadvertently caused the search logic to overlook these label values, continuing to search only by the value property.

Solution
To address this, the search functionality in the derived.js file within tablev2 has been updated. The solution involves retrieving the label value associated with the select column's value property and passing this label into the search logic. This ensures that the search functionality accurately reflects what is displayed in the table, providing correct search results based on the label values.

Fixes #35406

Automation

/ok-to-test tags="@tag.Sanity, @tag.Widget, @tag.Table, @tag.Binding"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/10817317106
Commit: f921efc
Cypress dashboard.
Tags: @tag.Sanity, @tag.Widget, @tag.Table, @tag.Binding
Spec:


Wed, 11 Sep 2024 19:44:20 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced search functionality in the TableWidgetV2 to include label values for select column types.
    • Improved test specifications for the TableV2 component, incorporating feature flags and complex data interactions.
    • Updated test cases to clarify input formats and validate rendering based on new structures.
  • Bug Fixes

    • Added test cases to verify the correct behavior of the table filtering and searching mechanisms.
  • Chores

    • Streamlined input data structure in Cypress tests for better compatibility with the component's configuration requirements.

@jacquesikot jacquesikot added Table Widget ok-to-test Required label for CI Widgets & Accelerators Pod Issues related to widgets & Accelerators labels Sep 3, 2024
@jacquesikot jacquesikot self-assigned this Sep 3, 2024
Copy link
Contributor

coderabbitai bot commented Sep 3, 2024

Walkthrough

The changes enhance the functionality of the TableV2 component by integrating feature flags and improving the search capabilities for select widget columns. A new dataset structure is introduced for testing, and the search functionality now correctly identifies both label and value entries in select columns. These modifications aim to resolve issues related to searching within data tables.

Changes

Files Change Summary
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/TableV2Filter1_1_Spec.ts Added imports for feature flags and editor navigation, defined demo data, and expanded test cases to verify search functionality for select columns.
app/client/src/widgets/TableWidgetV2/widget/derived.js Enhanced the component to handle select column types, allowing label values to be included in the search functionality.
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/columnTypes/Select1_spec.ts Modified input data structure for testing, changing from an object containing an array to a direct array of objects to accommodate new specifications.

Assessment against linked issues

Objective Addressed Explanation
Search functionality should apply to label fields of select widget columns (#[35406])

Possibly related issues

Possibly related PRs

  • chore: fix select1 spec #36228: The changes in this PR involve modifications to the Select1_spec.ts file, which is directly related to the main PR's focus on enhancing the test specifications for the TableV2 component.

Suggested labels

Task, Query & JS Pod, Integrations Product, Integrations Pod General

Poem

In tables where colors brightly shine,
The search now finds both label and line.
With flags that guide and data that flows,
A seamless experience, as everyone knows!
So let’s celebrate this code's new dance,
Where searching brings joy, not just a chance! 🌈


Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5fe966d and f921efc.

Files selected for processing (1)
  • app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/columnTypes/Select1_spec.ts (10 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/columnTypes/Select1_spec.ts

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 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 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 Bug Something isn't working Community Reported issues reported by community members Medium Issues that frustrate users due to poor UX Needs Triaging Needs attention from maintainers to triage Production Widgets Product This label groups issues related to widgets Enhancement New feature or request and removed Bug Something isn't working labels Sep 3, 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: 0

Outside diff range, codebase verification and nitpick comments (1)
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/TableV2Filter1_1_Spec.ts (1)

191-230: Great job on the new test case! Here are a few suggestions to make it even better:

  1. Consider extracting the column options data into a separate constant for better readability and maintainability.
  2. Use more descriptive variable names for the afterSearch variables to clarify their purpose.
  3. Add comments to explain the purpose of each search scenario (label search and value search) for better understanding.

Overall, the test case is well-structured, covers an important scenario, and follows the best practices for Cypress testing. It ensures that the search functionality works correctly for tables with select column types when the feature flag is enabled.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4516129 and b608cf7.

Files selected for processing (2)
  • app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/TableV2Filter1_1_Spec.ts (3 hunks)
  • app/client/src/widgets/TableWidgetV2/widget/derived.js (1 hunks)
Additional context used
Path-based instructions (1)
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/TableV2Filter1_1_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 not posted (7)
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/TableV2Filter1_1_Spec.ts (4)

1-1: Imports look good!

The new import statements for featureFlagIntercept, EditorNavigation, and EntityType are correctly added and will be useful for integrating feature flags and editor navigation functionalities into the test suite.

Also applies to: 12-14


16-60: The demoTableData constant is well-structured and comprehensive.

The demoTableData constant provides a realistic and diverse dataset for testing the TableV2 component. The data structure and attributes cover various scenarios, making it suitable for thorough testing.


Line range hint 1-230: Excellent adherence to Cypress best practices and additional instructions!

The code follows the recommended practices for Cypress testing, such as:

  • Avoiding cy.wait, cy.pause, and agHelper.sleep().
  • Using locator variables instead of plain strings.
  • Utilizing data-* attributes for selectors.
  • Avoiding XPaths, attributes, and complex CSS paths.
  • Performing login, logout, and signup via API calls.
  • Not using it.only.
  • Avoiding after and afterEach hooks in test cases.
  • Using multiple assertions for expect statements.
  • Avoiding the use of strings for assertions.
  • Using a unique filename.
  • Not using agHelper.Sleep or this.Sleep.

Keep up the great work in following the best practices and writing clean, maintainable test code!


Line range hint 1-230: Outstanding work on the Cypress test code!

The code is well-structured, follows best practices, and provides comprehensive coverage of important scenarios. The test cases are readable, maintainable, and adhere to the additional instructions provided.

I appreciate your attention to detail and efforts in writing high-quality test code. Keep up the excellent work, and feel free to reach out if you have any further questions or need assistance with your Cypress tests.

app/client/src/widgets/TableWidgetV2/widget/derived.js (3)

591-616: Great work on enhancing the search for select columns! 👍

The code changes correctly retrieve the label value for select columns and store it in the labelValueForSelectCell variable. This will allow the search to match against the label value displayed to the user.


619-619: Nice addition to the displayedRow object.

Including the labelValueForSelectCell in the displayedRow object ensures that the label value is considered during the search.


Line range hint 1-589:

Also applies to: 620-1000

@sagar-qa007
Copy link
Contributor

@jacquesikot Please check failure.

@github-actions github-actions bot added Bug Something isn't working and removed Bug Something isn't working labels Sep 3, 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: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b608cf7 and a8308c8.

Files selected for processing (1)
  • app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/columnTypes/Select1_spec.ts (5 hunks)
Additional context used
Path-based instructions (1)
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/columnTypes/Select1_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 not posted (3)
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/columnTypes/Select1_spec.ts (3)

89-96: The data structure change is consistent with the previous update.

This code segment also wraps the array of objects with an additional set of curly braces, maintaining consistency with the change observed in the previous code segment. This reinforces the assumption that the modification is part of a broader update to align with a new specification.


Line range hint 182-197: LGTM! The data structure change is consistent.

This code segment follows the same pattern of wrapping the array of objects with an additional set of curly braces. It aligns with the previous changes and maintains consistency throughout the file.


Line range hint 45-60: Verify the impact of the data structure change.

The input data structure for the property control options has been modified by wrapping the array of objects with an additional set of curly braces. While this change seems intentional, it's crucial to ensure that the rest of the application correctly handles this new structure.

Please run the following script to verify that the data structure change does not introduce any regressions:

Verification successful

Let's correct the regex pattern by escaping the curly braces and re-run the script to verify the impact of the data structure change. This will help us ensure that the new data structure is handled correctly throughout the application.


Let's adjust our approach by specifying the file extension directly using the --glob option. This will help us search through the TypeScript files correctly and verify the impact of the data structure change.


No issues found with the data structure change.

The search did not reveal any instances of the cy.updateCodeInput function being used with the updated data structure pattern elsewhere in the codebase. This suggests that the change is isolated to the file under review and does not impact other parts of the application. Therefore, no regressions are expected from this modification.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the table component correctly handles the updated input data structure.

# Test: Search for usages of the property control options data. Expect: No errors related to the data structure change.
rg --type typescript $'cy\.updateCodeInput\(\s*".+",\s*`\s*{{\s*\[\s*{' -A 10

Length of output: 245


Script:

#!/bin/bash
# Description: Verify the table component correctly handles the updated input data structure.

# Test: Search for usages of the property control options data. Expect: No errors related to the data structure change.
rg --type typescript $'cy\\.updateCodeInput\\(\\s*".+",\\s*`\\s*\\{\\{\\s*\\[\\s*\\{' -A 10

Length of output: 116


Script:

#!/bin/bash
# Description: Verify the table component correctly handles the updated input data structure.

# Test: Search for usages of the property control options data. Expect: No errors related to the data structure change.
rg --glob '*.ts' $'cy\\.updateCodeInput\\(\\s*".+",\\s*`\\s*\\{\\{\\s*\\[\\s*\\{' -A 10

Length of output: 77

@jacquesikot
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

github-actions bot commented Sep 3, 2024

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

Copy link

github-actions bot commented Sep 3, 2024

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

Shivam-z pushed a commit to Shivam-z/appsmith that referenced this pull request Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Reported issues reported by community members Enhancement New feature or request Medium Issues that frustrate users due to poor UX Needs Triaging Needs attention from maintainers to triage ok-to-test Required label for CI Production Table Widget Widgets & Accelerators Pod Issues related to widgets & Accelerators Widgets Product This label groups issues related to widgets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: datatable search doesn't apply to label field of select widget columns
3 participants