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
186 lines
5.4 KiB
TypeScript
186 lines
5.4 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import {
|
|
isTransferNavigationTerminalTabId,
|
|
pickHostForTransferNavigation,
|
|
resolveSftpTransferNavigationHostLabel,
|
|
resolveSftpTransferNavigationPath,
|
|
resolveSftpTransferNavigationTarget,
|
|
} from "./sftpTransferNavigation";
|
|
|
|
test("resume of a direct download opens the remote source host", () => {
|
|
const target = resolveSftpTransferNavigationTarget({
|
|
direction: "download",
|
|
sourceHostId: "host-1",
|
|
targetConnectionId: "local",
|
|
sourceConnectionId: "conn-remote",
|
|
sourcePath: "/root/geoip.metadb",
|
|
targetPath: "/Users/me/Desktop/geoip.metadb",
|
|
isDirectory: false,
|
|
}, true);
|
|
|
|
assert.deepEqual(target, {
|
|
kind: "remote-host",
|
|
hostId: "host-1",
|
|
useSourcePath: true,
|
|
});
|
|
});
|
|
|
|
test("resume of a dual-pane download still opens the remote source", () => {
|
|
// Dual-pane local targets use a real connection UUID, not the "local" sentinel.
|
|
const target = resolveSftpTransferNavigationTarget({
|
|
direction: "download",
|
|
sourceHostId: "host-1",
|
|
targetHostId: undefined,
|
|
sourceConnectionId: "conn-remote",
|
|
targetConnectionId: "conn-local-uuid",
|
|
sourcePath: "/root/geoip.metadb",
|
|
targetPath: "/Users/me/Desktop/geoip.metadb",
|
|
isDirectory: false,
|
|
}, true);
|
|
|
|
assert.deepEqual(target, {
|
|
kind: "remote-host",
|
|
hostId: "host-1",
|
|
useSourcePath: true,
|
|
});
|
|
});
|
|
|
|
test("opening a finished download target uses the local folder", () => {
|
|
const target = resolveSftpTransferNavigationTarget({
|
|
direction: "download",
|
|
sourceHostId: "host-1",
|
|
targetConnectionId: "conn-local-uuid",
|
|
sourceConnectionId: "conn-remote",
|
|
sourcePath: "/root/geoip.metadb",
|
|
targetPath: "/Users/me/Desktop/geoip.metadb",
|
|
isDirectory: false,
|
|
}, false);
|
|
|
|
assert.equal(target.kind, "local-path");
|
|
assert.equal(
|
|
resolveSftpTransferNavigationPath({
|
|
sourcePath: "/root/geoip.metadb",
|
|
targetPath: "/Users/me/Desktop/geoip.metadb",
|
|
isDirectory: false,
|
|
}, false),
|
|
"/Users/me/Desktop",
|
|
);
|
|
});
|
|
|
|
test("resume of an upload opens the remote target host", () => {
|
|
const target = resolveSftpTransferNavigationTarget({
|
|
direction: "upload",
|
|
targetHostId: "host-2",
|
|
sourceConnectionId: "local",
|
|
targetConnectionId: "conn-remote",
|
|
sourcePath: "/Users/me/file.txt",
|
|
targetPath: "/tmp/file.txt",
|
|
isDirectory: false,
|
|
}, true);
|
|
|
|
assert.deepEqual(target, {
|
|
kind: "remote-host",
|
|
hostId: "host-2",
|
|
useSourcePath: false,
|
|
});
|
|
});
|
|
|
|
test("resume of a local copy only opens the SFTP panel", () => {
|
|
const target = resolveSftpTransferNavigationTarget({
|
|
direction: "local-copy",
|
|
sourceConnectionId: "local",
|
|
targetConnectionId: "local",
|
|
sourcePath: "/Users/me/a.txt",
|
|
targetPath: "/Users/me/b.txt",
|
|
isDirectory: false,
|
|
}, true);
|
|
|
|
assert.deepEqual(target, {
|
|
kind: "local-copy-panel",
|
|
useSourcePath: false,
|
|
});
|
|
});
|
|
|
|
test("opening an upload destination uses the remote target (never local openPath)", () => {
|
|
const withHostId = resolveSftpTransferNavigationTarget({
|
|
direction: "upload",
|
|
targetHostId: "host-2",
|
|
sourceConnectionId: "local",
|
|
targetConnectionId: "conn-remote",
|
|
sourcePath: "/Users/me/file.txt",
|
|
targetPath: "/root/file.txt",
|
|
isDirectory: false,
|
|
}, false);
|
|
assert.deepEqual(withHostId, {
|
|
kind: "remote-host",
|
|
hostId: "host-2",
|
|
useSourcePath: false,
|
|
});
|
|
|
|
// Older / drag-drop rows may lack targetHostId — still open remote, not /root via shell.
|
|
const withoutHostId = resolveSftpTransferNavigationTarget({
|
|
direction: "upload",
|
|
sourceConnectionId: "local",
|
|
targetConnectionId: "conn-remote",
|
|
sourcePath: "/Users/me/file.txt",
|
|
targetPath: "/root/file.txt",
|
|
isDirectory: false,
|
|
}, false);
|
|
assert.deepEqual(withoutHostId, {
|
|
kind: "remote-host",
|
|
hostId: undefined,
|
|
useSourcePath: false,
|
|
});
|
|
});
|
|
|
|
test("navigation host label prefers the endpoint being opened", () => {
|
|
assert.equal(
|
|
resolveSftpTransferNavigationHostLabel({
|
|
sourceHostLabel: "Local",
|
|
targetHostLabel: "CI-Build-01",
|
|
}, false),
|
|
"CI-Build-01",
|
|
);
|
|
assert.equal(
|
|
resolveSftpTransferNavigationHostLabel({
|
|
sourceHostLabel: "prod",
|
|
targetHostLabel: "Local",
|
|
}, true),
|
|
"prod",
|
|
);
|
|
});
|
|
|
|
test("pickHostForTransferNavigation falls back to live SFTP host for uploads", () => {
|
|
const live = { id: "host-live", label: "CI-Build-01", hostname: "10.0.0.1" };
|
|
assert.equal(
|
|
pickHostForTransferNavigation({
|
|
hostId: undefined,
|
|
hostLabel: undefined,
|
|
vaultHosts: [{ id: "other", label: "other" }],
|
|
liveHosts: [live],
|
|
allowLiveUploadFallback: true,
|
|
}),
|
|
live,
|
|
);
|
|
assert.equal(
|
|
pickHostForTransferNavigation({
|
|
hostId: "host-vault",
|
|
hostLabel: "CI-Build-01",
|
|
vaultHosts: [{ id: "host-vault", label: "CI-Build-01" }],
|
|
liveHosts: [live],
|
|
})?.id,
|
|
"host-vault",
|
|
);
|
|
});
|
|
|
|
test("isTransferNavigationTerminalTabId rejects vault/editor scopes", () => {
|
|
assert.equal(isTransferNavigationTerminalTabId(null), false);
|
|
assert.equal(isTransferNavigationTerminalTabId("vault"), false);
|
|
assert.equal(isTransferNavigationTerminalTabId("sftp"), false);
|
|
assert.equal(isTransferNavigationTerminalTabId("editor:abc"), false);
|
|
assert.equal(isTransferNavigationTerminalTabId("session-uuid"), true);
|
|
assert.equal(isTransferNavigationTerminalTabId("workspace-1"), true);
|
|
});
|