





















@@ -1,11 +1,19 @@
11import path from "node:path";
22import { afterEach, describe, expect, it, vi } from "vitest";
3+4+const detectBinaryMock = vi.hoisted(() => vi.fn(async () => false));
5+6+vi.mock("./detect-binary.js", () => ({
7+detectBinary: detectBinaryMock,
8+}));
9+310import { resolveBrowserOpenCommand } from "./browser-open.js";
411import { resetWindowsInstallRootsForTests } from "./windows-install-roots.js";
512613afterEach(() => {
714vi.restoreAllMocks();
815vi.unstubAllEnvs();
16+detectBinaryMock.mockReset().mockResolvedValue(false);
917resetWindowsInstallRootsForTests();
1018});
1119@@ -44,4 +52,24 @@ describe("resolveBrowserOpenCommand", () => {
4452expect(resolved.argv).toEqual([rundll32, "url.dll,FileProtocolHandler"]);
4553expect(resolved.command).toBe(rundll32);
4654});
55+56+it("resolves macOS open even when SSH environment variables are present", async () => {
57+vi.spyOn(process, "platform", "get").mockReturnValue("darwin");
58+vi.stubEnv("SSH_CONNECTION", "192.0.2.1 12345 192.0.2.2 22");
59+detectBinaryMock.mockResolvedValueOnce(true);
60+61+const resolved = await resolveBrowserOpenCommand();
62+63+expect(detectBinaryMock).toHaveBeenCalledWith("open");
64+expect(resolved).toEqual({ argv: ["open"], command: "open" });
65+});
66+67+it("still refuses browser launch over Linux SSH without a display", async () => {
68+vi.spyOn(process, "platform", "get").mockReturnValue("linux");
69+vi.stubEnv("SSH_CONNECTION", "192.0.2.1 12345 192.0.2.2 22");
70+71+const resolved = await resolveBrowserOpenCommand();
72+73+expect(resolved).toEqual({ argv: null, reason: "ssh-no-display" });
74+});
4775});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。