Skip to content

chore: Add snaps for Table Widget#34676

Closed
jsartisan wants to merge 1 commit intoreleasefrom
chore/table-widget-tests
Closed

chore: Add snaps for Table Widget#34676
jsartisan wants to merge 1 commit intoreleasefrom
chore/table-widget-tests

Conversation

@jsartisan
Copy link
Contributor

@jsartisan jsartisan commented Jul 3, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a disableScroll property to the table widget, allowing users to disable scrolling for tables.
  • Bug Fixes

    • Adjusted table column width calculations to account for border width, ensuring consistent table layouts.
  • Tests

    • Added test cases for the Anvil Table Widget in various modes (Canvas, Preview, Deploy) to ensure consistent behavior.
  • Style

    • Updated table widget styling to support the new disableScroll property and adjusted border styling for table rows.

@jsartisan jsartisan requested a review from ApekshaBhosale as a code owner July 3, 2024 11:28
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 3, 2024

Walkthrough

The changes focus on enhancing the functionality and behavior of the WDSTableWidget component. A key addition is the disableScroll property which allows the table to conditionally disable scrolling. This feature is integrated across multiple files, modifying interfaces, component logic, styling, and rendering utilities. Additionally, new test cases have been introduced to verify the behavior of the Anvil Table Widget in different modes such as Canvas, Preview, and Deploy.

Changes

Files Change Summary
app/client/cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilTableWidgetSnapshot_spec.ts Introduces test cases for verifying the behavior of the Anvil Table Widget in Canvas, Preview, and Deploy modes.
app/client/src/widgets/wds/WDSTableWidget/component/Table.tsx Adds a disableScroll property to the TableProps interface and implements its usage to conditionally set a data-disable-scroll attribute.
app/client/src/widgets/wds/WDSTableWidget/component/index.tsx Adds a disableScroll property to the ReactTableComponentProps interface and updates the ReactTableComponent function. Adjusts memoization logic to consider the disableScroll property.
app/client/src/widgets/wds/WDSTableWidget/component/styles.module.css Adds styling for disabling scroll with [data-disable-scroll] { overflow: hidden; } and adjusts styling for cell borders in rows.
app/client/src/widgets/wds/WDSTableWidget/widget/index.tsx Updates the WDSTableWidget class to include a condition for disableScroll based on renderMode and isPreviewMode properties.
app/client/src/widgets/wds/WDSTableWidget/widget/reactTableUtils/getColumnsPureFn.tsx Introduces a BORDER_WIDTH constant and adjusts the column width calculations to account for the border width.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant WDSTableWidget
    participant renderMode
    participant UI

    User->>WDSTableWidget: Open Table
    WDSTableWidget->>renderMode: Determine Mode (Canvas / Preview / Deploy)
    renderMode-->>WDSTableWidget: Mode
    WDSTableWidget->>UI: Update Table Component
    Note right of UI: Check disableScroll property
    UI-->>User: Render Table with/without Scroll
Loading

Poem

In the code, a table stands tall,
With rows and columns, big and small.
A new feature to disable the scroll,
Ensuring control, proud and whole.
Tests now check every mode’s role,
Making sure it’s under control.
Hoppy code, neat and droll. 🐇

Tip

AI model upgrade

gpt-4o model for reviews and chat is now live

OpenAI claims that this model is better at understanding and generating code than the previous models. Please join our Discord Community to provide any feedback or to report any issues.


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 Configration 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 skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Jul 3, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5d879ec and 0c06ee8.

Files ignored due to path filters (6)
  • app/client/cypress/snapshots/AnvilTableWidgetSnapshot_spec.ts/anvilTableWidgetCanvas.snap.png is excluded by !**/*.png
  • app/client/cypress/snapshots/AnvilTableWidgetSnapshot_spec.ts/anvilTableWidgetCanvasDark.snap.png is excluded by !**/*.png
  • app/client/cypress/snapshots/AnvilTableWidgetSnapshot_spec.ts/anvilTableWidgetDeployipad-2.snap.png is excluded by !**/*.png
  • app/client/cypress/snapshots/AnvilTableWidgetSnapshot_spec.ts/anvilTableWidgetDeployiphone-6.snap.png is excluded by !**/*.png
  • app/client/cypress/snapshots/AnvilTableWidgetSnapshot_spec.ts/anvilTableWidgetDeploymacbook-13.snap.png is excluded by !**/*.png
  • app/client/cypress/snapshots/AnvilTableWidgetSnapshot_spec.ts/anvilTableWidgetPreview.snap.png is excluded by !**/*.png
