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: add sortBy property to table select cell type #35187

Merged

Conversation

jacquesikot
Copy link
Contributor

@jacquesikot jacquesikot commented Jul 25, 2024

Description

Problem
The table widget now supports the Select column type, which allows the column to contain both a label and a value. This could be useful for currency fields, foreign keys, or any other case where you want to display a different version of the column value. However, there is a problem with sorting. The table always sorts using the value, and does not give the user an option to sort using the label, where it makes sense in specific cases.

Solution
This PR adds a Sort By property to the table select cell, allowing the users to choose which value is used for sorting without affecting any functionality of the label or value of the select cell.

Additional Technical Documentation

Tested Cases

  1. Sort select column by default value
    Objective: Ensure that a newly added table with select column default sorts by the value
    Steps:
  • Drop a new table widget.
  • Add sample data to the table.
  • Set a column (e.g., role) to select type.
  • Add selectOptions property
  • Verify that when sorted in ascending or descending order, the sorting is correct
  1. Sort select column by label
    Objective: Ensure that a newly added table with select column and sortBy property set to label sorts correctly
    Steps:
  • Drop a new table widget.
  • Add sample data to the table.
  • Set a column (e.g., role) to select type
  • Add selectOptions property
  • Set sortBy property to label
  • Verify that when sorted in ascending or descending order, the sorting is correct and based on the label value only
  1. Verify that sorting of other table cells that are not select works as expected
    Objective: Ensure that every other cell type in the table sorts correctly
    Steps:
  • Drop a new table widget.
  • Add sample data to the table.
  • Set a column (e.g., role) to select type
  • Add selectOptions property
  • Set sortBy property to label
  • Verify that when columns other that role are sorted, they are sorted correctly
  1. Verify that sorting works as expected when table data is a binding
    Objective: Ensure that the sorting works for all columns while using data binding in table data
    Steps:
  • Drop a new table widget
  • Link a query binding to the table data property
  • Verify that all columns sort correctly
  1. Verify that sorting works as expected when table data is a binding and select column sorting is set to label
    Objective: Ensure that the sorting works for all columns while using data binding in table data with a select column set to sort by the label
    Steps:
  • Drop a new table widget
  • Link a query binding to the table data property
  • Set a column (e.g., role) to select type
  • Add selectOptions property
  • Set sortBy property to label
  • Verify that all columns sort correctly
  1. Verify that sortBy logic does not take effect or break user experience until the user adds selectOptions in select cell
    Steps:
  • Drop a new table widget
  • Link a query binding to the table data property or add raw data
  • Set a column (e.g., role) to select type
  • Do not add selectOptions
  • Set sortBy property to label
  • Verify that all other columns display and sort correctly
  1. Verify that sorting by label and value works correctly in deployed mode
    Steps:
  • Drop a new table widget
  • Link a query binding to the table data property or add raw data
  • Set a column (e.g., role) to select type
  • Add selectOptions
  • Set sortBy property to label
  • Deploy application
  • Confirm that sorting works correctly for all columns

Fixes #21993

Automation

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

🔍 Cypress test results

Tip

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


Tue, 30 Jul 2024 16:02:35 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced a feature flag for dynamic table cell labeling.
    • Added a sorting option for select cells, allowing sort by value or label.
    • Enhanced user interface with new configuration options for select components.
    • Improved sorting functionality for select columns to sort by labels.
  • Bug Fixes

    • Improved sorting functionality in the table widget to ensure accurate data representation.
  • Tests

    • Expanded and clarified test cases for sorting functionality in the Table Widget V2.
    • Updated testing structure for better reliability and isolation of test scenarios.
    • Integrated dynamic testing capabilities based on feature flags.
  • Documentation

    • Added new locators for sorting controls to enhance UI interaction capabilities.

Copy link
Contributor

coderabbitai bot commented Jul 25, 2024

Walkthrough

The recent enhancements to the Table widget's Select column type vastly improve its functionality and user experience. Key updates include the implementation of feature flags for toggling between label and value displays, a refined structure for options, and enhanced sorting capabilities. Collectively, these modifications streamline user interactions, clarify data presentation, and empower users with greater control over how information is displayed and sorted in the widget.

