Файли
openidea/src/features/run/closeRunTab.test.ts
T
l0ng-ai 733b6cff1d feat(run): pin Run and Debug tabs; a new run replaces one finished, unpinned tab (#3514)
Run and Debug tabs can be pinned (context menu, Pin Active Tab, or the pin in place of the close button). A new run or debug session takes the place of one finished, unpinned tab: the same configuration's, else the selected one, else the first; Run used to add a tab per configuration, so finished tabs piled up. Rerun on a pinned tab restarts it in place and keeps it pinned. Settings > Run/Debug gets "Make configurations pinned by default".

Siblings: Run, Debug, Find and Usages tabs share one context menu (Close Tab, Close All Tabs, Close Other Tabs, Pin/Unpin Tab); Find and Usages show a pinned tab with the pin in place of its close button.
2026-11-15 18:29:15 +08:00

29 рядки
1.1 KiB
TypeScript

import { expect, it, vi } from "vitest";
import type { RunConfig } from "@/platform/ipc";
import { provideToolWindowService, type ToolWindowService } from "@/workbench/contributions";
import { closeRunTab } from "./runTabs";
import { useStackTraces } from "./stackTrace";
import { useRun, type RunSession } from "./store";
const finished = (id: string): RunSession =>
({
id,
config: { id, name: id, kind: "shell", command: "x", args: [], cwd: null, env: {} } as unknown as RunConfig,
runId: null,
status: "finished",
exitCode: 0,
startedAt: 0,
}) as RunSession;
it("hides the Run tool window once its last tab is closed", async () => {
const hide = vi.fn();
provideToolWindowService({ hide } as unknown as ToolWindowService);
useRun.setState({ sessions: [finished("a"), finished("b")] });
useStackTraces.setState({ tabs: [{ id: "t", title: "Trace", text: "" } as never] });
await closeRunTab("a");
await closeRunTab("t");
expect(hide).not.toHaveBeenCalled();
await closeRunTab("b");
expect(hide).toHaveBeenCalledWith("run", { removeFromStripe: true });
});