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

chore: fix form widgets bugs #38492

Merged
merged 7 commits into from
Jan 7, 2025
Merged

chore: fix form widgets bugs #38492

merged 7 commits into from
Jan 7, 2025

Conversation

jsartisan
Copy link
Contributor

@jsartisan jsartisan commented Jan 6, 2025

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

Fixes #38200
Fixes #38201
Fixes #38409
Fixes #38410

Summary by CodeRabbit

Based on the comprehensive summary, here are the updated release notes:

  • New Features

    • Enhanced calendar functionality with month and year dropdown selection.
    • Improved input and select component styling.
    • Added text wrapping and line clamping for field labels.
  • Bug Fixes

    • Refined input validation and error handling across multiple widgets.
    • Updated text property handling for various input widgets.
  • Documentation

    • Updated autocomplete configuration for input widgets.
  • Chores

    • Temporarily disabled several Cypress test suites for Anvil widgets.
    • Standardized text property naming across input-related components.
  • Style

    • Improved CSS styling for input groups, dropdowns, and calendar components.
    • Enhanced text rendering and whitespace handling.

These release notes capture the key changes across the design system and widget components, focusing on user-facing improvements and internal refinements.

Tip

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


Tue, 07 Jan 2025 11:41:09 UTC

Copy link
Contributor

coderabbitai bot commented Jan 6, 2025

Walkthrough

This pull request introduces comprehensive changes across multiple components in the design system and widget implementations. The primary focus is on standardizing text property handling, refactoring input and calendar components, and updating CSS styles. Key modifications include renaming parsedText to text across various widgets, enhancing input styling, and introducing new dropdown functionalities for calendar components.

Changes

