mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-10-09 15:58:34 +00:00
ff6b4a4625
* Broadcast user paste to terminals * Use workspace session id for context paste broadcast * Consume paste broadcast suppression before toggle check
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import { broadcastTerminalPasteData } from "./hooks/useTerminalContextActions";
|
|
|
|
test("terminal context paste reports whether it broadcast to peers", () => {
|
|
const broadcasted: Array<{ data: string; sessionId: string }> = [];
|
|
|
|
const didBroadcast = broadcastTerminalPasteData("line one", {
|
|
sourceSessionId: "workspace-session-1",
|
|
sessionRef: { current: "backend-session-1" },
|
|
isBroadcastEnabledRef: { current: true },
|
|
onBroadcastInputRef: {
|
|
current: (data, sourceSessionId) => {
|
|
broadcasted.push({ data, sessionId: sourceSessionId });
|
|
},
|
|
},
|
|
});
|
|
|
|
assert.equal(didBroadcast, true);
|
|
assert.deepEqual(broadcasted, [{ data: "line one", sessionId: "workspace-session-1" }]);
|
|
});
|
|
|
|
test("terminal context paste reports false when broadcast is disabled", () => {
|
|
const didBroadcast = broadcastTerminalPasteData("line one", {
|
|
sourceSessionId: "workspace-session-1",
|
|
sessionRef: { current: "session-1" },
|
|
isBroadcastEnabledRef: { current: false },
|
|
onBroadcastInputRef: {
|
|
current: () => {
|
|
throw new Error("broadcast should not run");
|
|
},
|
|
},
|
|
});
|
|
|
|
assert.equal(didBroadcast, false);
|
|
});
|