Files selected for processing (6)
  • app/client/cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilTableWidgetSnapshot_spec.ts (1 hunks)
  • app/client/src/widgets/wds/WDSTableWidget/component/Table.tsx (2 hunks)
  • app/client/src/widgets/wds/WDSTableWidget/component/index.tsx (4 hunks)
  • app/client/src/widgets/wds/WDSTableWidget/component/styles.module.css (2 hunks)
  • app/client/src/widgets/wds/WDSTableWidget/widget/index.tsx (1 hunks)
  • app/client/src/widgets/wds/WDSTableWidget/widget/reactTableUtils/getColumnsPureFn.tsx (2 hunks)
Files skipped from review due to trivial changes (1)
  • app/client/src/widgets/wds/WDSTableWidget/widget/reactTableUtils/getColumnsPureFn.tsx
Additional context used
Path-based instructions (5)
app/client/cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilTableWidgetSnapshot_spec.ts (1)

Pattern **/*.*: Do not use cy.wait in code.
Do call the add function.
Do not keep duplicate lines in code.
Descriptive test names are used to clearly convey the intent of each test.

app/client/src/widgets/wds/WDSTableWidget/component/styles.module.css (1)

Pattern **/*.*: Do not use cy.wait in code.
Do call the add function.
Do not keep duplicate lines in code.
Descriptive test names are used to clearly convey the intent of each test.

app/client/src/widgets/wds/WDSTableWidget/component/index.tsx (1)

Pattern **/*.*: Do not use cy.wait in code.
Do call the add function.
Do not keep duplicate lines in code.
Descriptive test names are used to clearly convey the intent of each test.

app/client/src/widgets/wds/WDSTableWidget/component/Table.tsx (1)

Pattern **/*.*: Do not use cy.wait in code.
Do call the add function.
Do not keep duplicate lines in code.
Descriptive test names are used to clearly convey the intent of each test.

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

