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

fix: filteredTableData property in autocomplete suggestions #35856

Open
wants to merge 8 commits into
base: release
Choose a base branch
from

Conversation

Pavan134
Copy link

@Pavan134 Pavan134 commented Aug 23, 2024

  • issue link: Link
  • Fix the filteredTableData property in autocomplete suggestions
  • Snapshot:
  • Issue:

image

image

  • After fix:

image

image

  • Cypress test execution:

    image

Description

  • Added filteredTableData property in autocomplete suggestions of table widget.
  • Added cypress test for filteredTableData property to verify it is present or not in autocomplete suggestions

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced filteredTableData property to enhance data handling in the Table Widget.
    • Added automated tests to verify the functionality of autocomplete suggestions based on filtered data in the table widget.
  • Bug Fixes

    • Improved reliability of autocomplete suggestions when filtering options are applied in the Table Widget.
  • Tests

    • Implemented unit tests for the filteredTableData property to ensure correct behavior within autocomplete definitions.
    • Enhanced test coverage for the table widget's filtering capabilities.

Copy link
Contributor

coderabbitai bot commented Aug 23, 2024

Walkthrough

The changes introduce a new filteredTableData property to the TableWidgetV2 class, enhancing its functionality related to filtered data handling. Additionally, Cypress end-to-end and unit tests are added to verify the correct operation of the filteredTableData property within the autocomplete suggestions of the table widget. This ensures that the filtering feature behaves as expected when applied to the table data.

Changes

Files Change Summary
app/client/cypress/e2e/Regression/ClientSide/... Introduces a Cypress test for verifying the filteredTableData property in autocomplete suggestions of a table widget with specific data and filtering options.
app/client/src/widgets/TableWidgetV2/widget/... Adds a new property filteredTableData to the TableWidgetV2 class, derived from the widget's state, enhancing data handling related to filtering.
app/client/src/widgets/TableWidgetV2/checkFilteredDataProperty.test.ts Implements unit tests for the TableWidgetV2, focusing on the filteredTableData property within its autocomplete definitions to ensure correct integration and functionality.

Possibly related PRs

Suggested labels

Bug, Enhancement, Widgets Product, Table Widget, ok-to-test, Widgets & Accelerators Pod, Test

Suggested reviewers

  • ApekshaBhosale
  • rahulbarwal
  • sagar-qa007
  • jacquesikot

Poem

In the realm of widgets, a change takes flight,
Filtering data, making suggestions bright.
With Cypress in tow, we test with glee,
Autocomplete magic for all to see!
A new property born, refined to the core,
Enhancing our tables, who could ask for more? ✨


Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 459c912 and edecbf0.

Files selected for processing (1)
  • app/client/src/widgets/TableWidgetV2/widget/checkFilteredDataProperty.test.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/client/src/widgets/TableWidgetV2/widget/checkFilteredDataProperty.test.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>, 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 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.

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 (5)
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/check_filterTableData_auto_spec.js (5)

1-2: Use ES6 import for locators.

Consider using ES6 import syntax for importing locators instead of require.

Here's how you can do it:

-import * as _ from "../../../../../support/Objects/ObjectsCore";
-const dynamicInputLocators = require("../../../../../locators/DynamicInput.json");
+import * as _ from "../../../../../support/Objects/ObjectsCore";
+import dynamicInputLocators from "../../../../../locators/DynamicInput.json";

55-58: Ensure meaningful test suite tags.

The tags should be meaningful and help in categorizing the test suite effectively. Ensure that they align with your project's tagging strategy.


59-76: Avoid using plain strings for locators.

Use locator variables instead of plain strings for better maintainability and readability.

Here's how you can improve it:

- cy.get(`${dynamicInputLocators.hints} li`)
+ cy.get(dynamicInputLocators.hintsList)

Ensure hintsList is defined in your JSON file.


59-76: Enhance assertions with multiple checks.

Consider adding multiple assertions to ensure the robustness of your test case. For example, check the visibility and text of the suggestion.

Here's an example:

cy.get(dynamicInputLocators.hintsList)
  .should('be.visible')
  .and('contain.text', 'filteredTableData');

60-63: Consider adding teardown steps.

Ensure that the test environment is reset after the test execution to avoid side effects on other tests.

You might want to add cleanup steps at the end of your test case.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 349ddb0 and 453fa0f.

Files selected for processing (2)
  • app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/check_filterTableData_auto_spec.js (1 hunks)
  • app/client/src/widgets/TableWidgetV2/widget/index.tsx (1 hunks)
