дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-08 19:02:17 +02:00
Closing a window, closing or switching a project, or quitting while Run/Debug sessions are still running now asks before terminating them (Terminate / Cancel / Don't ask again, sharing run.confirmTerminate with the Run tab prompt). Run publishes its live sessions through a RunningProcessesProvider contribution, so the close guard collects them without importing the run feature; the prompt comes before the unsaved-changes step so cancelling never discards edits. Closes #1433 Co-authored-by: ppxb <[email protected]>
36 рядки
1.3 KiB
TypeScript
36 рядки
1.3 KiB
TypeScript
import { expect, it, vi } from "vitest";
|
|
import { registerRunningProcessesProvider, runningProcesses } from "./contributions";
|
|
|
|
it("collects live processes from every provider, one entry per name", async () => {
|
|
const first = vi.fn(async () => [{ name: "app" }, { name: "worker" }]);
|
|
const second = vi.fn(() => [{ name: "app" }, { name: "docs" }]);
|
|
const disposers = [
|
|
registerRunningProcessesProvider({ id: "test.first", running: first }),
|
|
registerRunningProcessesProvider({ id: "test.second", running: second }),
|
|
];
|
|
try {
|
|
expect(await runningProcesses()).toEqual([{ name: "app" }, { name: "worker" }, { name: "docs" }]);
|
|
expect(first).toHaveBeenCalledOnce();
|
|
expect(second).toHaveBeenCalledOnce();
|
|
} finally {
|
|
disposers.forEach((dispose) => dispose());
|
|
}
|
|
expect(await runningProcesses()).toEqual([]);
|
|
});
|
|
|
|
it("keeps a replacement provider registered when its predecessor is disposed", async () => {
|
|
const disposeOld = registerRunningProcessesProvider({ id: "test.replaced", running: async () => [] });
|
|
const disposeNew = registerRunningProcessesProvider({
|
|
id: "test.replaced",
|
|
running: async () => [{ name: "app" }],
|
|
});
|
|
try {
|
|
disposeOld();
|
|
expect(await runningProcesses()).toEqual([{ name: "app" }]);
|
|
} finally {
|
|
disposeOld();
|
|
disposeNew();
|
|
}
|
|
expect(await runningProcesses()).toEqual([]);
|
|
});
|