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: mandatory date column enforcement #35613

Merged
merged 7 commits into from
Aug 20, 2024

Conversation

jacquesikot
Copy link
Contributor

@jacquesikot jacquesikot commented Aug 12, 2024

Description

Problem:
When the isRequired property is set for date columns in the table widget, the validation doesn't work as expected. Users can add new rows without filling in the date field, even though it is marked as required. This results in rows being added with missing date values, which can lead to incomplete or invalid data entries.

Root Cause:
The validation logic for the date column is currently handled within the DateCell component. However, the isRequired validation functionality was not implemented within this component. Additionally, the general validation logic in the getEditableCellValidity function, located in the derived.js file, does not account date cells in its isRequired validation.

Solution:
To fix this issue:

Enhance the getEditableCellValidity function: Extend the existing validation logic in getEditableCellValidity to include the date cell in its validation, specifically checking for the isRequired property.

Integrate with DateCell validation: Ensure that the isRequired validation is properly executed in conjunction with the existing date validations inside the DateCell component. This will enforce the requirement and prevent new rows from being added if the date field is left empty.

Test Plan
https://www.notion.so/appsmith/Test-Plan-Date-Column-Marked-as-Required-Doesn-t-Enforce-Mandatory-Entry-When-Adding-New-Table-Row-c73b764af60842a188cba056bdda6d79?pvs=4

Fixes #34258

Automation

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

🔍 Cypress test results

Tip

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


Mon, 19 Aug 2024 13:17:23 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced validation for "Date" column types, ensuring that required fields are correctly enforced.
  • Enhancements

    • Improved validation logic for more accurate user feedback in date cells.
    • Expanded support for validating "date" columns in the table widget.
  • Bug Fixes

    • Enhanced error handling to ensure proper indication of cell validity based on new validation criteria.
    • Updated visual feedback for cell editor state in the UI.

@jacquesikot jacquesikot added Table Widget V2 Issues related to Table Widget V2 Widgets & Accelerators Pod Issues related to widgets & Accelerators labels Aug 12, 2024
@jacquesikot jacquesikot self-assigned this Aug 12, 2024
@github-actions github-actions bot added Bug Something isn't working Help enterprise Requested by Appsmith customers or prospects High This issue blocks a user from building or impacts a lot of users Needs Triaging Needs attention from maintainers to triage Production Table Inline Edit Issues related to inline editing Widgets Product This label groups issues related to widgets labels Aug 12, 2024
@jacquesikot jacquesikot added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Aug 12, 2024
Copy link
Contributor

coderabbitai bot commented Aug 12, 2024

Walkthrough

The changes enhance the validation logic for the date column in the Table widget, ensuring that required fields are enforced when adding new rows. New Cypress tests validate this functionality, while the DateCell component has been updated to accurately reflect these validation requirements. Overall, these improvements aim to boost usability and reliability in data entry within the table.

Changes

File Change Summary
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/AddNewRow2_spec.js Introduced tests to verify that the isRequired validation for the date column functions correctly, checking for error messages when saving a new row without a date entry.
app/client/src/widgets/TableWidgetV2/component/cellComponents/DateCell.tsx Enhanced the DateCell component by adding a new prop, isEditableCellValid, which refines the validation logic with an internal state variable. The rendering logic was updated to use a new computed validity check for improved user feedback.
app/client/src/widgets/TableWidgetV2/widget/derived.js Expanded the validatableColumns array to include the "date" type, enabling validation support for date columns in the Table widget.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TableWidget
    participant DateCell
    participant Validation

    User->>TableWidget: Attempts to add new row (empty date)
    TableWidget->>DateCell: Validate date entry
    DateCell->>Validation: Check isEditableCellValid
    Validation-->>DateCell: Return validation status
    DateCell-->>TableWidget: Notify validity
    TableWidget-->>User: Display error message (if invalid)
Loading

Assessment against linked issues