Pattern **/*.*: Do not use cy.wait in code.
Do call the add function.
Do not keep duplicate lines in code.
Descriptive test names are used to clearly convey the intent of each test.

Biome
app/client/src/widgets/wds/WDSTableWidget/widget/index.tsx

[error] 930-930: 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)

Additional comments not posted (9)
app/client/cypress/e2e/Regression/ClientSide/Anvil/Widgets/AnvilTableWidgetSnapshot_spec.ts (1)

1-27: LGTM! The test structure is clear and well-organized.

The tests cover different modes of the Anvil Table Widget effectively.

app/client/src/widgets/wds/WDSTableWidget/component/styles.module.css (2)

37-39: LGTM! The [data-disable-scroll] block is correctly implemented.

It effectively disables scrolling when the attribute is set.


170-172: LGTM! The styling for the last cell in the row is handled correctly.

Setting border-block-end-color to transparent is a good design choice.

app/client/src/widgets/wds/WDSTableWidget/component/index.tsx (2)

85-85: LGTM! The disableScroll property is correctly added to the ReactTableComponentProps interface.

This addition is necessary for controlling the scroll behavior.


102-102: LGTM! The disableScroll property is correctly utilized in the ReactTableComponent function.

Passing this property to the Table component ensures the intended behavior.

Also applies to: 214-214

app/client/src/widgets/wds/WDSTableWidget/component/Table.tsx (2)

101-101: LGTM! The disableScroll property is correctly added to the TableProps interface.

This addition is necessary for controlling the scroll behavior.


298-298: LGTM! The disableScroll property is correctly utilized in the Table component.

Applying this property as a data attribute ensures the intended behavior.

app/client/src/widgets/wds/WDSTableWidget/widget/index.tsx (2)

929-931: LGTM! The disableScroll property is correctly utilized in the ReactTableComponent.

Passing this property ensures the intended behavior.

Tools
Biome

[error] 930-930: 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)


Line range hint 319-319: LGTM! The disableScroll property is correctly included in the comparison for React.memo.

Ensuring the component re-renders if this property changes is important for correct functionality.

Tools
Biome

[error] 930-930: 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)

Comment on lines +928 to +931
disableScroll={
this.props.renderMode === RenderModes.CANVAS &&
!Boolean(this.props.isPreviewMode)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix redundant Boolean call.

The Boolean call is redundant since the value is already coerced to a boolean.

-            !Boolean(this.props.isPreviewMode)
+            !this.props.isPreviewMode
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
disableScroll={
this.props.renderMode === RenderModes.CANVAS &&
!Boolean(this.props.isPreviewMode)
}
disableScroll={
this.props.renderMode === RenderModes.CANVAS &&
!this.props.isPreviewMode
}
Tools
Biome

[error] 930-930: 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)

@jsartisan jsartisan requested a review from KelvinOm July 5, 2024 06:45
@KelvinOm KelvinOm mentioned this pull request Jul 8, 2024
2 tasks
KelvinOm added a commit that referenced this pull request Jul 9, 2024
## Description
1. Add scripts for local e2e testing in the docker container. 
2. Add types for cypress-image-snapshot

In this PR, I also added the following PRS as they affect screenshot
tests as well. I did this to speed up the process and unblock the team.

#34528
#34546
#34676
#34729
#34638
#34639
#34511

To run E2E tests locally in docker, you need to do the following:
1. Run FE locally and prepare the tests for local launch. See the
instructions
[here](https://github.com/appsmithorg/appsmith/blob/release/contributions/ClientSetup.md).
2. Run `yarn cypress:snapshot:docker:build` — this will create a docker
container with the necessary environment.
3. Run `yarn cypress:snapshot:docker
"./cypress/e2e/Regression/ClientSide/Anvil/Widgets/*_spec.ts"
updateSnapshots=false`. Here we can use the path to a specific file, or
set `updateSnapshots=true` flag to update the screenshots.

## Automation

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

### :mag: Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/9844579277>
> Commit: 75f2659
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9844579277&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Anvil`
> Spec:
> <hr>Mon, 08 Jul 2024 18:37:36 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added support for image snapshot testing with the
`@types/cypress-image-snapshot` dependency.

- **Refactor**
- Updated test specifications by removing unnecessary
`triggerInputInvalidState()` calls.
- Reorganized and improved efficiency of image snapshot methods for
various devices.

- **Chores**
- Updated `Dockerfile` to configure the Cypress environment with
specific versions for dependencies.
  - Changed import paths in `e2e.js` for better module resolution. 

- **Style**
  - Fixed a comment typo in Cypress plugin configuration.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Pawan Kumar <pawankumar@Pawans-MacBook-Pro-2.local>
Co-authored-by: unknown <vadim@appsmith.com>
@KelvinOm
Copy link
Collaborator

KelvinOm commented Jul 9, 2024

Merged here.

@KelvinOm KelvinOm closed this Jul 9, 2024
Shivam-z pushed a commit to Shivam-z/appsmith that referenced this pull request Jul 10, 2024
## Description
1. Add scripts for local e2e testing in the docker container. 
2. Add types for cypress-image-snapshot

In this PR, I also added the following PRS as they affect screenshot
tests as well. I did this to speed up the process and unblock the team.

appsmithorg#34528
appsmithorg#34546
appsmithorg#34676
appsmithorg#34729
appsmithorg#34638
appsmithorg#34639
appsmithorg#34511

To run E2E tests locally in docker, you need to do the following:
1. Run FE locally and prepare the tests for local launch. See the
instructions
[here](https://github.com/appsmithorg/appsmith/blob/release/contributions/ClientSetup.md).
2. Run `yarn cypress:snapshot:docker:build` — this will create a docker
container with the necessary environment.
3. Run `yarn cypress:snapshot:docker
"./cypress/e2e/Regression/ClientSide/Anvil/Widgets/*_spec.ts"
updateSnapshots=false`. Here we can use the path to a specific file, or
set `updateSnapshots=true` flag to update the screenshots.

## Automation

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

### :mag: Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/9844579277>
> Commit: 75f2659
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9844579277&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Anvil`
> Spec:
> <hr>Mon, 08 Jul 2024 18:37:36 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added support for image snapshot testing with the
`@types/cypress-image-snapshot` dependency.

- **Refactor**
- Updated test specifications by removing unnecessary
`triggerInputInvalidState()` calls.
- Reorganized and improved efficiency of image snapshot methods for
various devices.

- **Chores**
- Updated `Dockerfile` to configure the Cypress environment with
specific versions for dependencies.
  - Changed import paths in `e2e.js` for better module resolution. 

- **Style**
  - Fixed a comment typo in Cypress plugin configuration.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Pawan Kumar <pawankumar@Pawans-MacBook-Pro-2.local>
Co-authored-by: unknown <vadim@appsmith.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Adding this label to a PR prevents it from being listed in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants