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: Fix for the test case #37936

Merged
merged 5 commits into from
Dec 6, 2024
Merged

fix: Fix for the test case #37936

merged 5 commits into from
Dec 6, 2024

Conversation

sagar-qa007
Copy link
Contributor

@sagar-qa007 sagar-qa007 commented Dec 4, 2024

Description

Fix flaky test case.

Fixes # https://app.zenhub.com/workspaces/stability-pod-6690c4814e31602e25cab7fd/issues/gh/appsmithorg/appsmith/37935

Automation

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

🔍 Cypress test results

Tip

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


Thu, 05 Dec 2024 06:59:43 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • Bug Fixes
    • Updated timeout duration for API calls in the bug test suite to improve test reliability.
    • Shifted focus of test specifications from a template-related test to a bug-related test.

These changes enhance the effectiveness of our testing process, ensuring more accurate results and quicker response times during tests.

Copy link
Contributor

coderabbitai bot commented Dec 4, 2024

Walkthrough

The changes involve modifications to a Cypress test suite and a test specification file. Specifically, the RunAPI method calls in DS_Bug26941_Spec.ts have been updated to increase the timeout duration from 20 to 2000. Additionally, the limited-tests.txt file has been updated to reference the DS_Bug26941_Spec.ts test case instead of a previous template test, indicating a shift in testing focus.

Changes

File Path Change Summary
app/client/cypress/e2e/Regression/ClientSide/BugTests/DS_Bug26941_Spec.ts Updated RunAPI method calls from 20 to 2000 (three instances) for timeout duration.
app/client/cypress/limited-tests.txt Changed test specification path from Fork_Template_spec.js to DS_Bug26941_Spec.ts.

Possibly related PRs

Suggested labels

Test

Suggested reviewers

  • ApekshaBhosale

🎉 In the land of code where tests do run,
A timeout was changed, now it's more fun!
From twenty to two thousand, the wait time's grown,
For bugs to be caught, in tests we have sown.
With paths now adjusted, our focus is clear,
Let's celebrate changes, for progress is near! 🎈


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 11de141 and 751789d.

📒 Files selected for processing (1)
  • app/client/cypress/e2e/Regression/ClientSide/BugTests/DS_Bug26941_Spec.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/cypress/e2e/Regression/ClientSide/BugTests/DS_Bug26941_Spec.ts

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

@github-actions github-actions bot added the Bug Something isn't working label Dec 4, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
app/client/cypress/e2e/Regression/ClientSide/BugTests/DS_Bug26941_Spec.ts (2)

Line range hint 17-24: Increasing timeouts is not the ideal solution for flaky tests

While increasing the timeout from 20 to 50 might temporarily fix the flaky test, it's generally considered an anti-pattern as it:

  1. Masks the underlying issue causing the flakiness
  2. Increases overall test execution time
  3. Could still fail intermittently if the root cause isn't addressed

Consider investigating:

  • Network conditions causing delayed responses
  • Race conditions in the API calls
  • State management issues between tests

Would you like assistance in implementing a more robust solution that doesn't rely on increased timeouts?

Also applies to: 27-39, 40-47


Line range hint 1-47: Test structure needs improvements to align with Cypress best practices

The test could benefit from several improvements to follow Cypress best practices:

  1. Consider using data-* attributes for selectors instead of class-based selectors
  2. The API calls could be intercepted using cy.intercept() for better control
  3. Consider breaking down the test into smaller, focused test cases

Here's a suggested refactor approach:

describe("API Header Validation", { tags: ["@tag.Datasource", "@tag.Git", "@tag.AccessControl"] }, () => {
  beforeEach(() => {
    cy.intercept('POST', '**/123').as('apiCall');
    const randomApi = `${dataManager.dsValues[dataManager.defaultEnviorment].mockApiUrl}123`;
    apiPage.CreateAndFillApi(randomApi);
  });

  it("should handle empty header key correctly", () => {
    apiPage.EnterHeader("", "");
    apiPage.RunAPI();
    cy.wait('@apiCall');
    agHelper.AssertElementAbsence(debuggerHelper.locators._debuggerDownStreamErrMsg);
  });

  it("should handle invalid header key correctly", () => {
    apiPage.EnterHeader(">", "");
    apiPage.RunAPI();
    cy.wait('@apiCall').then((interception) => {
      debuggerHelper.AssertDownStreamLogError(
        interception.response.body.data.pluginErrorDetails.downstreamErrorMessage
      );
    });
  });
});
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1078a03 and fa1bddb.

📒 Files selected for processing (2)
  • app/client/cypress/e2e/Regression/ClientSide/BugTests/DS_Bug26941_Spec.ts (3 hunks)
  • app/client/cypress/limited-tests.txt (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
app/client/cypress/limited-tests.txt (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/BugTests/DS_Bug26941_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 (2)
app/client/cypress/limited-tests.txt (1)

2-2: LGTM! Test specification path follows proper structure.

The path correctly points to the bug test case and follows the proper directory structure for Cypress tests.

Let's verify the existence of the referenced test file:

✅ Verification successful

Test file exists and follows proper test structure

The referenced test file exists at the correct location and contains proper Cypress test structure with describe/it blocks and appropriate tags.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the referenced test file
# and check its content for proper test structure

# Check if the file exists
fd "DS_Bug26941_Spec.ts" app/client/cypress/e2e/Regression/ClientSide/BugTests/

# If found, verify basic test structure
rg -A 5 "describe|it\(" app/client/cypress/e2e/Regression/ClientSide/BugTests/DS_Bug26941_Spec.ts

Length of output: 749

app/client/cypress/e2e/Regression/ClientSide/BugTests/DS_Bug26941_Spec.ts (1)

Line range hint 1-47: Verify usage of wait/sleep patterns in the codebase

Let's check for potential sources of test flakiness in the codebase.

@sagar-qa007
Copy link
Contributor Author

/ci-test-limit-count run_count=20

Copy link

github-actions bot commented Dec 4, 2024

@sagar-qa007 sagar-qa007 added the ok-to-test Required label for CI label Dec 4, 2024
@sagar-qa007
Copy link
Contributor Author

/ci-test-limit-count run_count=20 runId=12154768235

Copy link

github-actions bot commented Dec 4, 2024

Copy link

github-actions bot commented Dec 4, 2024

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

***** Repeat Run Summary ***** Total Tests with repeat: 20 Total Passed: 0 Total Failed: 20 Total Skipped: 0 *****************************

@sagar-qa007
Copy link
Contributor Author

/ci-test-limit-count run_count=5 runId=12154768235

Copy link

github-actions bot commented Dec 4, 2024

Copy link

github-actions bot commented Dec 4, 2024

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

***** Repeat Run Summary ***** Total Tests with repeat: 5 Total Passed: 0 Total Failed: 5 Total Skipped: 0 *****************************

@sagar-qa007
Copy link
Contributor Author

/ci-test-limit-count run_count=5 runId=12154768235

@sagar-qa007 sagar-qa007 removed the ok-to-test Required label for CI label Dec 4, 2024
Copy link

github-actions bot commented Dec 4, 2024

Copy link

github-actions bot commented Dec 4, 2024

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12158311193.
Cypress dashboard: Click here!
The following are new failures, please fix them before merging the PR:
To know the list of identified flaky tests - Refer here

***** Repeat Run Summary ***** Total Tests with repeat: 5 Total Passed: 5 Total Failed: 0 Total Skipped: 0 *****************************

@sagar-qa007
Copy link
Contributor Author

/ci-test-limit-count run_count=20 runId=12154768235

Copy link

github-actions bot commented Dec 4, 2024

Copy link

github-actions bot commented Dec 4, 2024

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12158925153.
Cypress dashboard: Click here!
The following are new failures, please fix them before merging the PR:
To know the list of identified flaky tests - Refer here

***** Repeat Run Summary ***** Total Tests with repeat: 20 Total Passed: 20 Total Failed: 0 Total Skipped: 0 *****************************

@sagar-qa007
Copy link
Contributor Author

/ci-test-limit-count run_count=20 runId=12154768235

Copy link

github-actions bot commented Dec 4, 2024

Copy link

github-actions bot commented Dec 4, 2024

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12160939710.
Cypress dashboard: Click here!
The following are new failures, please fix them before merging the PR:
To know the list of identified flaky tests - Refer here

***** Repeat Run Summary ***** Total Tests with repeat: 20 Total Passed: 20 Total Failed: 0 Total Skipped: 0 *****************************

Copy link
Contributor

Choose a reason for hiding this comment

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

Raising the wait will resulting in making the test flaky after few days.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This wait is not a hardcoded sleep; it is the timeout for the API call to respond. Typically, I observe successful responses within 1 second, but for better stability, I have set it to 2 seconds. If the response is received within 1 second, the test will pass without delay.

Maintaining this timeout avoids the need for adding retries, which could mask potential bugs. Introducing retries increases the risk of missing errors and reduces the accuracy of our tests.

@sagar-qa007 sagar-qa007 added the ok-to-test Required label for CI label Dec 5, 2024
@sagar-qa007 sagar-qa007 merged commit 6f42527 into release Dec 6, 2024
47 checks passed
@sagar-qa007 sagar-qa007 deleted the fix/dsbugspecfailure branch December 6, 2024 11:42
This was referenced Dec 6, 2024
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Dec 9, 2024
## Description
Fix flaky test case.

Fixes #
https://app.zenhub.com/workspaces/stability-pod-6690c4814e31602e25cab7fd/issues/gh/appsmithorg/appsmith/37935

## Automation

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

### 🔍 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/12174291982>
> Commit: d71af4c
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12174291982&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Datasource`
> Spec:
> <hr>Thu, 05 Dec 2024 06:59:43 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

- **Bug Fixes**
- Updated timeout duration for API calls in the bug test suite to
improve test reliability.
- Shifted focus of test specifications from a template-related test to a
bug-related test.

These changes enhance the effectiveness of our testing process, ensuring
more accurate results and quicker response times during tests.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@coderabbitai coderabbitai bot mentioned this pull request Dec 22, 2024
2 tasks
This was referenced Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working ok-to-test Required label for CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants