From d6ace3e54eb7a81eb9d2ad16f6c342dedf6a985c Mon Sep 17 00:00:00 2001 From: abose Date: Fri, 17 Jan 2025 14:59:13 +0530 Subject: [PATCH 1/3] fix: git file diff showing as empty and tests --- src/extensions/default/Git/src/Panel.js | 2 +- test/spec/Extn-Git-integ-test.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/extensions/default/Git/src/Panel.js b/src/extensions/default/Git/src/Panel.js index ed71310eb9..cac77c3dc0 100644 --- a/src/extensions/default/Git/src/Panel.js +++ b/src/extensions/default/Git/src/Panel.js @@ -460,7 +460,7 @@ define(function (require, exports) { } else { Metrics.countEvent(Metrics.EVENT_TYPE.GIT, 'diffBtn', "success"); } - $dialog.find(".commit-diff").append(Utils.formatDiff(diffVal)); + $dialog.find(".commit-diff").append(diffVal); }).catch(function (err) { Metrics.countEvent(Metrics.EVENT_TYPE.GIT, 'diffBtn', "error"); ErrorHandler.showError(err, Strings.ERROR_GIT_DIFF_FAILED); diff --git a/test/spec/Extn-Git-integ-test.js b/test/spec/Extn-Git-integ-test.js index 0bfd910647..82df91a40b 100644 --- a/test/spec/Extn-Git-integ-test.js +++ b/test/spec/Extn-Git-integ-test.js @@ -230,6 +230,25 @@ define(function (require, exports, module) { await __PR.waitForModalDialogClosed("#git-commit-dialog"); }); + it("Should be able to show individual file diff from panel", async function () { + $($(".btn-git-diff")[0]).click(); + + // check commit diff + await awaitsFor(()=>{ + return $(".commit-diff").text().includes("gitignore"); + }, "commit-diff to be shown", 10000); + expectTextToContain($(".commit-diff").text(), [ + "node_modules" + ]); + expectTextToContain($(".dialog-title").text(), [ + ".gitignore" + ]); + + // dismiss dialog + __PR.clickDialogButtonID("close"); + await __PR.waitForModalDialogClosed("#git-diff-dialog"); + }); + it("Should be able to commit the files", async function () { await commitAllBtnClick(); await commmitDlgWithMessage("first commit"); From 0555b89f2438d2cb8bcd320a8b45ef10565a443b Mon Sep 17 00:00:00 2001 From: abose Date: Fri, 17 Jan 2025 15:19:16 +0530 Subject: [PATCH 2/3] test: git discard all local changes integ test --- test/spec/Extn-Git-integ-test.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/spec/Extn-Git-integ-test.js b/test/spec/Extn-Git-integ-test.js index 82df91a40b..ff06ef5c55 100644 --- a/test/spec/Extn-Git-integ-test.js +++ b/test/spec/Extn-Git-integ-test.js @@ -435,6 +435,27 @@ define(function (require, exports, module) { }); + it("should discard all changes since last commit", async () => { + await SpecRunnerUtils.loadProjectInTestWindow(testPathGit); + __PR.typeAtCursor("discardTest"); + await __PR.saveActiveFile(); + await __PR.openFile("test.js"); + __PR.typeAtCursor("discardJSTest"); + await __PR.saveActiveFile(); + await awaitsFor(()=>{ + return $gitPanel.find(".modified-file").length === 2; + }, "2 files to be added in modified files list", 10000); + + // now discard all changes + __PR.execCommand(Commands.CMD_GIT_DISCARD_ALL_CHANGES); // dont await here as + // it tracks full complete after dialog closed + await __PR.waitForModalDialog("#git-question-dialog"); + __PR.clickDialogButtonID(__PR.Dialogs.DIALOG_BTN_OK); + await awaitsFor(()=>{ + return $gitPanel.find(".modified-file").length === 0; + }, "no files in modified files list", 10000); + }); + }); }); From b8a876e76a7ff4e6dc2b3f32912e9a6f46b1f955 Mon Sep 17 00:00:00 2001 From: abose Date: Fri, 17 Jan 2025 15:35:18 +0530 Subject: [PATCH 3/3] test: git branch switch tests --- test/spec/Extn-Git-integ-test.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/test/spec/Extn-Git-integ-test.js b/test/spec/Extn-Git-integ-test.js index ff06ef5c55..6713ddc8d0 100644 --- a/test/spec/Extn-Git-integ-test.js +++ b/test/spec/Extn-Git-integ-test.js @@ -456,7 +456,36 @@ define(function (require, exports, module) { }, "no files in modified files list", 10000); }); - }); + const createdBranch = "createdBranch"; + async function waitForBranchNameDropdown(expectedName) { + await awaitsFor(()=>{ + return $("#git-branch").text().trim().includes(expectedName); + }, `branch ${expectedName} to show in project`); + } + it("should be able to create a new branch", async () => { + $("#git-branch-dropdown-toggle").click(); + await awaitsFor(()=>{ + return $(".git-branch-new").is(":visible"); + }, "branch dropdown to show"); + $(".git-branch-new").click(); + await __PR.waitForModalDialog(".git"); + $('input[name="branch-name"]').val(createdBranch); + __PR.clickDialogButtonID(__PR.Dialogs.DIALOG_BTN_OK); + await waitForBranchNameDropdown(createdBranch); + }); + + it("should be able to switch branch", async () => { + await waitForBranchNameDropdown(createdBranch); + $("#git-branch-dropdown-toggle").click(); + await awaitsFor(()=>{ + return $(".git-branch-new").is(":visible"); + }, "branch dropdown to show"); + + expect($(".switch-branch").text()).toContain("master"); + $(".switch-branch").click(); + await waitForBranchNameDropdown("master"); + }); + }); }); });