fix: improve trans script migration hint

This commit is contained in:
Codex
2026-06-20 07:23:11 +00:00
parent d05b963064
commit 4d4feacb31
7 changed files with 133 additions and 13 deletions
+35
View File
@@ -74,3 +74,38 @@ describe("ssh stdout bounded streaming", () => {
expect(hint).toContain("\"transport\":\"frontend-websocket\"");
});
});
describe("ssh removed shell aliases", () => {
test("reports route-aware replacement examples for trans script", () => {
const previousEntrypoint = process.env.UNIDESK_SSH_ENTRYPOINT;
process.env.UNIDESK_SSH_ENTRYPOINT = "trans";
try {
parseSshInvocation("D601:/tmp", ["script", "--", "pwd"]);
throw new Error("expected script alias to fail");
} catch (error) {
expect(error).toBeInstanceOf(Error);
const payload = error as Error & {
code?: string;
entrypoint?: string;
route?: string;
operation?: string;
replacementExamples?: {
posixSh?: string;
bash?: string;
};
};
expect(payload.code).toBe("ssh-removed-shell-alias");
expect(payload.entrypoint).toBe("trans");
expect(payload.route).toBe("D601:/tmp");
expect(payload.operation).toBe("script");
expect(payload.replacementExamples?.posixSh).toBe("trans D601:/tmp sh -- 'pwd'");
expect(payload.replacementExamples?.bash).toBe("trans D601:/tmp bash -- 'pwd'");
} finally {
if (previousEntrypoint === undefined) {
delete process.env.UNIDESK_SSH_ENTRYPOINT;
} else {
process.env.UNIDESK_SSH_ENTRYPOINT = previousEntrypoint;
}
}
});
});