Changes

File(s) Change Summary
app/client/cypress/e2e/.../Select1_spec.ts, app/client/src/ce/entities/FeatureFlag.ts Implemented feature flag support for table cell labeling, updated tests to validate the new label/value structure in Select options, and introduced the feature flag release_table_cell_label_value_enabled to control this functionality.
app/client/src/widgets/TableWidgetV2/component/Constants.ts Modified interfaces to include an optional sortBy property for sorting options and added a new enum TableSelectColumnOptionKeys for standardized handling of selection options.
app/client/src/widgets/TableWidgetV2/component/cellComponents/SelectCell.tsx Enhanced the SelectCell component to utilize the feature flag for determining cell label values, incorporated hooks for efficient data management, and cleaned up import statements for better clarity.
app/client/src/widgets/TableWidgetV2/widget/derived.js Introduced logic to sort "select" columns by label instead of value, transforming data appropriately during the sorting process to improve accuracy and user experience.
app/client/src/widgets/TableWidgetV2/widget/propertyConfig/PanelConfig/Select.ts Added a new property sortBy to control sorting of select options by value or label, enhancing usability in property configuration through validation and default settings.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TableWidget
    participant SelectCell
    participant FeatureFlag

    User->>TableWidget: Interacts with select column
    TableWidget->>SelectCell: Passes current selection
    SelectCell->>FeatureFlag: Checks if label/value feature is enabled
    FeatureFlag-->>SelectCell: Returns feature status
    SelectCell->>SelectCell: Determines display value based on feature status
    SelectCell-->>TableWidget: Returns display value
    TableWidget-->>User: Shows updated select column
Loading

🎉 In the world of code where changes flow,
A Select column blooms, putting on a show.
With labels and values now side by side,
Feature flags dancing, our new pride!
Sorting with ease, a delightful twist,
Usability shines; who could resist? 🌟

Assessment against linked issues

