Skip to content

Commit 0e3ccd0

Browse files
committed
feat: add bulk open changed files test coverage
1 parent dabb165 commit 0e3ccd0

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

test/spec/Extn-Git-integ-test.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,53 @@ define(function (require, exports, module) {
572572
expect(viewedFileIs("test.html")).toBeTrue();
573573
expect(MainViewManager.getWorkingSetSize(MainViewManager.ALL_PANES)).toBe(3);
574574
});
575+
576+
// one more than the threshold the panel starts confirming at
577+
const BULK_FILE_COUNT = 51;
578+
579+
it("should confirm before opening a large number of changed files", async () => {
580+
await showGitPanel();
581+
await __PR.closeAll();
582+
await awaitsFor(()=>{
583+
return MainViewManager.getWorkingSetSize(MainViewManager.ALL_PANES) === 0;
584+
}, "working set to be empty");
585+
586+
for (let i = 0; i < BULK_FILE_COUNT; i++) {
587+
await __PR.writeTextFile(`bulkFile${i}.txt`, `bulk file ${i}\n`, true);
588+
}
589+
await __PR.execCommand(Commands.CMD_GIT_REFRESH);
590+
await awaitsFor(()=>{
591+
return $gitPanel.find(".modified-file").length >= BULK_FILE_COUNT;
592+
}, "bulk files to be in modified files list", 30000);
593+
594+
// nothing is deleted and untracked files are shown, so every row in the
595+
// panel is a file the command will open
596+
const changedFileCount = $gitPanel.find(".modified-file").length;
597+
598+
// cancelling the confirmation must not open anything
599+
__PR.execCommand(Commands.CMD_GIT_OPEN_CHANGED_FILES); // dont await here as
600+
// it only completes after the dialog is closed
601+
await __PR.waitForModalDialog("#git-question-dialog", null, 10000);
602+
__PR.clickDialogButtonID(__PR.Dialogs.DIALOG_BTN_CANCEL);
603+
await __PR.waitForModalDialogClosed("#git-question-dialog");
604+
await __PR.execCommand(Commands.CMD_GIT_REFRESH);
605+
expect(MainViewManager.getWorkingSetSize(MainViewManager.ALL_PANES)).toBe(0);
606+
607+
// confirming opens all of them
608+
__PR.execCommand(Commands.CMD_GIT_OPEN_CHANGED_FILES);
609+
await __PR.waitForModalDialog("#git-question-dialog", null, 10000);
610+
__PR.clickDialogButtonID(__PR.Dialogs.DIALOG_BTN_OK);
611+
await __PR.waitForModalDialogClosed("#git-question-dialog");
612+
await awaitsFor(()=>{
613+
return MainViewManager.getWorkingSetSize(MainViewManager.ALL_PANES) === changedFileCount;
614+
}, "all changed files to be opened", 30000);
615+
616+
// re-running it now asks nothing as the files are already open. awaiting
617+
// here is safe for that reason, a dialog coming up would time out the spec
618+
await __PR.execCommand(Commands.CMD_GIT_OPEN_CHANGED_FILES);
619+
expect($("#git-question-dialog").length).toBe(0);
620+
expect(MainViewManager.getWorkingSetSize(MainViewManager.ALL_PANES)).toBe(changedFileCount);
621+
}, 60000);
575622
});
576623
});
577624
});

0 commit comments

Comments
 (0)