* fix: route Cmd+W through existing tab close flow Keep the original tab-close behavior intact, and close the main or settings window only when there is no active closable tab to handle. * fix: fall back to closing non-listener windows on Cmd+W Treat BrowserWindow instances that do not participate in Netcatty's command-close bridge as regular closable windows. Keep the existing command-close path for the main and settings windows, and add tests that cover both the fallback close behavior and the renderer-capable send path.
70 lines
1.6 KiB
TypeScript
70 lines
1.6 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import { resolveWindowCommandCloseIntent } from "./windowCommandClose.ts";
|
|
|
|
test("Cmd+W closes the active closable tab first", () => {
|
|
assert.deepEqual(
|
|
resolveWindowCommandCloseIntent({
|
|
activeTabId: "s1",
|
|
editorTabIds: [],
|
|
sessionIds: ["s1", "s2"],
|
|
workspaceIds: [],
|
|
logViewIds: [],
|
|
}),
|
|
{ kind: "closeTab" },
|
|
);
|
|
});
|
|
|
|
test("Cmd+W on a log view closes the log view", () => {
|
|
assert.deepEqual(
|
|
resolveWindowCommandCloseIntent({
|
|
activeTabId: "log-1",
|
|
editorTabIds: [],
|
|
sessionIds: ["s1", "s2"],
|
|
workspaceIds: [],
|
|
logViewIds: ["log-1"],
|
|
}),
|
|
{ kind: "closeLogView", tabId: "log-1" },
|
|
);
|
|
});
|
|
|
|
test("Cmd+W closes an editor tab through the existing close flow", () => {
|
|
assert.deepEqual(
|
|
resolveWindowCommandCloseIntent({
|
|
activeTabId: "editor:1",
|
|
editorTabIds: ["editor:1"],
|
|
sessionIds: [],
|
|
workspaceIds: [],
|
|
logViewIds: [],
|
|
}),
|
|
{ kind: "closeTab" },
|
|
);
|
|
});
|
|
|
|
test("Cmd+W closes the window from the Vault page", () => {
|
|
assert.deepEqual(
|
|
resolveWindowCommandCloseIntent({
|
|
activeTabId: "vault",
|
|
editorTabIds: [],
|
|
sessionIds: [],
|
|
workspaceIds: [],
|
|
logViewIds: [],
|
|
}),
|
|
{ kind: "closeWindow" },
|
|
);
|
|
});
|
|
|
|
test("Cmd+W closes the window when nothing else is active", () => {
|
|
assert.deepEqual(
|
|
resolveWindowCommandCloseIntent({
|
|
activeTabId: null,
|
|
editorTabIds: [],
|
|
sessionIds: [],
|
|
workspaceIds: [],
|
|
logViewIds: [],
|
|
}),
|
|
{ kind: "closeWindow" },
|
|
);
|
|
});
|