Objective Addressed Explanation
Support for Select column with both label and value (Issue #21993)
Allow users to choose how to display the column (Issue #21993)
Enable sorting by either label or value (Issue #21993)
Improve user experience in handling currency columns in the table widget (Issue #21993) Not explicitly covered in tests.

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 Configuration 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.

@github-actions github-actions bot added the Enhancement New feature or request label Jul 25, 2024
@jacquesikot jacquesikot self-assigned this Jul 25, 2024
@github-actions github-actions bot added Widgets Product This label groups issues related to widgets High This issue blocks a user from building or impacts a lot of users Table Widget Widgets & Blocks Pod labels Jul 25, 2024
…o feat/add-sort-by-property-to-table-select-cell-type
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 ad71b8e and aca623b.

Files selected for processing (6)
  • app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/columnTypes/Select1_spec.ts (2 hunks)
  • app/client/src/ce/entities/FeatureFlag.ts (2 hunks)
  • app/client/src/widgets/TableWidgetV2/component/Constants.ts (3 hunks)
  • app/client/src/widgets/TableWidgetV2/component/cellComponents/SelectCell.tsx (4 hunks)
  • app/client/src/widgets/TableWidgetV2/widget/derived.js (3 hunks)
  • app/client/src/widgets/TableWidgetV2/widget/propertyConfig/PanelConfig/Select.ts (2 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 (18)
app/client/src/ce/entities/FeatureFlag.ts (2)

37-38: Good job adding the new feature flag!

The new feature flag release_table_cell_label_value_enabled is correctly added to the FEATURE_FLAG constant. This addition will allow for dynamic toggling of the feature. Ensure to follow the naming convention as per the guidelines.


68-68: Default value set correctly!

The default value for the new feature flag release_table_cell_label_value_enabled is set to false in the DEFAULT_FEATURE_FLAG_VALUE object. This is a good practice to ensure the feature is disabled by default until explicitly enabled.

app/client/src/widgets/TableWidgetV2/widget/propertyConfig/PanelConfig/Select.ts (2)

10-10: Good import!

The import of TableSelectColumnOptionKeys is necessary for the new sortBy property configuration. This ensures the options for the dropdown are correctly referenced.


41-66: Excellent addition of the sortBy property!

The new sortBy property is well-defined with a clear label, help text, and default value. The options for sorting by "label" or "value" are correctly structured, and the validation ensures only allowed values are used.

app/client/src/widgets/TableWidgetV2/component/cellComponents/SelectCell.tsx (6)

1-1: Good import!

The import of FEATURE_FLAG is necessary for the new feature flag mechanism. This ensures the feature flag is correctly referenced.


4-4: Nice use of the useFeatureFlag hook!

The import of useFeatureFlag is essential for checking the status of the new feature flag. This allows the component to dynamically respond to feature toggles.


197-199: Correct usage of the useFeatureFlag hook!

The useFeatureFlag hook is correctly used to check the status of release_table_cell_label_value_enabled. This ensures the component can dynamically toggle the feature based on the flag's status.


201-212: Well-implemented logic for cellLabelValue!

The useMemo hook is used effectively to compute the cellLabelValue based on the feature flag. This ensures that the label is used when the feature is enabled, otherwise, the value is used.


252-252: Correct usage of cellLabelValue!

The cellLabelValue is correctly used in the StyledSelectComponent to ensure the correct label or value is displayed based on the feature flag.


282-282: Correct usage of cellLabelValue!

The cellLabelValue is also correctly used in the BasicCell component to ensure consistency in the displayed label or value.

app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/columnTypes/Select1_spec.ts (2)

8-8: Good addition of the import statement.

The new import for featureFlagIntercept is necessary for the feature flagging functionality.


157-193: Well-structured test case update.

The test case updates correctly reflect the new feature flag and label-based sorting functionality.

However, ensure that featureFlagIntercept is used correctly throughout the codebase.

Verification successful

Consistent usage of featureFlagIntercept across the codebase.

The function featureFlagIntercept is consistently used across various test files to enable different feature flags, ensuring the correct behavior of the tests.

  • app/client/cypress/support/Pages/AutoLayout.ts
  • app/client/cypress/support/Pages/AdminSettings.ts
  • app/client/cypress/support/commands.js
  • app/client/cypress/e2e/Regression/ClientSide/PartialImportExport/PartialExport_spec.ts
  • app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/columnTypes/Select1_spec.ts
  • And many more...
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `featureFlagIntercept` in the codebase.

# Test: Search for the usage of `featureFlagIntercept`. Expect: Consistent usage.
rg --type js --type ts 'featureFlagIntercept'

Length of output: 11361

app/client/src/widgets/TableWidgetV2/component/Constants.ts (3)

186-186: Good addition of the sortBy property.

The new optional property sortBy enhances the SelectCellProperties interface by allowing sorting options to be specified.


345-345: Good addition of the sortBy property.

The new optional property sortBy enhances the EditActionColumnProperties interface by allowing sorting options to be specified.


577-580: Good addition of the TableSelectColumnOptionKeys enum.

The new enum standardizes the keys used for table selection options, improving type safety and clarity.

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

320-334: Good identification logic for select columns.

The code correctly identifies select columns that need to be sorted by label, which is essential for the new sorting functionality.


336-358: Good data transformation logic for sorting by label.

The code correctly transforms the processedTableData to replace the values in select columns with their corresponding labels for sorting.


Line range hint 394-470:
Well-implemented conditional sorting logic and final data transformation.

The code ensures that the data is sorted by label but retains the correct value representation, which is essential for the new sorting functionality.

@jacquesikot jacquesikot added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jul 25, 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 aca623b and 7f93e56.

Files selected for processing (2)
  • app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/TableV2_Sorting_spec.js (2 hunks)
  • app/client/cypress/locators/commonlocators.json (2 hunks)
Additional context used
Path-based instructions (2)
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/TableV2_Sorting_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.
app/client/cypress/locators/commonlocators.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 not posted (7)
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/TableV2_Sorting_spec.js (6)

7-52: Good use of sample data for testing.

The demoTableData structure is well-defined and provides a comprehensive dataset for testing sorting functionality.


53-59: Great use of beforeEach for test isolation.

Using beforeEach to add a new page before each test ensures test isolation and reliability.


Line range hint 62-117:
Comprehensive test case with multiple assertions.

The test case thoroughly verifies sorting for a custom column, including renaming and preserving data. Ensure that the test case covers all edge cases.


119-157: Clear and focused test case for default sorting.

The test case effectively verifies default sorting for a select column using the value property. Ensure that the feature flag is appropriately managed.


159-201: Well-structured test case for sorting by label.

The test case accurately verifies sorting for a select column type when sortBy is set to label. Ensure that the feature flag is appropriately managed.


1-6: Ensure necessary imports.

The new import statements seem appropriate. Verify that all imported modules are used in the code.

Verification successful

All imported modules are used in the code.

The verification confirms that the imported modules featureFlagIntercept, ObjectsCore, testdata, commonlocators, and PageList are utilized within the file app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/TableV2_Sorting_spec.js.

  • featureFlagIntercept is used for feature flagging.
  • ObjectsCore is used for core object functionalities.
  • testdata is used for test data.
  • commonlocators is used for common locators.
  • PageList is used for page list functionalities.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify usage of imported modules.

# Test: Search for usage of imported modules. Expect: All imported modules are used.
rg --type js 'featureFlagIntercept|ObjectsCore|testdata|commonlocators|PageList'

Length of output: 246341

app/client/cypress/locators/commonlocators.json (1)

109-109: New locator added for sorting control.

The new locator changeSortBy is appropriately named and follows the existing naming conventions. Ensure it is used correctly in the tests.

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 7f93e56 and 6174a55.

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

@jacquesikot jacquesikot added the ok-to-test Required label for CI label Jul 29, 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 (4)
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/TableV2_Sorting_spec.js (4)

1-5: Use locator pages from CommonLocators.ts

Please use locator pages from app/client/cypress/support/Objects/CommonLocators.ts as per previous review comments.


Line range hint 62-117:
Avoid using plain strings for locators

Please use locator variables instead of plain strings for locators. This improves maintainability and readability.

Good use of multiple assertions

The test case uses multiple assertions to verify sorting functionality. This is a good practice.


119-157: Avoid using cy.wait

Please avoid using cy.wait in your test code. Instead, use more reliable methods like cy.intercept and cy.wait for specific network requests.

Use locator variables

Ensure that locator variables are used instead of plain strings for selectors.


159-201: Avoid using cy.wait

Please avoid using cy.wait in your test code. Instead, use more reliable methods like cy.intercept and cy.wait for specific network requests.

Use locator variables

Ensure that locator variables are used instead of plain strings for selectors.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6174a55 and cc83a5e.

Files selected for processing (1)
  • app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/TableV2_Sorting_spec.js (3 hunks)
Additional context used
Path-based instructions (1)
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/TableV2_Sorting_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/TableV2_Sorting_spec.js (2)

7-52: LGTM!

The demoTableData variable is well-structured and suitable for testing the table sorting functionality.


58-59: Good use of beforeEach hook

Replacing before with beforeEach enhances test isolation and reliability.

Copy link
Contributor

@rahulbarwal rahulbarwal left a comment

Choose a reason for hiding this comment

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

Minor changes requested.

@jacquesikot jacquesikot added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jul 29, 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 (4)
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/TableV2_Sorting_spec.js (4)

1-6: Great! But consider using locator pages for imports.

The imports look good, but consider using locator pages from app/client/cypress/support/Objects/CommonLocators.ts for consistency.

-const commonlocators = require("../../../../../locators/commonlocators.json");
+import commonlocators from "../../../../../support/Objects/CommonLocators";

Line range hint 62-117:
Excellent test case! But ensure the use of locator variables.

The test case is well-written and covers the necessary scenarios for sorting and renaming a custom column. However, ensure that locator variables are used instead of plain strings.

-  cy.get(_.propPane._paneTitle).click({ force: true });
-  cy.get(_.propPane._paneTitle)
+  cy.get(commonlocators.paneTitle).click({ force: true });
+  cy.get(commonlocators.paneTitle)

119-169: Good test case! But use locator variables and avoid cy.wait.

The test case is well-written and covers the necessary scenarios for default sorting. However, ensure that locator variables are used and avoid using cy.wait.

-  cy.get(commonlocators.changeColType).last().click();
-  cy.get(_.locators._dropdownText).children().contains("Select").click();
-  cy.wait("@updateLayout");
+  cy.get(commonlocators.changeColType).last().click();
+  cy.get(commonlocators.dropdownText).children().contains("Select").click();

171-225: Great test case! But use locator variables and avoid cy.wait.

The test case is well-written and covers the necessary scenarios for sorting by label. However, ensure that locator variables are used and avoid using cy.wait.

-  cy.get(commonlocators.changeSortBy).last().click();
-  cy.get(_.locators._dropdownText).children().contains("Label").click();
-  cy.wait("@updateLayout");
+  cy.get(commonlocators.changeSortBy).last().click();
+  cy.get(commonlocators.dropdownText).children().contains("Label").click();
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between cc83a5e and 678a3a4.

Files selected for processing (3)
  • app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/TableV2_Sorting_spec.js (3 hunks)
  • app/client/src/widgets/TableWidgetV2/widget/derived.js (3 hunks)
  • app/client/src/widgets/TableWidgetV2/widget/propertyConfig/PanelConfig/Select.ts (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • app/client/src/widgets/TableWidgetV2/widget/derived.js
  • app/client/src/widgets/TableWidgetV2/widget/propertyConfig/PanelConfig/Select.ts
Additional context used
Path-based instructions (1)
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/TableV2_Sorting_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/TableV2_Sorting_spec.js (2)

7-52: Well done! The test data is well-structured.

The demoTableData is well-structured and provides a comprehensive dataset for testing.


58-59: Good use of beforeEach for test isolation.

Using beforeEach ensures that each test starts with a clean state, which is a best practice in Cypress testing.

Copy link
Contributor

@rishabhrathod01 rishabhrathod01 left a comment

Choose a reason for hiding this comment

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

nit

app/client/src/widgets/TableWidgetV2/widget/derived.js Outdated Show resolved Hide resolved
app/client/src/widgets/TableWidgetV2/widget/derived.js Outdated Show resolved Hide resolved
Copy link
Contributor

@rahulbarwal rahulbarwal left a comment

Choose a reason for hiding this comment

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

Spec comments are not addressed.

rahulbarwal
rahulbarwal previously approved these changes Jul 30, 2024
Copy link
Contributor

@rahulbarwal rahulbarwal left a comment

Choose a reason for hiding this comment

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

Ignore my last review! For some reason I did not get the latest changes from the PR.
Lets address suggestions from Rishabh.

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 678a3a4 and 7c90156.

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

@jacquesikot jacquesikot added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jul 30, 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 7c90156 and 8a4e8b2.

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

Comment on lines +326 to +329
const isColumnSortedByLabel =
column?.columnType === "select" &&
column?.sortBy === "label" &&
column?.selectOptions?.length;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to implement the same logic without a specific check? I am wondering why we required such a check only for this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don’t think so. The sort by label logic I implemented should only take effect if those checks are true for specific fields, if those checks do not exist, we need to sort by value, which is the default method for sorting.

@Nikhil-Nandagopal Nikhil-Nandagopal removed Widgets & Blocks Pod Widgets Product This label groups issues related to widgets labels Jul 31, 2024
@github-actions github-actions bot added the Widgets Product This label groups issues related to widgets label Jul 31, 2024
@jacquesikot jacquesikot merged commit 3b1c14a into release Aug 2, 2024
46 checks passed
@jacquesikot jacquesikot deleted the feat/add-sort-by-property-to-table-select-cell-type branch August 2, 2024 07:37
@jacquesikot
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

github-actions bot commented Aug 5, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request High This issue blocks a user from building or impacts a lot of users ok-to-test Required label for CI Table Widget Widgets Product This label groups issues related to widgets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: Add options for labels in select columns in a table widget
5 participants