Skip to content

test: updated git tests for regression#39616

Closed
NandanAnantharamu wants to merge 2 commits intoreleasefrom
test/gitRegressionTests
Closed

test: updated git tests for regression#39616
NandanAnantharamu wants to merge 2 commits intoreleasefrom
test/gitRegressionTests

Conversation

@NandanAnantharamu
Copy link
Contributor

@NandanAnantharamu NandanAnantharamu commented Mar 7, 2025

Summary by CodeRabbit

  • New Features

    • Enhanced Git branch management to prevent duplicate branch creation and to reliably merge branches, including updates that reflect theme changes and integrate new queries and JavaScript objects.
  • Tests

    • Added comprehensive tests covering branch creation, deletion, and merging workflows to ensure a smooth and consistent user experience.
  • Chores

    • Updated test configurations to focus on essential branch management validations.

Warning

Tests have not run on the HEAD eca67f0 yet


Fri, 07 Mar 2025 19:15:15 UTC

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 7, 2025

Walkthrough

A new test suite for Git branch functionalities has been added to validate branch creation, deletion, and merging (including conflict, queries, JS objects, and theme changes). The limited tests configuration was updated to include the new suite while excluding certain others. Additionally, a new locator and a public method for preventing duplicate branch creation were introduced in the GitSync module, enhancing branch management through UI interactions.

Changes

File Change Summary
app/.../Git/MergeBranch_spec.ts Added new test suite for Git branch functionalities covering branch duplication, deletion, and various merge scenarios; introduced helper function DeleteBranchFromUI.
app/.../limited-tests.txt Updated test paths: replaced JSEditorIndent_spec.js with MergeBranch_spec.ts and commented out paths for Widgets tests.
app/.../GitSync.ts Added new locator createNewBranchButton and public method verifyNoDuplicateBranch to prevent duplicate branch creation via UI interactions.

Sequence Diagram(s)

sequenceDiagram
    participant TS as Test Suite
    participant GS as GitSync
    participant UI as User Interface

    TS->>GS: invoke verifyNoDuplicateBranch(branch)
    GS->>UI: Click quickActionsBranchBtn
    UI-->>GS: Display branchSearchInput
    GS->>UI: Type branch name (base + GUID)
    UI-->>GS: Update input field
    GS->>UI: Check absence of createNewBranchButton
    UI-->>GS: Return not visible
    GS->>UI: Click branchCloseBtn
Loading

Possibly related PRs

Suggested labels

Bug, ok-to-test, Enhancement, Git Product

Suggested reviewers

  • ApekshaBhosale
  • sagar-qa007
  • yatinappsmith

Poem

In the realm of branches, tests arise,
Merging code with precise surmise.
Duplicate alerts fade from view,
As locators and methods ring true.
Code and tests dance in a joyful hue! 🎉


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

@NandanAnantharamu
Copy link
Contributor Author

/ci-test-limit-count run_count=10

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

github-actions bot commented Mar 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: 3

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

91-91: Use data- attribute for selector instead of CSS class*

The locator is using a CSS class selector instead of a data-* attribute as recommended in the coding guidelines.

-    createNewBranchButton: ".t--create-new-branch-button",
+    createNewBranchButton: "[data-testid='t--create-new-branch-button']",
app/client/cypress/e2e/Regression/ClientSide/Git/MergeBranch_spec.ts (2)

104-148: Avoid using force:true in click operations

Using force:true (lines 108, 111, etc.) indicates potential issues with element visibility or interactability. This can lead to flaky tests.

Use proper waiting mechanisms or element visibility assertions before interacting with elements instead of forcing interactions.


24-30: Add after block for cleanup

The test has a before() hook but is missing an after() hook for cleanup. This could leave resources that affect other tests.

describe("Git Branch:", {}, function () {
  before(() => {
    gitSync.CreateNConnectToGit();
    cy.get("@gitRepoName").then((repName) => {
      repoName = repName;
    });
  });
+
+  after(() => {
+    // Clean up resources here, e.g., delete created branches
+  });
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6ad0926 and da46d73.

📒 Files selected for processing (3)
  • app/client/cypress/e2e/Regression/ClientSide/Git/MergeBranch_spec.ts (1 hunks)
  • app/client/cypress/limited-tests.txt (1 hunks)
  • app/client/cypress/support/Pages/GitSync.ts (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/limited-tests.txt
  • app/client/cypress/e2e/Regression/ClientSide/Git/MergeBranch_spec.ts
  • app/client/cypress/support/Pages/GitSync.ts
🧠 Learnings (2)
app/client/cypress/e2e/Regression/ClientSide/Git/MergeBranch_spec.ts (4)
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.
Learnt from: brayn003
PR: appsmithorg/appsmith#36622
File: app/client/cypress/e2e/Regression/ClientSide/Git/GitPersistBranch_spec.ts:41-45
Timestamp: 2024-11-12T08:11:36.416Z
Learning: In `app/client/cypress/**/**.*` Cypress test files, the cleanup guideline is to use `after` hooks for cleanup tasks.
Learnt from: brayn003
PR: appsmithorg/appsmith#38635
File: app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/MergeViaRemote_spec.ts:52-58
Timestamp: 2025-01-13T15:15:05.763Z
Learning: The Git sync helper functions (_.gitSync.CommitAndPush, _.gitSync.MergeToMaster) in Cypress tests already include built-in assertions, so additional explicit assertions after these calls are not needed.
Learnt from: brayn003
PR: appsmithorg/appsmith#38635
File: app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/MergeViaRemote_spec.ts:81-82
Timestamp: 2025-01-13T15:14:42.085Z
Learning: In Cypress test files, unsafe optional chaining is acceptable when the intention is for the test to fail if the expected data structure is not present, as it helps validate the API response structure.
app/client/cypress/support/Pages/GitSync.ts (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-prettier / prettier-check
  • GitHub Check: client-build / client-build
🔇 Additional comments (4)
app/client/cypress/limited-tests.txt (2)

2-2: LGTM - Added new MergeBranch spec to limited tests

The addition of the MergeBranch_spec.ts to the limited tests looks good.


5-5: LGTM - Commented out Widgets tests

Properly commented out the Widgets test path from the limited tests.

app/client/cypress/support/Pages/GitSync.ts (1)

541-564: LGTM - New utility method for branch verification

The method implementation looks good. It properly checks if a branch with the same name already exists by verifying the absence of the create button.

I notice you're using the retrieved learning to properly implement this method without unnecessary assertions after SwitchGitBranch().

app/client/cypress/e2e/Regression/ClientSide/Git/MergeBranch_spec.ts (1)

32-35: LGTM - Test validates duplicate branch creation

Good test case that verifies a branch with the same name cannot be created twice.

demoBranch = branchName;
gitSync.SwitchGitBranch("master");
DeleteBranchFromUI(demoBranch);
cy.wait(5000);
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

Replace explicit wait with proper assertions

Using explicit waits like cy.wait(5000) is against the coding guidelines. Replace with appropriate assertions or waitUntil.

-      cy.wait(5000);
+      agHelper.AssertElementVisibility(gitSync.locators.quickActionsBranchBtn);
+      // Or use a more specific assertion that confirms the UI is ready
📝 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.wait(5000);
agHelper.AssertElementVisibility(gitSync.locators.quickActionsBranchBtn);
// Or use a more specific assertion that confirms the UI is ready

gitSync.CreateGitBranch("Demo1", true);
PageList.AddNewPage();
gitSync.CommitAndPush();
cy.wait(3000);
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

Replace explicit wait with proper assertions

Using explicit waits like cy.wait(3000) is against the coding guidelines. Replace with appropriate assertions or waitUntil.

-    cy.wait(3000);
+    agHelper.WaitUntilElementVisible(gitSync.locators.quickActionsCommitBtn);
+    // Or use a more specific assertion that confirms the UI is ready
📝 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.wait(3000);
agHelper.WaitUntilElementVisible(gitSync.locators.quickActionsCommitBtn);
// Or use a more specific assertion that confirms the UI is ready

Comment on lines +150 to +159
function DeleteBranchFromUI(branch: any) {
cy.get(gitSync.locators.quickActionsBranchBtn).click();
agHelper.HoverElement(
`${gitSync.locators.branchItem}:contains('${branch}')`,
);
cy.get(gitSync.locators.branchItemMenuBtn).click({ force: true });
cy.get(gitSync.locators.branchItemMenuDeleteBtn)
.should("be.visible")
.click({ force: true });
}
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

Use data- attributes in DeleteBranchFromUI function*

The function uses CSS contains selector rather than data attributes, which goes against guidelines.

function DeleteBranchFromUI(branch: any) {
  cy.get(gitSync.locators.quickActionsBranchBtn).click();
-  agHelper.HoverElement(
-    `${gitSync.locators.branchItem}:contains('${branch}')`,
-  );
+  // Use a more appropriate selector without :contains
+  agHelper.HoverElement(gitSync.locators.branchItem);
+  // Use agHelper methods that target elements by text content instead
  cy.get(gitSync.locators.branchItemMenuBtn).click({ force: true });
  cy.get(gitSync.locators.branchItemMenuDeleteBtn)
    .should("be.visible")
    .click({ force: true });
}

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

@NandanAnantharamu
Copy link
Contributor Author

/ci-test-limit-count run_count=10

@github-actions
Copy link

github-actions bot commented Mar 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/cypress/e2e/Regression/ClientSide/Git/MergeBranch_spec.ts (2)

23-23: Add a specific type definition for demoBranch

Replace any with a more specific type definition to improve type safety and code readability.

-let demoBranch: any;
+let demoBranch: string;

47-50: Implement or remove commented code

The commented code related to verifying that a checked-out branch cannot be deleted should either be implemented or removed to maintain clean code.

-      // Verify cannot delete checked out branch
-      //   DeleteBranchFromUI(demoBranch);
-      //   agHelper.ValidateToastMessage("Cannot delete checked out branch.");
-      //   cy.wait(5000)
+      // TODO: Implement test for verifying that a checked-out branch cannot be deleted
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between da46d73 and eca67f0.

📒 Files selected for processing (1)
  • app/client/cypress/e2e/Regression/ClientSide/Git/MergeBranch_spec.ts (1 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/MergeBranch_spec.ts
🧠 Learnings (1)
app/client/cypress/e2e/Regression/ClientSide/Git/MergeBranch_spec.ts (4)
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.
Learnt from: brayn003
PR: appsmithorg/appsmith#36622
File: app/client/cypress/e2e/Regression/ClientSide/Git/GitPersistBranch_spec.ts:41-45
Timestamp: 2024-11-12T08:11:36.416Z
Learning: In `app/client/cypress/**/**.*` Cypress test files, the cleanup guideline is to use `after` hooks for cleanup tasks.
Learnt from: brayn003
PR: appsmithorg/appsmith#38635
File: app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/MergeViaRemote_spec.ts:52-58
Timestamp: 2025-01-13T15:15:05.763Z
Learning: The Git sync helper functions (_.gitSync.CommitAndPush, _.gitSync.MergeToMaster) in Cypress tests already include built-in assertions, so additional explicit assertions after these calls are not needed.
Learnt from: brayn003
PR: appsmithorg/appsmith#38635
File: app/client/cypress/e2e/Regression/ClientSide/Git/GitSync/MergeViaRemote_spec.ts:81-82
Timestamp: 2025-01-13T15:14:42.085Z
Learning: In Cypress test files, unsafe optional chaining is acceptable when the intention is for the test to fail if the expected data structure is not present, as it helps validate the API response structure.
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: client-build / client-build
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-lint / client-lint
🔇 Additional comments (3)
app/client/cypress/e2e/Regression/ClientSide/Git/MergeBranch_spec.ts (3)

44-44: Replace explicit wait with proper assertions

Using explicit waits like cy.wait(5000) is against the coding guidelines. Replace with appropriate assertions or waitUntil.

-      cy.wait(5000);
+      agHelper.AssertElementVisibility(gitSync.locators.quickActionsBranchBtn);
+      // Or use a more specific assertion that confirms the UI is ready

58-58: Replace explicit wait with proper assertions

Using explicit waits like cy.wait(3000) is against the coding guidelines. Replace with appropriate assertions or waitUntil.

-    cy.wait(3000);
+    agHelper.WaitUntilElementVisible(gitSync.locators.quickActionsCommitBtn);
+    // Or use a more specific assertion that confirms the UI is ready

150-159: Use data- attributes in DeleteBranchFromUI function*

The function uses CSS contains selector rather than data attributes, which goes against guidelines.

function DeleteBranchFromUI(branch: any) {
  cy.get(gitSync.locators.quickActionsBranchBtn).click();
-  agHelper.HoverElement(
-    `${gitSync.locators.branchItem}:contains('${branch}')`,
-  );
+  // Use a more appropriate selector without :contains
+  agHelper.HoverElement(gitSync.locators.branchItem);
+  // Use agHelper methods that target elements by text content instead
  cy.get(gitSync.locators.branchItemMenuBtn).click({ force: true });
  cy.get(gitSync.locators.branchItemMenuDeleteBtn)
    .should("be.visible")
    .click({ force: true });
}

Comment on lines +40 to +42
cy.wrap(demoBranch).as("demoBranch");
demoBranch = branchName;
gitSync.SwitchGitBranch("master");
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

Fix the variable wrapping and assignment logic

The current implementation appears to be wrapping a variable before it's assigned, which is incorrect.

-      cy.wrap(demoBranch).as("demoBranch");
-      demoBranch = branchName;
+      demoBranch = branchName;
+      cy.wrap(demoBranch).as("demoBranch");
📝 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.wrap(demoBranch).as("demoBranch");
demoBranch = branchName;
gitSync.SwitchGitBranch("master");
demoBranch = branchName;
cy.wrap(demoBranch).as("demoBranch");
gitSync.SwitchGitBranch("master");

@github-actions
Copy link

github-actions bot commented Mar 7, 2025

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/13727675969.
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: 60 Total Passed: 55 Total Failed: 5 Total Skipped: 0 *****************************

@NandanAnantharamu
Copy link
Contributor Author

/ci-test-limit-count run_count=10

@github-actions
Copy link

@github-actions
Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/13780788299.
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: 60 Total Passed: 45 Total Failed: 15 Total Skipped: 0 *****************************

@github-actions
Copy link

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

@github-actions github-actions bot added the Stale label Mar 18, 2025
@github-actions
Copy link

This PR has been closed because of inactivity.

@github-actions github-actions bot closed this Mar 26, 2025
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 Stale Test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant