Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
152 lines
4.5 KiB
TypeScript
152 lines
4.5 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import type { Host } from "../../domain/models";
|
|
import { prepareSerialConfigForSavedHost } from "../../domain/serialBackspace";
|
|
import { buildTelnetDeepLinkConnectionHost } from "../../domain/telnetDeepLink";
|
|
import { resolveEffectiveTerminalHost } from "../../domain/terminalHostResolution";
|
|
import {
|
|
createHostTerminalSession,
|
|
createSerialTerminalSession,
|
|
createWorkspaceHostTerminalSession,
|
|
} from "./sessionFactories";
|
|
|
|
const host = (overrides: Partial<Host>): Host => ({
|
|
id: "host-1",
|
|
label: "Host",
|
|
hostname: "example.com",
|
|
username: "alice",
|
|
port: 22,
|
|
group: "",
|
|
tags: [],
|
|
os: "linux",
|
|
protocol: "ssh",
|
|
createdAt: 1,
|
|
...overrides,
|
|
});
|
|
|
|
test("createHostTerminalSession keeps telnet deep-link default port for ssh hosts with telnet enabled", () => {
|
|
const connectionHost = buildTelnetDeepLinkConnectionHost(
|
|
host({
|
|
protocol: "ssh",
|
|
telnetEnabled: true,
|
|
telnetPort: undefined,
|
|
}),
|
|
);
|
|
|
|
const session = createHostTerminalSession("session-1", connectionHost);
|
|
|
|
assert.equal(session.protocol, "telnet");
|
|
assert.equal(session.port, 23);
|
|
});
|
|
|
|
test("serial session factories snapshot effective legacy Backspace behavior", () => {
|
|
const savedHostSession = createHostTerminalSession("session-1", host({
|
|
protocol: "serial",
|
|
hostname: "COM3",
|
|
port: 115200,
|
|
username: "",
|
|
serialConfig: {
|
|
path: "COM3",
|
|
baudRate: 115200,
|
|
},
|
|
backspaceBehavior: "ctrl-h",
|
|
}));
|
|
const quickSession = createSerialTerminalSession("session-2", {
|
|
path: "COM4",
|
|
baudRate: 9600,
|
|
});
|
|
const explicitDefaultSession = createHostTerminalSession("session-3", host({
|
|
protocol: "serial",
|
|
hostname: "COM5",
|
|
port: 115200,
|
|
username: "",
|
|
backspaceBehavior: "ctrl-h",
|
|
serialConfig: {
|
|
path: "COM5",
|
|
baudRate: 115200,
|
|
backspaceBehavior: "default",
|
|
},
|
|
}));
|
|
|
|
assert.equal(savedHostSession.serialConfig?.backspaceBehavior, "ctrl-h");
|
|
assert.equal(quickSession.serialConfig?.backspaceBehavior, "default");
|
|
assert.equal(explicitDefaultSession.serialConfig?.backspaceBehavior, "default");
|
|
});
|
|
|
|
test("workspace host factory creates a complete serial session", () => {
|
|
const session = createWorkspaceHostTerminalSession("session-serial", host({
|
|
protocol: "serial",
|
|
hostname: "COM7",
|
|
port: 57600,
|
|
username: "",
|
|
serialConfig: {
|
|
path: "COM7",
|
|
baudRate: 57600,
|
|
dataBits: 7,
|
|
stopBits: 2,
|
|
parity: "even",
|
|
},
|
|
}), "workspace-1");
|
|
|
|
assert.equal(session.workspaceId, "workspace-1");
|
|
assert.equal(session.protocol, "serial");
|
|
assert.deepEqual(session.serialConfig, {
|
|
path: "COM7",
|
|
baudRate: 57600,
|
|
dataBits: 7,
|
|
stopBits: 2,
|
|
parity: "even",
|
|
backspaceBehavior: "default",
|
|
});
|
|
});
|
|
|
|
test("workspace append snapshots serial Backspace behavior inherited from a group", () => {
|
|
const savedHost = host({
|
|
protocol: "serial",
|
|
hostname: "COM3",
|
|
port: 115200,
|
|
username: "",
|
|
group: "network/serial",
|
|
serialConfig: prepareSerialConfigForSavedHost({
|
|
path: "COM3",
|
|
baudRate: 115200,
|
|
backspaceBehavior: "default",
|
|
}),
|
|
});
|
|
const effectiveHost = resolveEffectiveTerminalHost({
|
|
host: savedHost,
|
|
groupConfigs: [{ path: "network", backspaceBehavior: "ctrl-h" }],
|
|
proxyProfiles: [],
|
|
});
|
|
|
|
const session = createWorkspaceHostTerminalSession("session-1", effectiveHost, "workspace-1");
|
|
|
|
assert.equal(session.workspaceId, "workspace-1");
|
|
assert.equal(session.serialConfig?.backspaceBehavior, "ctrl-h");
|
|
});
|
|
|
|
test("host session factories snapshot plugin connection configuration", () => {
|
|
const providerId = "com.example.transport.connection";
|
|
const pluginConnection = {
|
|
providerId,
|
|
authenticationProviderId: "com.example.transport.auth",
|
|
configuration: { endpoint: "gateway.example", tags: ["prod"] },
|
|
credentialId: "credential-reference-1234",
|
|
};
|
|
const pluginHost = host({
|
|
protocol: `plugin:${providerId}`,
|
|
pluginConnection,
|
|
});
|
|
|
|
const regular = createHostTerminalSession("session-plugin", pluginHost);
|
|
const workspace = createWorkspaceHostTerminalSession("session-workspace-plugin", pluginHost, "workspace-1");
|
|
|
|
assert.equal(regular.protocol, `plugin:${providerId}`);
|
|
assert.deepEqual(regular.pluginConnection, pluginConnection);
|
|
assert.notEqual(regular.pluginConnection, pluginConnection);
|
|
assert.equal(workspace.workspaceId, "workspace-1");
|
|
assert.deepEqual(workspace.pluginConnection, pluginConnection);
|
|
assert.notEqual(workspace.pluginConnection, pluginConnection);
|
|
});
|