Additional context used
Path-based instructions (1)
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/check_filterTableData_auto_spec.js (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 (2)
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/check_filterTableData_auto_spec.js (1)

1-77: Adhere to Cypress best practices.

Ensure that the test script adheres to Cypress best practices, such as avoiding cy.wait and using data-* attributes for selectors.

Review the entire test script to ensure compliance with Cypress best practices.

app/client/src/widgets/TableWidgetV2/widget/index.tsx (1)

477-477: Great addition of filteredTableData!

The introduction of filteredTableData to the autocomplete definitions enhances the developer experience by providing more precise suggestions. Ensure that generateTypeDef is correctly handling widget.filteredTableData.

Would you like to verify the usage of generateTypeDef with filteredTableData in the codebase?

@sagar-qa007
Copy link
Contributor

@Pavan134 Can you please explain the requirement for cypress test case here? Also please add equivalent unit test cases.

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

Outside diff range, codebase verification and nitpick comments (1)
app/client/src/widgets/TableWidgetV2/checkFilteredDataProperty.test.ts (1)

16-19: Add comments to explain the purpose of each section.

Adding comments to explain the purpose of each section in the test case will make it easier for others to understand the test case.

Here's an example of how you can add comments:

it("check filteredTableData property", () => {
  // Register the TableWidget
  registerWidgets([TableWidget]);

  // Define the properties for the TableWidget
  const tableWidgetProps: TableWidgetProps = {
    // ... (properties)
  };

  // Create the data tree entity
  const dataTreeEntity: DataTreeEntityObject = {
    ENTITY_TYPE: ENTITY_TYPE.WIDGET,
    meta: {},
    ...tableWidgetProps,
  };

  // Define the data tree entity configuration
  const dataTreeEntityConfig: WidgetEntityConfig = {
    // ... (configuration)
  };

  // Generate definitions and entity information
  const { def, entityInfo } = dataTreeTypeDefCreator(
    {
      Table1: dataTreeEntity,
    },
    {},
    dataTreeEntityConfig
  );

  // Assert that the filteredTableData property exists
  expect(def).toHaveProperty("Table1.filteredTableData");

  // Verify the entity information
  expect(entityInfo.get("Table1")).toStrictEqual({
    type: ENTITY_TYPE.WIDGET,
    subType: "TABLE_WIDGET_V2",
  });
});
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 453fa0f and 0f95934.

Files selected for processing (1)
  • app/client/src/widgets/TableWidgetV2/checkFilteredDataProperty.test.ts (1 hunks)

@Pavan134 Pavan134 force-pushed the bug-filtered-table-data-property-of-table-widget-doesnt-show-up-on-auto-complete branch from 0f95934 to 2d39d27 Compare August 27, 2024 17:17
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: 3

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0f95934 and 2d39d27.

Files selected for processing (1)
  • app/client/src/widgets/TableWidgetV2/widget/checkFilteredDataProperty.test.ts (1 hunks)
Additional comments not posted (4)
app/client/src/widgets/TableWidgetV2/widget/checkFilteredDataProperty.test.ts (4)

1-14: Good job on the imports!

The necessary modules and types are correctly imported.

The code changes are approved.


15-15: Well-named test suite!

The test suite name clearly indicates the purpose of the test.

The code changes are approved.


16-18: Great start with the test case!

The test case correctly registers the TableWidget and sets up the initial properties.

The code changes are approved.


158-199: Excellent verification of the filteredTableData property!

The test case correctly verifies the presence of the filteredTableData property in the autocomplete definitions and the entity information.

The code changes are approved.

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 2d39d27 and 73ad852.

Files selected for processing (1)
  • app/client/src/widgets/TableWidgetV2/widget/checkFilteredDataProperty.test.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/client/src/widgets/TableWidgetV2/widget/checkFilteredDataProperty.test.ts

@Pavan134
Copy link
Author

Hi @sagar-qa007 Gentle Remainder: Thanks for reviewing.I have added unit test cases. Can you please review it?
Thanks in Advance.

@sagar-qa007
Copy link
Contributor

@rahulbarwal Please check this PR. Let's plan this as shadow PR.

cy.get(`${dynamicInputLocators.hints} li`).contains("filteredTableData").should('be.visible').click();

})
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this red changes. Linter error. Kindly run linter.

Copy link
Author

Choose a reason for hiding this comment

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

@sagar-qa007 How to run linter

Copy link

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

@github-actions github-actions bot added the Stale label Sep 10, 2024
@Pavan134
Copy link
Author

Pavan134 commented Sep 11, 2024

Hii @sagar-qa007 I created cypress test file for checking the 'filteredTableData' property is present in auto complete section.If the cypress file is not required can I delete the file.

@rahulbarwal
Copy link
Contributor

@Pavan134 what is the issue number that this PR is fixing. I don't see any linked issue.

@Pavan134
Copy link
Author

@rahulbarwal This is the issue link

@github-actions github-actions bot removed the Stale label Sep 11, 2024
@rahulbarwal
Copy link
Contributor

@Pavan134 a spec is failing due to new changes in the PR. It needs to be updated.
CI Run: https://github.com/appsmithorg/appsmith/actions/runs/10881528449/job/30191358368
Spec Name: cypress/e2e/Regression/ClientSide/Widgets/TableV2/TableV2_Widget_Copy_Paste_spec.js

Please fix it and let me know if you have any questions.

@Pavan134
Copy link
Author

Pavan134 commented Oct 3, 2024

@rahulbarwal If everything is ok can you review and merge this pr

@rahulbarwal
Copy link
Contributor

@Pavan134 we are revisiting the validity of this issue here: #26097 (comment)

We might not need this fix at all. We appreciate your effort and will keep you updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants