-
Notifications
You must be signed in to change notification settings - Fork 4.5k
test: updated git tests for regression #39616
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,160 @@ | ||||||||
| import commonLocators from "../../../../locators/commonlocators.json"; | ||||||||
|
|
||||||||
| import { | ||||||||
| agHelper, | ||||||||
| entityExplorer, | ||||||||
| jsEditor, | ||||||||
| deployMode, | ||||||||
| gitSync, | ||||||||
| apiPage, | ||||||||
| dataSources, | ||||||||
| assertHelper, | ||||||||
| locators, | ||||||||
| appSettings, | ||||||||
| } from "../../../../support/Objects/ObjectsCore"; | ||||||||
| import EditorNavigation, { | ||||||||
| EntityType, | ||||||||
| PageLeftPane, | ||||||||
| PagePaneSegment, | ||||||||
| } from "../../../../support/Pages/EditorNavigation"; | ||||||||
| import PageList from "../../../../support/Pages/PageList"; | ||||||||
|
|
||||||||
| let repoName; | ||||||||
| let demoBranch: any; | ||||||||
| describe("Git Branch:", {}, function () { | ||||||||
| before(() => { | ||||||||
| gitSync.CreateNConnectToGit(); | ||||||||
| cy.get("@gitRepoName").then((repName) => { | ||||||||
| repoName = repName; | ||||||||
| }); | ||||||||
| }); | ||||||||
|
|
||||||||
| it("1. Verify branch with same name cannot be created", function () { | ||||||||
| gitSync.CreateGitBranch("Test_Branch"); | ||||||||
| gitSync.verifyNoDuplicateBranch("Test_Branch"); | ||||||||
| }); | ||||||||
|
|
||||||||
| it("2. Verify delete branch", function () { | ||||||||
| gitSync.CreateGitBranch("Demo", true); | ||||||||
| gitSync.GetCurrentBranchName().then((branchName: any) => { | ||||||||
| cy.wrap(demoBranch).as("demoBranch"); | ||||||||
| demoBranch = branchName; | ||||||||
| gitSync.SwitchGitBranch("master"); | ||||||||
| DeleteBranchFromUI(demoBranch); | ||||||||
| cy.wait(5000); | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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);
+ agHelper.AssertElementVisibility(gitSync.locators.quickActionsBranchBtn);
+ // Or use a more specific assertion that confirms the UI is ready📝 Committable suggestion
Suggested change
|
||||||||
| gitSync.SwitchGitBranch(`origin/${demoBranch}`); | ||||||||
|
|
||||||||
| // Verify cannot delete checked out branch | ||||||||
| // DeleteBranchFromUI(demoBranch); | ||||||||
| // agHelper.ValidateToastMessage("Cannot delete checked out branch."); | ||||||||
| // cy.wait(5000) | ||||||||
| }); | ||||||||
| }); | ||||||||
|
|
||||||||
| it("3. Verify merge branch", function () { | ||||||||
| gitSync.CreateGitBranch("Demo1", true); | ||||||||
| PageList.AddNewPage(); | ||||||||
| gitSync.CommitAndPush(); | ||||||||
| cy.wait(3000); | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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);
+ agHelper.WaitUntilElementVisible(gitSync.locators.quickActionsCommitBtn);
+ // Or use a more specific assertion that confirms the UI is ready📝 Committable suggestion
Suggested change
|
||||||||
| cy.then(() => { | ||||||||
| gitSync.CheckMergeConflicts(demoBranch); | ||||||||
| agHelper.GetNClick(gitSync.locators.opsMergeBtn); | ||||||||
| assertHelper.AssertNetworkStatus("@mergeBranch"); | ||||||||
| gitSync.CloseOpsModal(); | ||||||||
| gitSync.SwitchGitBranch(demoBranch); | ||||||||
| PageList.assertPresence("Page2"); | ||||||||
| }); | ||||||||
| }); | ||||||||
|
|
||||||||
| it("4. Verify merge branch with new query", function () { | ||||||||
| gitSync.SwitchGitBranch("Demo1"); | ||||||||
| dataSources.CreateMockDB("Users"); | ||||||||
| dataSources.CreateQueryAfterDSSaved("select * from users limit 10"); | ||||||||
| dataSources.RunQuery(); | ||||||||
| gitSync.CommitAndPush(); | ||||||||
| cy.then(() => { | ||||||||
| gitSync.CheckMergeConflicts(demoBranch); | ||||||||
| agHelper.GetNClick(gitSync.locators.opsMergeBtn); | ||||||||
| assertHelper.AssertNetworkStatus("@mergeBranch"); | ||||||||
| gitSync.CloseOpsModal(); | ||||||||
| gitSync.SwitchGitBranch(demoBranch); | ||||||||
| EditorNavigation.NavigateToPage("Page2", true); | ||||||||
| PageLeftPane.switchSegment(PagePaneSegment.Queries); | ||||||||
| agHelper.AssertElementVisibility(locators._entityTestId("Query1")); | ||||||||
| }); | ||||||||
| }); | ||||||||
|
|
||||||||
| it("5. Verify merge branch with new JS object", function () { | ||||||||
| gitSync.SwitchGitBranch("Demo1"); | ||||||||
| EditorNavigation.NavigateToPage("Page2", true); | ||||||||
| jsEditor.CreateJSObject('return "Success";'); | ||||||||
| gitSync.CommitAndPush(); | ||||||||
| cy.then(() => { | ||||||||
| gitSync.CheckMergeConflicts(demoBranch); | ||||||||
| agHelper.GetNClick(gitSync.locators.opsMergeBtn); | ||||||||
| assertHelper.AssertNetworkStatus("@mergeBranch"); | ||||||||
| gitSync.CloseOpsModal(); | ||||||||
| gitSync.SwitchGitBranch(demoBranch); | ||||||||
| EditorNavigation.NavigateToPage("Page2", true); | ||||||||
| PageLeftPane.switchSegment(PagePaneSegment.JS); | ||||||||
| agHelper.AssertElementVisibility(locators._entityTestId("JSObject1")); | ||||||||
| }); | ||||||||
| }); | ||||||||
|
|
||||||||
| it("6. Verify merge branch with theme change", function () { | ||||||||
| gitSync.SwitchGitBranch("Demo1"); | ||||||||
| appSettings.OpenAppSettings(); | ||||||||
| appSettings.GoToThemeSettings(); | ||||||||
| cy.get(commonLocators.changeThemeBtn).click({ force: true }); | ||||||||
| agHelper.AssertAutoSave(); | ||||||||
| // select a theme | ||||||||
| cy.get(commonLocators.themeCard).last().click({ force: true }); | ||||||||
| agHelper.AssertAutoSave(); | ||||||||
| // check for alert | ||||||||
| cy.get(`${commonLocators.themeCard}`) | ||||||||
| .last() | ||||||||
| .siblings("div") | ||||||||
| .first() | ||||||||
| .invoke("text") | ||||||||
| .then((text) => { | ||||||||
| cy.get(commonLocators.toastmsg).contains(`Theme ${text} applied`); | ||||||||
| }); | ||||||||
|
|
||||||||
| // check if color of canvas is same as theme bg color | ||||||||
| cy.get(`${commonLocators.themeCard} > main`) | ||||||||
| .last() | ||||||||
| .invoke("css", "background-color") | ||||||||
| .then((backgroudColor) => { | ||||||||
| cy.get(commonLocators.canvas).should( | ||||||||
| "have.css", | ||||||||
| "background-color", | ||||||||
| backgroudColor, | ||||||||
| ); | ||||||||
|
|
||||||||
| gitSync.CommitAndPush(); | ||||||||
| cy.then(() => { | ||||||||
| gitSync.CheckMergeConflicts(demoBranch); | ||||||||
| agHelper.GetNClick(gitSync.locators.opsMergeBtn); | ||||||||
| assertHelper.AssertNetworkStatus("@mergeBranch"); | ||||||||
| gitSync.CloseOpsModal(); | ||||||||
| gitSync.SwitchGitBranch(demoBranch); | ||||||||
| cy.get(commonLocators.canvas).should( | ||||||||
| "have.css", | ||||||||
| "background-color", | ||||||||
| backgroudColor, | ||||||||
| ); | ||||||||
| }); | ||||||||
| }); | ||||||||
| }); | ||||||||
|
|
||||||||
| 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 }); | ||||||||
| } | ||||||||
|
Comment on lines
+150
to
+159
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 });
}
|
||||||||
| }); | ||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| # To run only limited tests - give the spec names in below format: | ||
| #cypress/e2e/Regression/ClientSide/VisualTests/JSEditorIndent_spec.js | ||
| cypress/e2e/Regression/ClientSide/Git/MergeBranch_spec.ts | ||
| # For running all specs - uncomment below: | ||
| #cypress/e2e/**/**/* | ||
| cypress/e2e/Regression/ClientSide/Anvil/Widgets/* | ||
| #cypress/e2e/Regression/ClientSide/Anvil/Widgets/* | ||
|
|
||
| #ci-test-limit uses this file to run minimum of specs. Do not run entire suite with this command. |
There was a problem hiding this comment.
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.
📝 Committable suggestion