Files
Netcatty/components/editor/EditorWindowPage.close.test.ts
T
90ab87efcc feat(editor): detached multi-tab window with acknowledged content handoff (#3606)
Add a detached multi-tab editor window with acknowledged content ownership, focused Monaco shortcuts, and shared close/save confirmation. Preserve source contents until handoff acknowledgement and block edits or incoming transfers during ownership changes.

Continuation of #3439. Original implementation by pplulee.

Co-authored-by: pplulee <hi@pplulee.me>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-08 18:11:23 +08:00

18 lines
975 B
TypeScript

import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import test from "node:test";
test("the custom window close button delegates before touching any renderer-owned tabs", async () => {
const source = readFileSync(new URL("./EditorWindowPage.tsx", import.meta.url), "utf8");
const body = source.match(/const handleWindowClose = useCallback\(async \(\) => \{([\s\S]*?)\n {2}\}, \[/)?.[1];
assert.ok(body);
let closes = 0;
const fail = () => { throw new Error("Native close must own tab confirmation and the incoming-transfer gate"); };
const close = new Function("closeWindow", "editorTabStore", "promptUnsavedChanges", "saveTab", "reportDetachedEditorTabsClosed", `return async () => {${body}}`)(
async () => { closes++; }, { getTabs: fail, close: fail }, fail, fail, fail,
);
await close();
assert.equal(closes, 1);
assert.match(source, /<EditorWindowControls onClose=\{\(\) => \{ void handleWindowClose\(\); \}\}/);
});