File Path Change Summary
.../Input/src/styles.module.css Enhanced CSS for input groups and input styling
.../Calendar/* New month and year dropdown components, updated heading
.../ui-builder/ui/wds/*Widget/ Renamed parsedText to text across multiple widgets
.../cypress/e2e/Regression/ClientSide/Anvil/Widgets/* Skipped multiple widget snapshot tests

Sequence Diagram

sequenceDiagram
    participant User
    participant Calendar
    participant MonthDropdown
    participant YearDropdown

    User->>Calendar: Interact with Calendar
    Calendar->>MonthDropdown: Request Month Selection
    MonthDropdown-->>Calendar: Update Focused Month
    Calendar->>YearDropdown: Request Year Selection
    YearDropdown-->>Calendar: Update Focused Year
Loading

Possibly related PRs

Suggested Labels

Bug, WDS team, Anvil Pod

Suggested Reviewers

  • ApekshaBhosale
  • KelvinOm

Poem

🌈 Code transforms, like magic's art
Parsing text with a brand new start
Dropdowns dance, styles refine
Widgets sing in perfect line!
Refactoring's sweet embrace 🚀


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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 the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Jan 6, 2025
@jsartisan
Copy link
Contributor Author

/ci-test-limit-count run_count=1 update_snapshot=true specs_to_run=cypress/e2e/Regression/ClientSide/Anvil/Widgets/*

Copy link

github-actions bot commented Jan 6, 2025

@jsartisan jsartisan force-pushed the chore/fix-disabled-state branch from 46ea6b4 to 3d09e46 Compare January 6, 2025 08:46
@jsartisan
Copy link
Contributor Author

/ci-test-limit-count run_count=1 update_snapshot=true specs_to_run=cypress/e2e/Regression/ClientSide/Anvil/Widgets/*

Copy link

github-actions bot commented Jan 6, 2025

@jsartisan
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

github-actions bot commented Jan 6, 2025

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

Copy link

github-actions bot commented Jan 6, 2025

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

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

🧹 Nitpick comments (5)
app/client/packages/design-system/widgets/src/components/Calendar/src/CalendarHeading.tsx (1)

18-18: Context naming.
Consider renaming state to something that conveys its role within the Calendar context, such as calendarState, for improved clarity.

app/client/packages/design-system/widgets/src/components/Calendar/src/CalendarYearDropdown.tsx (2)

7-22: Year generation approach.
Generating a 41-year range centered on the current year is straightforward and valid. In some cases, you might consider exposing this range as a prop for greater flexibility.


31-46: Appropriate use of Select & ListBoxItem.
Using selectedKey={20} as the default selects the current year index in your array. Consider adding a comment explaining that index 20 represents focusedDate if you find teammates are confused about this logic.

app/client/packages/design-system/widgets/src/components/Calendar/src/CalendarMonthDropdown.tsx (1)

9-34: Filtering out invalid months.
Skipping months outside minValue or maxValue is a good approach. If many months are out of range, you may want to display a message or a disabled option instead, but that’s a design choice.

app/client/packages/design-system/widgets/src/components/Calendar/src/styles.module.css (1)

72-76: Effective grid layout.
Using a two-column grid with a gap is a straightforward and responsive design for managing two dropdowns. Consider adding responsive breakpoints if you anticipate narrow screens.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3d09e46 and dee3bf0.

📒 Files selected for processing (19)
  • app/client/packages/design-system/widgets/src/components/Calendar/src/CalendarHeading.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Calendar/src/CalendarMonthDropdown.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Calendar/src/CalendarYearDropdown.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Calendar/src/styles.module.css (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Datepicker/src/Datepicker.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Input/src/Input.tsx (3 hunks)
  • app/client/packages/design-system/widgets/src/components/Input/src/styles.module.css (5 hunks)
  • app/client/packages/design-system/widgets/src/components/Select/src/SelectTrigger.tsx (3 hunks)
  • app/client/packages/design-system/widgets/src/components/Text/src/Text.tsx (1 hunks)
  • app/client/src/modules/ui-builder/ui/wds/WDSBaseInputWidget/widget/index.tsx (1 hunks)
  • app/client/src/modules/ui-builder/ui/wds/WDSCurrencyInputWidget/config/autocompleteConfig.ts (1 hunks)
  • app/client/src/modules/ui-builder/ui/wds/WDSCurrencyInputWidget/widget/index.tsx (8 hunks)
  • app/client/src/modules/ui-builder/ui/wds/WDSInputWidget/config/autocompleteConfig.ts (1 hunks)
  • app/client/src/modules/ui-builder/ui/wds/WDSInputWidget/config/settersConfig.ts (1 hunks)
  • app/client/src/modules/ui-builder/ui/wds/WDSInputWidget/widget/helper.ts (2 hunks)
  • app/client/src/modules/ui-builder/ui/wds/WDSInputWidget/widget/index.tsx (4 hunks)
  • app/client/src/modules/ui-builder/ui/wds/WDSPhoneInputWidget/config/autocompleteConfig.ts (1 hunks)
  • app/client/src/modules/ui-builder/ui/wds/WDSPhoneInputWidget/widget/helpers.ts (1 hunks)
  • app/client/src/modules/ui-builder/ui/wds/WDSPhoneInputWidget/widget/index.tsx (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/packages/design-system/widgets/src/components/Input/src/styles.module.css
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-build / client-build
  • GitHub Check: chromatic-deployment
  • GitHub Check: chromatic-deployment
  • GitHub Check: storybook-tests
🔇 Additional comments (54)
app/client/packages/design-system/widgets/src/components/Select/src/SelectTrigger.tsx (2)

5-5: Looks good!

Importing Button and SelectValue from react-aria-components is an elegant approach and aligns with modern UI patterns. No issues found.


Line range hint 22-45: Check accessibility impact of replacing Group with div.

Although replacing Group with a plain div is structurally simple, ensure that the Button retains all the necessary ARIA attributes. You might consider adding relevant role or aria-* attributes on the container to preserve any previously provided accessibility benefits from Group.

🧰 Tools
🪛 Biome (1.9.4)

[error] 25-25: Avoid redundant Boolean call

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call

(lint/complexity/noExtraBooleanCast)

app/client/packages/design-system/widgets/src/components/Text/src/Text.tsx (1)

48-48: Consider verifying cross-browser and layout impact for "pre-wrap" use.
This change preserves whitespace and line breaks. It may also result in unexpected large expansions.

✅ Verification successful

white-space: pre-wrap usage is safe and well-tested
The Text component has comprehensive test coverage including visual regression tests, and the style can be overridden if needed.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check all occurrences of "whiteSpace: pre-wrap" and ensure no conflicts with other styling.
rg -A 3 $'whiteSpace: "pre-wrap"'

Length of output: 409


Script:

#!/bin/bash
# Check for Text component tests and stories
fd "Text" --type f --exec rg -l "Text" {} \;

# Look for component usage
rg -A 2 "import.*Text.*from.*design-system"

Length of output: 8052

app/client/packages/design-system/widgets/src/components/Input/src/Input.tsx (2)

6-6: Import usage confirmed.

The import from "react-aria-components" seems properly declared, making the HeadlessInput available for use.


Line range hint 52-77: Consider accessibility implications when replacing the Group component with a regular <div>.

The Group component from react-aria-components may provide built-in accessibility attributes or roles. Replacing it with a plain <div> could remove some of these benefits. If maintaining or improving accessibility is a priority, double-check that any needed ARIA roles, labels, or attributes are still in place or otherwise replicated.

app/client/src/modules/ui-builder/ui/wds/WDSInputWidget/config/settersConfig.ts (1)

22-22: Looks good!
Renaming the accessor to "text" matches the naming convention used elsewhere. No issues found.

app/client/src/modules/ui-builder/ui/wds/WDSInputWidget/config/autocompleteConfig.ts (1)

7-14: Nice rename and addition!
The introduction of text and rawText is consistent with the rest of the codebase. Documentation is clear.

app/client/src/modules/ui-builder/ui/wds/WDSCurrencyInputWidget/config/autocompleteConfig.ts (1)

7-14: Renaming to text and refining docs
The updated property name and doc for rawText are aligned with the currency input's purpose. Great work.

app/client/src/modules/ui-builder/ui/wds/WDSPhoneInputWidget/config/autocompleteConfig.ts (1)

7-7: Consistent renaming and documentation
Switching parsedText to text preserves clarity. No concerns here.

app/client/src/modules/ui-builder/ui/wds/WDSBaseInputWidget/widget/index.tsx (1)

59-59: Renamed property aligns with standard usage.
Good move changing parsedText to text.

app/client/src/modules/ui-builder/ui/wds/WDSInputWidget/widget/helper.ts (6)

73-73: Introducing text property is consistent.
Replacing parsedText with text matches the overall rename.


76-76: Required field check looks correct.
Ensures a non-empty text when isRequired.


84-84: Appropriate use of text length limit.
Makes sense to validate maxChars against text.


100-100: Retaining existing logic while renaming.
Correctly references text in the numeric check.


102-102: Conditional check for minimum value is valid.
Uses text for value comparison.


109-109: Conditional check for maximum value is valid.
Keeps the numeric constraint logic intact with text.

app/client/src/modules/ui-builder/ui/wds/WDSInputWidget/widget/index.tsx (7)

65-65: Meta property rename is consistent.
Ensures the meta property returns text.


72-72: Default property mapping refined.
Updating text to map from defaultText preserves behavior.


160-160: Comparing rawText and text is straightforward.
Helps maintain data consistency between them.


163-163: Push update to text after parse is correct.
Retains existing logic for numeric or string values.


170-170: Properly updating text on inputType change.
Maintains accurate state for typed inputs.


193-193: Capturing text on user input.
Pushes updated text to meta, effectively syncing.


214-214: Reset logic preserves correct property usage.
Fully resets both rawText and text.

app/client/src/modules/ui-builder/ui/wds/WDSPhoneInputWidget/widget/index.tsx (11)

120-120: Consistently sets text in meta properties.
Aligns with the general rename to text.


129-129: Default property mapping for text is consistent.
Keeps phone widget behavior uniform.


163-163: Formatting and updating text.
Converts rawText to display-ready phone number.


179-179: Ensures text re-formats on formatting toggle.
Correctly updates meta property.


184-185: Synchronizing defaultText with phone field.
Refreshes rawText and applies formatting to text.


187-187: Retains consistent parsing logic.
Moves phone composition into the widget’s text property.


194-194: Completes text assignment after re-parsing.
Maintains an updated phone number.


215-215: Regenerates text on ISD code updates.
Properly refreshes phone format with new dial code.


223-223: Conditional logic for user-typed input.
Only formats if the user is actually entering characters.


233-233: OnTextChanged triggers remain functional.
Dynamically updates the phone input meta property.


301-301: Uses text for displayed phone number.
Gracefully leverages this.props.text instead of parsedText.

app/client/src/modules/ui-builder/ui/wds/WDSCurrencyInputWidget/widget/index.tsx (11)

133-133: Consistent renaming to text.
This meta property aligns well with the broader rename from parsedText.


142-142: Correct update to default text property.
The default property name change from parsedText to text maintains clarity.


156-158: Appropriate check for text instead of parsedText.
This ensures the widget references the updated property consistently.


195-195: Replacing parsedText with text in onValueChange.
Keeps consistency in how we handle the input value.


217-217: Deformatting uses the correct property.
Switching to const text = this.props.text is correct and consistent.


223-223: Updating text with the deformatted value.
Retains consistent usage of the text property.


232-235: Conditional format application remains intact.
Using this.props.text here matches the rename and ensures formatting logic flows correctly.


238-238: Ensuring text reflects the formatted value.
This final assignment to text is logically consistent.


252-252: Graceful fallback to this.props.text on errors.
Preserves user input when formatting or parsing fails.


297-297: isTextFormatted referencing text.
Approach is straightforward and aligns with the rename.


301-311: Consistent text parsing and formatting.
Renaming to this.props.text ensures uniform usage across the code.

app/client/src/modules/ui-builder/ui/wds/WDSPhoneInputWidget/widget/helpers.ts (1)

8-8: Correct reference to props.text.
Updates the validation function to rely on the new property name consistently.

app/client/packages/design-system/widgets/src/components/Calendar/src/CalendarHeading.tsx (2)

1-11: Imports look consistent and readable.
No issues found with these import statements; they neatly organize dependencies and align with React best practices.


21-24: Good use of dropdown composition.
Switching from a heading text display to a pair of Month/Year dropdowns is an elegant way to handle date selection. The usage of a dedicated container (styles.monthYearDropdown) further improves clarity.

app/client/packages/design-system/widgets/src/components/Calendar/src/CalendarYearDropdown.tsx (2)

1-6: Imports and initial setup.
All necessary libraries and types are imported cleanly. This is a good structure for a new component.


24-29: Change handler clarity.
The onChange function properly converts the key to a numeric index and sets the focused date accordingly. The flow is clear and easy to follow.

app/client/packages/design-system/widgets/src/components/Calendar/src/CalendarMonthDropdown.tsx (3)

1-8: Setup for month selection.
Imports appear consistent, and the usage of CSS modules keeps styling maintainable.


35-39: onChange logic.
Straightforward and aligns well with the handling in CalendarYearDropdown.


41-57: Use of defaultSelectedKey.
Selecting the current month by default is intuitive, increasing usability. The code is clear and easy to maintain.

app/client/packages/design-system/widgets/src/components/Datepicker/src/Datepicker.tsx (1)

105-105: FieldError placement.
Placing the error message below the popover improves visibility. Be sure to confirm that the popover doesn’t obscure the error in edge cases.

@jsartisan jsartisan changed the title chore: fix disabled input UI chore: fix form widgets bugs Jan 7, 2025
@jsartisan
Copy link
Contributor Author

/ci-test-limit-count run_count=1 update_snapshot=true

Copy link

github-actions bot commented Jan 7, 2025

@jsartisan
Copy link
Contributor Author

/ci-test-limit-count run_count=1 update_snapshot=true

Copy link

github-actions bot commented Jan 7, 2025

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

🧹 Nitpick comments (1)
app/client/packages/design-system/widgets/src/components/FieldLabel/src/FieldLabel.tsx (1)

25-30: Consider memoizing the title value for performance.

The accessibility improvement with title attribute is good. However, toString() is called on every render.

+ const titleText = React.useMemo(
+   () => children?.toString(),
+   [children]
+ );

  <Text
    fontWeight={600}
    lineClamp={1}
    size="caption"
-   title={children?.toString()}
+   title={titleText}
  >
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 79f2351 and 0bb967c.

📒 Files selected for processing (5)
  • app/client/cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilCurrencyInputWidgetSnapshot_spec.ts (1 hunks)
  • app/client/cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilInputWidgetSnapshot_spec.ts (1 hunks)
  • app/client/cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilPhoneInputWidgetSnapshot_spec.ts (1 hunks)
  • app/client/cypress/support/Pages/Anvil/AnvilSnapshot.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/FieldLabel/src/FieldLabel.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
app/client/cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilCurrencyInputWidgetSnapshot_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.
app/client/cypress/support/Pages/Anvil/AnvilSnapshot.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.
app/client/cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilInputWidgetSnapshot_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.
app/client/cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilPhoneInputWidgetSnapshot_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.
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: chromatic-deployment
  • GitHub Check: storybook-tests
  • GitHub Check: chromatic-deployment
🔇 Additional comments (4)
app/client/packages/design-system/widgets/src/components/FieldLabel/src/FieldLabel.tsx (1)

25-30: Good addition of text truncation with tooltip!

The combination of lineClamp with title attribute improves accessibility for truncated text.

app/client/cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilInputWidgetSnapshot_spec.ts (1)

8-8: Verify if issue #36419 is resolved before enabling tests

The test suite has been enabled but the TODO comment still references an unresolved issue. This might lead to unstable tests if the underlying issue persists.

✅ Verification successful

Tests can be safely enabled as issue #36419 is resolved

The referenced issue about snapshot testing infrastructure has been closed, confirming that the environment is now ready for snapshot tests.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the referenced issue is closed
gh issue view 36419 --json state,title,url

Length of output: 217

app/client/cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilPhoneInputWidgetSnapshot_spec.ts (1)

8-8: Same concern as AnvilInputWidgetSnapshot_spec.ts

app/client/cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilCurrencyInputWidgetSnapshot_spec.ts (1)

8-8: Same concern as AnvilInputWidgetSnapshot_spec.ts

Comment on lines +176 to +177
cy.get("input[required]").first().type("123");
cy.get("input[required]").first().clear();
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve selector specificity and accessibility

Two concerns with the current implementation:

  1. Using input[required] instead of input[aria-required=true] might affect accessibility
  2. Using .first() without specific identification could make tests fragile

Consider this improvement:

-    cy.get("input[required]").first().type("123");
-    cy.get("input[required]").first().clear();
+    cy.get("[data-testid='required-input']").type("123");
+    cy.get("[data-testid='required-input']").clear();

Also, ensure the input has both required and aria-required="true" attributes for better accessibility.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cy.get("input[required]").first().type("123");
cy.get("input[required]").first().clear();
cy.get("[data-testid='required-input']").type("123");
cy.get("[data-testid='required-input']").clear();

@jsartisan jsartisan added the ok-to-test Required label for CI label Jan 7, 2025
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

🧹 Nitpick comments (2)
app/client/packages/design-system/widgets/src/components/Calendar/utils/calendar.ts (1)

4-25: Extract YEAR_RANGE as a named constant

Move the magic number to a named constant at the module level for better maintainability.

+const YEAR_RANGE = 20;
+
 export function useYearOptions(state: CalendarState) {
   const formatter = useDateFormatter({
     year: "numeric",
     timeZone: state.timeZone,
   });

   const years: { value: CalendarState["focusedDate"]; formatted: string }[] = [];

-  const YEAR_RANGE = 20;
app/client/packages/design-system/widgets/src/components/Calendar/src/CalendarYearDropdown.tsx (1)

26-30: Add aria-label to ListBoxItem for better accessibility

Include descriptive aria-labels for screen readers.

       {years.map((year, i) => (
         <ListBoxItem
           id={i}
           key={i}
+          aria-label={`Year ${year.formatted}`}
           textValue={year.formatted}
         >
           {year.formatted}
         </ListBoxItem>
       ))}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 70f2b28 and c41781c.

📒 Files selected for processing (5)
  • app/client/cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilStatsWidgetSnapshot_spec.ts (1 hunks)
  • app/client/cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilSwitchWidgetSnapshot_spec.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Calendar/src/CalendarMonthDropdown.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Calendar/src/CalendarYearDropdown.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Calendar/utils/calendar.ts (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • app/client/cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilSwitchWidgetSnapshot_spec.ts
  • app/client/cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilStatsWidgetSnapshot_spec.ts
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: chromatic-deployment
  • GitHub Check: chromatic-deployment
  • GitHub Check: storybook-tests
🔇 Additional comments (2)
app/client/packages/design-system/widgets/src/components/Calendar/utils/calendar.ts (1)

27-52: LGTM! Well-structured month validation logic

The implementation correctly handles min/max date constraints and month formatting.

app/client/packages/design-system/widgets/src/components/Calendar/src/CalendarMonthDropdown.tsx (1)

10-40: LGTM! Well-implemented month dropdown

The component demonstrates good practices with proper typing, accessibility attributes, and state management.

aria-label="Year"
onSelectionChange={onChange}
placeholder="Select Year"
selectedKey={20}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Replace hardcoded selectedKey with dynamic value

The selectedKey should be calculated based on the current year's position in the years array.

-      selectedKey={20}
+      selectedKey={years.findIndex(
+        (year) => year.value.compare(state.focusedDate) === 0
+      )}

Committable suggestion skipped: line range outside the PR's diff.

@github-actions github-actions bot added Anvil Pod Issue related to Anvil project Task A simple Todo labels Jan 7, 2025
@jsartisan jsartisan merged commit a9a0d71 into release Jan 7, 2025
55 checks passed
@jsartisan jsartisan deleted the chore/fix-disabled-state branch January 7, 2025 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Anvil Pod Issue related to Anvil project ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog Task A simple Todo
Projects
None yet
2 participants