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

test: hard code date values in Date_column_types_validation_spec #36759

Merged
merged 3 commits into from
Oct 10, 2024

Conversation

jacquesikot
Copy link
Contributor

@jacquesikot jacquesikot commented Oct 8, 2024

Description

Problem
In the test spec, date data is fed directly from a file (app/client/cypress/fixtures/tableDateColumnTypes.ts), which includes specific, static dates. However, the test is designed to handle relative dates (e.g., "today" and "tomorrow"). As a result, when the date picker opens, it displays a fixed date (e.g., September 2024), while the test is attempting to select a date like October 8 (tomorrow’s date), which is out of view.

EE PR - https://github.com/appsmithorg/appsmith-ee/pull/5312

Fixes #36756

Automation

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

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11270917513
Commit: 9ac8789
Cypress dashboard.
Tags: @tag.Table
Spec:


Thu, 10 Oct 2024 09:53:10 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced clarity and specificity in end-to-end tests for date column validation in the table widget.
    • Updated assertions to directly compare against a specific hardcoded date.
  • Refactor

    • Removed the getFormattedTomorrowDates method from the Table class, streamlining date formatting functionality.

Copy link
Contributor

coderabbitai bot commented Oct 8, 2024

Walkthrough

The changes in this pull request focus on enhancing the Cypress end-to-end test suite for validating date column types in a table widget. Key modifications include clarifying comments and updating assertions in the clickAndValidateDateCell function. Additionally, a public method, getFormattedTomorrowDates, has been removed from the Table class, indicating a shift in how date formatting is handled within the application.

Changes

File Path Change Summary
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/Date_column_types_validation_spec.ts Updated comments and assertions in the date validation test, specifying the date picker context.
app/client/cypress/support/Pages/Table.ts Removed the getFormattedTomorrowDates method from the Table class.

Assessment against linked issues

