дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-06 18:17:15 +02:00
OPENIDEA_CONFIG_DIR, OPENIDEA_DATA_DIR and OPENIDEA_LOG_DIR take an absolute path, like OPENIDEA_LOCAL_DATA_DIR, and the IDE uses <path>/<identifier> under it. Every place that resolved these directories now goes through ide_host::data_dirs (app state, invalidate caches, window zoom and window state, the MCP stdio bridge, logging, the openidea-plugin CLI), and the frontend takes the user data directory from app_info instead of Tauri's appDataDir. A relative path for the configuration or user data shows an error and exits. Closes #2814
31 рядки
1.2 KiB
TypeScript
31 рядки
1.2 KiB
TypeScript
import { afterEach, expect, it, vi } from "vitest";
|
|
import { appDataDir, loadPlatformInfo, usePlatform } from "./platformInfo";
|
|
|
|
const appInfo = vi.hoisted(() => vi.fn());
|
|
vi.mock("@/platform/ipc", () => ({ isTauri: () => true, commands: { appInfo } }));
|
|
|
|
const initialPlatform = usePlatform.getState();
|
|
afterEach(() => usePlatform.setState(initialPlatform));
|
|
|
|
it.each([
|
|
["windows", 19045],
|
|
["windows", 22631],
|
|
["macos", null],
|
|
["linux", null],
|
|
] as const)("loads %s OS build %s separately from the app version", async (platform, windowsBuildNumber) => {
|
|
appInfo.mockResolvedValue({ platform, windowsBuildNumber, version: "0.1.39", wayland: false });
|
|
await loadPlatformInfo();
|
|
expect(usePlatform.getState()).toMatchObject({ os: platform, windowsBuildNumber, version: "0.1.39" });
|
|
});
|
|
|
|
it("keeps platform defaults when the query fails", async () => {
|
|
appInfo.mockRejectedValue(new Error("unavailable"));
|
|
await loadPlatformInfo();
|
|
expect(usePlatform.getState()).toEqual(initialPlatform);
|
|
});
|
|
|
|
it("takes the user data directory from the backend, which may have moved it", async () => {
|
|
appInfo.mockResolvedValue({ platform: "windows", dataDir: "E:/OpenIDEA/ai.l0ng.openidea/" });
|
|
expect(await appDataDir()).toBe("E:/OpenIDEA/ai.l0ng.openidea");
|
|
});
|