mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
* Fix desktop CLI passthrough tty handling * Fix desktop daemon manager test drift * Update daemon stop test after main merge * test(cli): isolate npx cache per CLI test
77 lines
1.8 KiB
TypeScript
77 lines
1.8 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { resolveNodeExecPath } from "./runtime-paths";
|
|
|
|
const mocks = vi.hoisted(() => ({
|
|
existsSync: vi.fn(),
|
|
app: {
|
|
isPackaged: true,
|
|
},
|
|
}));
|
|
|
|
vi.mock("node:fs", () => ({
|
|
existsSync: mocks.existsSync,
|
|
readFileSync: vi.fn(),
|
|
}));
|
|
|
|
vi.mock("electron", () => ({
|
|
app: mocks.app,
|
|
}));
|
|
|
|
vi.mock("electron-log/main", () => ({
|
|
default: { warn: vi.fn() },
|
|
}));
|
|
|
|
vi.mock("@getpaseo/server", () => ({
|
|
spawnProcess: vi.fn(),
|
|
}));
|
|
|
|
const originalPlatform = process.platform;
|
|
const originalExecPath = process.execPath;
|
|
const originalResourcesPath = process.resourcesPath;
|
|
|
|
function setProcessRuntime(input: {
|
|
platform: NodeJS.Platform;
|
|
execPath: string;
|
|
resourcesPath?: string;
|
|
}): void {
|
|
Object.defineProperty(process, "platform", {
|
|
configurable: true,
|
|
value: input.platform,
|
|
});
|
|
Object.defineProperty(process, "execPath", {
|
|
configurable: true,
|
|
value: input.execPath,
|
|
});
|
|
Object.defineProperty(process, "resourcesPath", {
|
|
configurable: true,
|
|
value: input.resourcesPath,
|
|
});
|
|
}
|
|
|
|
describe("runtime-paths", () => {
|
|
beforeEach(() => {
|
|
mocks.app.isPackaged = true;
|
|
mocks.existsSync.mockReturnValue(true);
|
|
setProcessRuntime({
|
|
platform: "darwin",
|
|
execPath: "/Applications/Paseo.app/Contents/MacOS/Paseo",
|
|
resourcesPath: "/Applications/Paseo.app/Contents/Resources",
|
|
});
|
|
});
|
|
|
|
afterEach(() => {
|
|
vi.restoreAllMocks();
|
|
setProcessRuntime({
|
|
platform: originalPlatform,
|
|
execPath: originalExecPath,
|
|
resourcesPath: originalResourcesPath,
|
|
});
|
|
});
|
|
|
|
it("uses the macOS Helper executable for packaged daemon node launches", () => {
|
|
expect(resolveNodeExecPath()).toBe(
|
|
"/Applications/Paseo.app/Contents/Frameworks/Paseo Helper.app/Contents/MacOS/Paseo Helper",
|
|
);
|
|
});
|
|
});
|