Файли
openidea/src/workbench/runningProcesses.test.ts
T
ppxbтаppxb 43af99d3ec feat(app): ask before closing with running Run/Debug processes (#1445)
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]>
2026-11-05 12:34:35 +08:00

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([]);
});