Objective Addressed Explanation
Date column set as required does not make it mandatory (Issue #34258)

Poem

In the realm of tables, new rules arise,
A date must be filled, no more disguise.
With each new row, a prompt to abide,
No empty fields in this data tide.
Usability dances, validation's glow,
A seamless experience for all users to know! ✨


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.

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/AddNewRow2_spec.js (3)

90-96: Avoid using cy.wait for better test performance.

The use of cy.wait(500) is not recommended as it can lead to flaky tests. Instead, use assertions to wait for specific conditions.

- cy.wait(500);
+ cy.get(`.t--inlined-cell-editor-has-error`).should("exist");

90-96: Use data- attributes for selectors.*

Using class selectors like .t--dropdown-option is not recommended. Prefer using data-* attributes for more robust and maintainable tests.

- cy.get(".t--dropdown-option").children().contains("Date").click();
+ cy.get("[data-testid='t--dropdown-option']").children().contains("Date").click();

90-96: Ensure locators use variables.

Avoid hardcoding locators. Use locator variables for better maintainability and readability.

const dateDropdownOption = "[data-testid='t--dropdown-option']";
cy.get(dateDropdownOption).children().contains("Date").click();
app/client/src/widgets/TableWidgetV2/component/cellComponents/DateCell.tsx (2)

Line range hint 172-199: Ensure prop types are well-defined.

The addition of isEditableCellValid should be reflected in the prop types to ensure type safety.

Ensure that the DateComponentProps type includes isEditableCellValid for better type checking and documentation.


199-199: Improve naming for clarity.

Consider renaming isCellCompletelyValid to something more descriptive, such as isCellValidationComplete, to convey its purpose more clearly.

- const isCellCompletelyValid = isEditableCellValid && isValid;
+ const isCellValidationComplete = isEditableCellValid && isValid;
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0afc9dd and 80bcba9.

Files selected for processing (3)
  • app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/AddNewRow2_spec.js (1 hunks)
  • app/client/src/widgets/TableWidgetV2/component/cellComponents/DateCell.tsx (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/AddNewRow2_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 (1)
app/client/src/widgets/TableWidgetV2/widget/derived.js (1)

854-854: Verify the impact of adding "date" to validatableColumns.

Adding "date" to the validatableColumns array is a significant change. Ensure that all necessary validation logic for date columns is implemented and tested.

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 80bcba9 and d65ab07.

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

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

Line range hint 10-10: Avoid using cy.wait.

Using cy.wait with arbitrary timeouts can lead to flaky tests. Consider using more reliable commands like cy.intercept to wait for specific network requests or cy.get with appropriate assertions.


Line range hint 16-16: Use data- attributes for selectors.*

Avoid using class selectors like .t--inlined-cell-editor-has-error. Instead, use data-* attributes for more reliable and maintainable selectors.

Also applies to: 20-20, 24-24, 28-28, 32-32, 36-36, 40-40


Line range hint 16-16: Use multiple assertions for expect statements.

Avoid using strings directly in assertions. Use multiple expect statements to provide clarity and robustness to the test.

Also applies to: 20-20, 24-24, 28-28, 32-32, 36-36, 40-40


Line range hint 107-107: Avoid using cy.wait.

Using cy.wait with arbitrary timeouts can lead to flaky tests. Consider using more reliable commands like cy.intercept to wait for specific network requests or cy.get with appropriate assertions.


Line range hint 107-107: Use data- attributes for selectors.*

Avoid using class selectors like .t--inlined-cell-editor-has-error. Instead, use data-* attributes for more reliable and maintainable selectors.

Also applies to: 111-111, 115-115


Line range hint 125-125: Avoid using cy.wait.

Using cy.wait with arbitrary timeouts can lead to flaky tests. Consider using more reliable commands like cy.intercept to wait for specific network requests or cy.get with appropriate assertions.


Line range hint 125-125: Use data- attributes for selectors.*

Avoid using class selectors like .t--inlined-cell-editor-has-error. Instead, use data-* attributes for more reliable and maintainable selectors.

Also applies to: 129-129


Line range hint 139-139: Avoid using cy.wait.

Using cy.wait with arbitrary timeouts can lead to flaky tests. Consider using more reliable commands like cy.intercept to wait for specific network requests or cy.get with appropriate assertions.

Also applies to: 143-143


Line range hint 139-139: Use data- attributes for selectors.*

Avoid using class selectors like .t--inlined-cell-editor-has-error. Instead, use data-* attributes for more reliable and maintainable selectors.

Also applies to: 143-143, 147-147

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d65ab07 and 922764b.

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

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 (3)
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/Date_column_editing_1_spec.ts (3)

Line range hint 18-33:
Avoid using agHelper.Sleep() in tests.

Using agHelper.Sleep(1000) is not recommended as it can lead to flaky tests. Instead, use Cypress commands like cy.wait() with network requests or cy.get() with assertions to wait for specific conditions.

- agHelper.Sleep(1000);
+ // Consider using a more reliable wait strategy here

Line range hint 118-135:
Avoid using agHelper.Sleep() in tests.

Using agHelper.Sleep(2000) is not recommended as it can lead to flaky tests. Instead, use Cypress commands like cy.wait() with network requests or cy.get() with assertions to wait for specific conditions.

- agHelper.Sleep(2000);
+ // Consider using a more reliable wait strategy here

Line range hint 137-164:
Avoid using agHelper.Sleep() in tests.

Using agHelper.Sleep(2000) is not recommended as it can lead to flaky tests. Instead, use Cypress commands like cy.wait() with network requests or cy.get() with assertions to wait for specific conditions.

- agHelper.Sleep(2000);
+ // Consider using a more reliable wait strategy here
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 922764b and b0ffa03.

Files selected for processing (1)
  • app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/Date_column_editing_1_spec.ts (1 hunks)
Additional context used
Path-based instructions (1)
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/Date_column_editing_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 (4)
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/Date_column_editing_1_spec.ts (4)

Line range hint 35-81:
Great use of multiple assertions!

The test case effectively checks the date editing functionality with multiple assertions, ensuring comprehensive coverage.


Line range hint 83-99:
Well-structured test case!

The test case correctly verifies the functionality of changing the date display format with appropriate assertions.


Line range hint 101-116:
Good job on verifying the date picker's first day of the week!

The test case effectively checks the change in the date picker's starting day with clear assertions.


Line range hint 166-205:
Comprehensive test for date cell behavior!

The test case effectively checks the behavior of date cells when adding a new row, with a focus on CSS changes. The assertions are well-implemented.

@jacquesikot
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

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

Copy link

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

sagar-qa007
sagar-qa007 previously approved these changes Aug 13, 2024
rahulbarwal
rahulbarwal previously approved these changes Aug 15, 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.

Only remaining thing: a feature flag. Otherwise its good.

@jacquesikot jacquesikot dismissed stale reviews from rahulbarwal and sagar-qa007 via 874a636 August 15, 2024 09:07
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 b0ffa03 and 874a636.

Files selected for processing (1)
  • app/client/src/widgets/TableWidgetV2/component/cellComponents/DateCell.tsx (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/client/src/widgets/TableWidgetV2/component/cellComponents/DateCell.tsx

rahulbarwal
rahulbarwal previously approved these changes Aug 16, 2024
@jacquesikot
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

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

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 874a636 and 40fe2ea.

Files selected for processing (1)
  • app/client/src/widgets/TableWidgetV2/widget/index.tsx (1 hunks)
Additional comments not posted (1)
app/client/src/widgets/TableWidgetV2/widget/index.tsx (1)

2657-2679: Great job on the onDateSave method!

The method correctly handles the update of transient table data and the execution of onSubmit actions. The use of batch updates ensures efficient state management.

Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Help enterprise Requested by Appsmith customers or prospects High This issue blocks a user from building or impacts a lot of users Needs Triaging Needs attention from maintainers to triage ok-to-test Required label for CI Production Table Inline Edit Issues related to inline editing Table Widget V2 Issues related to Table Widget V2 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]: Date column set as required does not making it mandatory for adding new Table row
3 participants