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: analysing flaky Switch Branch #39302

Open
wants to merge 7 commits into
base: release
Choose a base branch
from

Conversation

NandanAnantharamu
Copy link
Collaborator

@NandanAnantharamu NandanAnantharamu commented Feb 17, 2025

Summary by CodeRabbit

  • Tests
    • Refined the test suite to improve quality assurance.
    • Shifted the focus from editor-related tests to validating branch switching functionality.
    • Adjusted widget test coverage for more accurate testing outcomes.
    • Updated navigation method within the branch switching test for enhanced accuracy.
    • Modified element interaction to ensure reliable test execution.
    • Introduced a new locator for a spinner element to enhance test reliability.
    • Enhanced the click action in the ShowList method to ensure it functions regardless of element state.

Warning

Tests have not run on the HEAD c641ba7 yet


Thu, 20 Feb 2025 15:09:20 UTC

Copy link
Contributor

coderabbitai bot commented Feb 17, 2025

Walkthrough

This pull request updates the test specification file by replacing a reference to a JS editor indentation test with one for Git branch switching. Additionally, it adjusts the status of widget tests by commenting out one line and uncommenting its counterpart. These modifications refocus the limited test suite toward Git-related scenarios.

Changes

File(s) Change Summary
app/client/cypress/limited-tests.txt Replaced JSEditorIndent_spec.js with SwitchBranches_spec.js; adjusted widget tests by commenting out one line and uncommenting the related one.
app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/SwitchBranches_spec.js Updated method from SelectEntityByName to NavigateToPage for selecting an entity in the Git synchronization test.
app/client/cypress/support/Objects/CommonLocators.ts Added new property _spinnerHead to CommonLocators class for locating a spinner element.
app/client/cypress/support/Pages/PageList.ts Updated ShowList method to include { force: true } in the click action for robustness.

Possibly related PRs

  • test: adding test for page functionality #38538: The changes in the main PR, which involve updating test specifications in limited-tests.txt, are related to the modifications in the retrieved PR that also include changes to the same file, specifically commenting out and modifying test paths.
  • fix: updating migration repo for DSCrudAndBindings spec #36452: The changes in the main PR, which involve updating test specifications in limited-tests.txt, are related to the modifications in the retrieved PR that also updates test file paths in the same limited-tests.txt file.
  • test: GitSyncedApps_spec - multiple IA changes #33257: The changes in the main PR, which involve updating test specifications in limited-tests.txt, are related to the modifications in the retrieved PR that also update the PageList class, as both involve alterations to the handling of page interactions.

Suggested labels

Bug, ok-to-test

Suggested reviewers

  • ApekshaBhosale
  • sagar-qa007

Poem

In the files where tests reside,
A change unfolds with humble pride,
Old paths fade, new branches rise,
A dance of tests beneath our skies,
Code sings a tune of Git's embrace,
A playful shift in our test suite’s pace!


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3b54104 and c641ba7.

📒 Files selected for processing (1)
  • app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/SwitchBranches_spec.js (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/SwitchBranches_spec.js
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-build / client-build
  • GitHub Check: client-lint / client-lint

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.

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit-count run_count=50

@github-actions github-actions bot added skip-changelog Adding this label to a PR prevents it from being listed in the changelog Test labels Feb 17, 2025
Copy link

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/13361864664.
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: 350 Total Passed: 298 Total Failed: 2 Total Skipped: 0 *****************************

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit-count run_count=50

Copy link

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/13375245014.
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: 350 Total Passed: 299 Total Failed: 1 Total Skipped: 0 *****************************

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit-count run_count=50

Copy link

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

🔭 Outside diff range comments (1)
app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/SwitchBranches_spec.js (1)

94-95: 🛠️ Refactor suggestion

Remove explicit waits and use proper assertions.

Using cy.wait() is against Cypress best practices. Replace these with proper assertions or commands that automatically wait.

Replace the waits with appropriate assertions:

-// eslint-disable-next-line cypress/no-unnecessary-waiting
-cy.wait(2000);
+cy.get('@apiResponse').should('exist');

Also applies to: 112-113, 173-173

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 652dac4 and 34ff376.

📒 Files selected for processing (1)
  • app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/SwitchBranches_spec.js (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`app/client/cypress/**/**.*`: Review the following e2e test ...

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/Git/GitSync/SwitchBranches_spec.js
🧠 Learnings (1)
app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/SwitchBranches_spec.js (1)
Learnt from: brayn003
PR: appsmithorg/appsmith#38635
File: app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/MergeViaRemote_spec.ts:102-102
Timestamp: 2025-01-13T15:14:12.806Z
Learning: In Cypress Git sync tests, explicit assertions after _.gitSync.SwitchGitBranch() are not required as the helper method likely handles the verification internally.
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (1)
app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/SwitchBranches_spec.js (1)

131-131: LGTM! Improved navigation method.

The change to NavigateToPage is more appropriate for this use case.

Comment on lines 184 to 187
cy.get(".t--page-switch-tab")
.contains("ParentPage1")
.click({ force: true });
agHelper.WaitUntilEleAppear(".t--widget-tablewidgetv2");
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

Avoid force clicking and use data- attributes for selectors.*

The current implementation uses force click and CSS class selectors which could be brittle.

Apply this diff to improve the test reliability:

-cy.get(".t--page-switch-tab")
-  .contains("ParentPage1")
-  .click({ force: true });
-agHelper.WaitUntilEleAppear(".t--widget-tablewidgetv2");
+cy.get('[data-testid="t--page-switch-tab"]')
+  .contains("ParentPage1")
+  .should('be.visible')
+  .click();
+cy.get('[data-testid="t--widget-tablewidgetv2"]')
+  .should('be.visible');
📝 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(".t--page-switch-tab")
.contains("ParentPage1")
.click({ force: true });
agHelper.WaitUntilEleAppear(".t--widget-tablewidgetv2");
cy.get('[data-testid="t--page-switch-tab"]')
.contains("ParentPage1")
.should('be.visible')
.click();
cy.get('[data-testid="t--widget-tablewidgetv2"]')
.should('be.visible');

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/13393334444.
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: 350 Total Passed: 266 Total Failed: 34 Total Skipped: 0 *****************************

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 (1)
app/client/cypress/support/Objects/CommonLocators.ts (1)

358-358: LGTM! Consider using data-testid for better test stability.

The spinner locator is a good addition for handling loading states in tests. However, consider using a data-testid attribute instead of the Blueprint class for better test stability, as CSS classes might change during UI framework updates.

-  _spinnerHead = ".bp3-spinner-head";
+  _spinnerHead = "[data-testid='t--spinner-head']";
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 34ff376 and 8a488b2.

📒 Files selected for processing (2)
  • app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/SwitchBranches_spec.js (3 hunks)
  • app/client/cypress/support/Objects/CommonLocators.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/SwitchBranches_spec.js
🧰 Additional context used
📓 Path-based instructions (1)
`app/client/cypress/**/**.*`: Review the following e2e test ...

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/Objects/CommonLocators.ts
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-build / client-build

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit-count run_count=50

Copy link

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/13420171827.
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: 350 Total Passed: 292 Total Failed: 8 Total Skipped: 0 *****************************

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit-count run_count=50

Copy link

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 comments (2)
app/client/cypress/support/Pages/PageList.ts (2)

11-15: 🛠️ Refactor suggestion

Refactor selectors to use data-testid attributes.

The current selectors use string concatenation and CSS classes. According to our guidelines, we should use data-testid attributes for more reliable test selection.

Example refactor:

  private locators = {
-   pageListItem: (pageName: string) =>
-     `.t--entity.page:contains('${pageName}')`,
-   newButton: ".pages .t--entity-add-btn",
-   newPageOption: ".ads-v2-menu__menu-item-children",
-   switcher: `.t--pages-switcher`,
+   pageListItem: (pageName: string) =>
+     `[data-testid="page-item-${pageName}"]`,
+   newButton: "[data-testid=add-page-button]",
+   newPageOption: "[data-testid=page-option-menu]",
+   switcher: "[data-testid=pages-switcher]",
  };

110-110: ⚠️ Potential issue

Remove hardcoded waits and use proper assertions.

Using hardcoded waits (cy.wait) can make tests flaky. Instead, use Cypress's built-in retry-ability with assertions.

Replace with:

-    cy.wait(2000);
+    cy.get('.t--context-menu-container').should('be.visible');
-    cy.wait("@deletePage")
+    cy.intercept('DELETE', '**/api/v1/pages/*').as('deletePage');
+    cy.get('@deletePage').should('have.property', 'response.body.responseMeta.status', 200);

Also applies to: 113-113

🧹 Nitpick comments (1)
app/client/cypress/support/Pages/PageList.ts (1)

11-12: Sanitize page name input in selectors.

String concatenation in selectors could lead to XSS if the page name contains malicious content. Consider sanitizing the input or using a safer selector strategy.

  private locators = {
    pageListItem: (pageName: string) =>
-     `.t--entity.page:contains('${pageName}')`,
+     `[data-testid="page-item-${encodeURIComponent(pageName)}"]`,
  };
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8a488b2 and 3b54104.

📒 Files selected for processing (2)
  • app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/SwitchBranches_spec.js (4 hunks)
  • app/client/cypress/support/Pages/PageList.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/SwitchBranches_spec.js
🧰 Additional context used
📓 Path-based instructions (1)
`app/client/cypress/**/**.*`: Review the following e2e test ...

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/PageList.ts
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-build / client-build
🔇 Additional comments (1)
app/client/cypress/support/Pages/PageList.ts (1)

73-73:

❓ Verification inconclusive

Investigate why force click is necessary.

Adding force: true might mask underlying issues. Consider investigating why the element needs to be force-clicked:

  1. Is the element truly clickable?
  2. Is there an overlay blocking it?
  3. Is the element properly visible in the viewport?

🏁 Script executed:

#!/bin/bash
# Search for other force clicks in Cypress tests
rg -l "force: true" "app/client/cypress"

Length of output: 25245


Investigate the Necessity of Force Click on the Switcher Element
The usage of force: true in this click command mirrors a broader pattern across many Cypress tests in the project. While it can be acceptable in certain cases to bypass minor UI inconsistencies, it often indicates an underlying issue that should be addressed. Please verify the following for this specific element:

  • Is the switcher genuinely clickable without forcing the action?
  • Could an overlay or another UI element be obstructing interaction?
  • Is the element fully visible in the viewport as expected?

Reassessing these points will help ensure that we’re not masking deeper issues with our tests.

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/13433014768.
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: 350 Total Passed: 291 Total Failed: 9 Total Skipped: 0 *****************************

@NandanAnantharamu
Copy link
Collaborator Author

/ci-test-limit-count run_count=15

Copy link

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/13438394490.
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: 105 Total Passed: 69 Total Failed: 21 Total Skipped: 0 *****************************

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 Test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant