Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/extensions/default/Git/src/Panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
71 changes: 70 additions & 1 deletion test/spec/Extn-Git-integ-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -416,7 +435,57 @@ 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);
});

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");
});
});
});
});
Loading