Objective Addressed Explanation
Fix flaky test due to date picker context (#36756)

Possibly related PRs

Suggested labels

Bug, Task, ok-to-test, Test, Widgets & Accelerators Pod, Tech Debt

Suggested reviewers

  • ApekshaBhosale
  • sagar-qa007
  • rahulbarwal

🎉 In the realm of code, where tests do play,
We've sharpened our tools, come what may!
With dates now precise, and comments so clear,
Our widgets will dance, spreading joy and cheer!
So let’s click and validate, in harmony we strive,
For a smoother tomorrow, our tests come alive! 🎊


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@jacquesikot jacquesikot added the ok-to-test Required label for CI label Oct 8, 2024
@github-actions github-actions bot added the Bug Something isn't working label Oct 8, 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: 2

🧹 Outside diff range and nitpick comments (3)
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/Date_column_types_validation_spec.ts (3)

46-47: Good job on improving the comment clarity, class!

The updated comment provides a better explanation of why the date picker opens in September 2024. This aligns with our objective of addressing the issue with static date values.

However, let's make it even better! Can you add a note about how this relates to the problem described in the PR objectives? For example:
"This fixed date is part of the issue we're addressing, as it doesn't allow for testing relative dates like 'today' and 'tomorrow'."


Line range hint 1-180: Class, let's have a discussion about our overall test structure.

You've done a commendable job organizing the tests for various date formats. The structure is logical and easy to follow. Gold star for that!

However, we need to address an important issue. Throughout our tests, we're still using hardcoded dates. This doesn't align with our goal of handling relative dates like 'today' and 'tomorrow'.

Here's your homework assignment:

  1. Refactor the setEditableDateFormats function to handle relative dates.
  2. Update all test cases to use relative dates instead of fixed ones.
  3. Consider creating helper functions for getting 'today' and 'tomorrow' dates in various formats.

Remember, our goal is to make these tests robust and able to run correctly regardless of the current date. Let's work together to improve this!


Attention Needed: Remove Hardcoded Date in Line 55

Great effort in identifying and addressing most hardcoded dates. However, there's still a hardcoded date "2024-09-26" present in line 55. Please replace this with a dynamic relative date to ensure the tests remain reliable and maintainable.

🔗 Analysis chain

Line range hint 1-180: Class, let's summarize our lesson for today.

We've made some progress in addressing the issue with fixed dates, but we still have work to do. Here are the key points to remember:

  1. The comment changes have improved clarity, but we need to relate them more directly to our objectives.
  2. We're still using hardcoded dates in our selectors and assertions, which doesn't solve our core problem.
  3. The overall test structure is good, but needs to be refactored to handle relative dates.

Your assignment is to revise this code to fully address the issue of handling relative dates. Remember, in software development, we often need to iterate on our solutions to get them just right. Keep up the good work, and don't hesitate to ask questions if you need help!

To ensure we've addressed all instances of hardcoded dates, let's run a quick check:

This will help us identify any remaining hardcoded dates that we need to replace with relative date logic.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for hardcoded date patterns in the file
echo "Checking for hardcoded dates:"
rg -n '\d{4}-\d{2}-\d{2}' app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/Date_column_types_validation_spec.ts

Length of output: 257

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 8463d02 and 347f3ac.

📒 Files selected for processing (2)
  • app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/Date_column_types_validation_spec.ts (1 hunks)
  • app/client/cypress/support/Pages/Table.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • app/client/cypress/support/Pages/Table.ts
🧰 Additional context used
📓 Path-based instructions (1)
app/client/cypress/e2e/Regression/ClientSide/Widgets/TableV2/Date_column_types_validation_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.

agHelper.GetNClick(
`${table._dateInputPopover} [aria-label='${table.getFormattedTomorrowDates().verboseFormat}']`,
`${table._dateInputPopover} [aria-label='Thu Sep 26 2024']`,
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

Attention, students! We need to improve our selector usage.

While the change addresses the issue with the fixed date, it doesn't fully solve our problem. We're still using a hardcoded date, which goes against our goal of handling relative dates.

Let's think about how we can make this more dynamic. Can you come up with a way to select the date based on 'today' or 'tomorrow' instead of a fixed date? Remember, we want to avoid hardcoding specific dates in our tests.

.then((val) =>
expect(val).to.equal(table.getFormattedTomorrowDates().isoFormat),
);
.then((val) => expect(val).to.equal("2024-09-26"));
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

Class, let's discuss this assertion change.

The assertion now uses a hardcoded date value "2024-09-26" instead of a dynamic method. While this matches the clicked date, it doesn't align with our goal of working with relative dates.

Let's think about how we can make this assertion more flexible. Could we use a variable that represents 'tomorrow' or 'today + 1 day' instead of a fixed date? This would make our test more robust and less likely to fail due to date changes.

.then((val) =>
expect(val).to.equal(table.getFormattedTomorrowDates().isoFormat),
);
.then((val) => expect(val).to.equal("2024-09-26"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we think this is also hard coded?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is a hardcoded date value, i.e when the fixed date from the Table data is used, this hardcoded date here is always visible in the date picker viewport and will be selected.

@jacquesikot
Copy link
Contributor Author

/ci-test-limit

Copy link

github-actions bot commented Oct 9, 2024

@jacquesikot
Copy link
Contributor Author

/ci-test-limit-count run_count=15 runId=11250901833

Copy link

github-actions bot commented Oct 9, 2024

Copy link

github-actions bot commented Oct 9, 2024

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11250901833.
Cypress dashboard url: Click here!
All cypress tests have passed 🎉🎉🎉

@rahulbarwal rahulbarwal added the Table Widget V2 Issues related to Table Widget V2 label Oct 9, 2024
@rahulbarwal rahulbarwal changed the title fix: hard code date values in Date_column_types_validation_spec test: hard code date values in Date_column_types_validation_spec Oct 9, 2024
@github-actions github-actions bot added Task A simple Todo Widgets Product This label groups issues related to widgets skip-changelog Adding this label to a PR prevents it from being listed in the changelog Test and removed Bug Something isn't working labels Oct 9, 2024
@jacquesikot jacquesikot added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Oct 9, 2024
@github-actions github-actions bot added the Widgets & Accelerators Pod Issues related to widgets & Accelerators label Oct 9, 2024
@jacquesikot jacquesikot removed the ok-to-test Required label for CI label Oct 9, 2024
@jacquesikot jacquesikot added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Oct 9, 2024
@rahulbarwal rahulbarwal added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Oct 10, 2024
@jacquesikot jacquesikot added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Oct 10, 2024
@jacquesikot
Copy link
Contributor Author

/ci-test-limit

Copy link

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11270455557.
Cypress dashboard url: Click here!
All cypress tests have passed 🎉🎉🎉

@jacquesikot jacquesikot merged commit 9041c48 into release Oct 10, 2024
42 checks passed
@jacquesikot jacquesikot deleted the fix/date_column_types_validation_spec branch October 10, 2024 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog Table Widget V2 Issues related to Table Widget V2 Task A simple Todo Test 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.

[Fix]: Flaky Date_column_types_validation_spec
3 participants