Files
openidea/src/features/code-insight/ipc.test.ts
T
l0ng-ai ce12f68613 fix(hierarchy): load library types' levels from their language server (#3998)
The type hierarchy's withDocument opened every node from disk, so library types (jdt:// URIs) failed with os error 2: look-ahead loads failed silently, leaving expand arrows on every JDK type, and expanding one showed "failed to load". Library URIs now open as virtual documents.

Fixes #3409
2026-11-17 20:24:37 +08:00

30 lines
1.1 KiB
TypeScript

import { describe, expect, it, vi } from "vitest";
const opened = vi.hoisted(() => [] as string[]);
vi.mock("@/platform/ipc", async (importOriginal) => {
const ipc = await importOriginal<typeof import("@/platform/ipc")>();
const doc = (path: string) => Promise.resolve({ status: "ok", data: { id: 3, path } });
return {
...ipc,
isTauri: () => true,
commands: {
...ipc.commands,
docOpen: (path: string) => (opened.push(`file ${path}`), doc(path)),
docOpenVirtual: (uri: string) => (opened.push(`virtual ${uri}`), doc(uri)),
docClose: () => Promise.resolve(),
},
};
});
const { withDocument } = await import("./ipc");
describe("withDocument", () => {
it("opens a library type through its language server, a project file from disk", async () => {
const uri = "jdt://contents/java.base/java.util/UUID.class?=demo/%5C/jdk%5C/lib%5C/jrt-fs.jar%60java.base";
await withDocument(uri, async (doc) => doc);
await withDocument("/p/src/App.java", async (doc) => doc);
expect(opened).toEqual([`virtual ${uri}`, "file /p/src/App.java"]);
});
});