Files
paseo/packages/desktop/src/daemon/runtime-paths.test.ts
T
Mohamed Boudra 92b92a81c8 perf(desktop): reduce daemon management memory overhead (#5007)
Desktop and CLI helpers imported daemon bootstrap through the server root, while supervisor configuration retained the full wire schema tree. Expose existing capabilities through narrow package entrypoints and share configuration schemas without loading message definitions. Guard the dependency trees without tree-shaking so unused exports cannot hide the runtime cost.
2026-09-17 15:18:12 +02:00

73 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() },
}));
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",
);
});
});