Skip to content

Commit 5a92e63

Browse files
committed
test no veto when scratchpads should backup
1 parent 898311b commit 5a92e63

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/vs/workbench/services/workingCopy/test/electron-sandbox/workingCopyBackupTracker.test.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,49 @@ suite('WorkingCopyBackupTracker (native)', function () {
423423
await cleanup();
424424
});
425425

426+
test('onWillShutdown - scratchpads - no veto if backed up', async function () {
427+
const { accessor, cleanup } = await createTracker();
428+
429+
class TestBackupWorkingCopy extends TestWorkingCopy {
430+
431+
constructor(resource: URI) {
432+
super(resource);
433+
434+
accessor.workingCopyService.registerWorkingCopy(this);
435+
}
436+
437+
override capabilities = WorkingCopyCapabilities.Untitled | WorkingCopyCapabilities.Scratchpad;
438+
439+
override isDirty(): boolean {
440+
return false;
441+
}
442+
443+
override isModified(): boolean {
444+
return true;
445+
}
446+
}
447+
448+
accessor.filesConfigurationService.testOnFilesConfigurationChange({ files: { hotExit: HotExitConfiguration.ON_EXIT } });
449+
accessor.nativeHostService.windowCount = Promise.resolve(2);
450+
// Set cancel to force a veto if hot exit does not trigger
451+
accessor.fileDialogService.setConfirmResult(ConfirmResult.CANCEL);
452+
453+
const resource = toResource.call(this, '/path/custom.txt');
454+
new TestBackupWorkingCopy(resource);
455+
456+
const event = new TestBeforeShutdownEvent();
457+
event.reason = ShutdownReason.CLOSE;
458+
accessor.lifecycleService.fireBeforeShutdown(event);
459+
460+
const veto = await event.value;
461+
assert.ok(!veto);
462+
463+
const finalVeto = await event.finalValue?.();
464+
assert.ok(!finalVeto); // assert the tracker uses the internal finalVeto API
465+
466+
await cleanup();
467+
});
468+
426469
test('onWillShutdown - pending backup operations canceled and tracker suspended/resumsed', async function () {
427470
const { accessor, tracker, cleanup } = await createTracker();
428471

0 commit comments

Comments
 (0)