Файли
openidea/src/platform/projectPresentation.test.ts
T
l0ng-ai 9d670e6262 feat(project-tree): enrich JVM project view icons (#512)
Project rows only showed generic folder and filename icons, so JVM modules, packages and declarations looked alike.

Rows now show Maven and Gradle project and module icons, packages, Spring configuration and Boot application classes, runnable classes, test classes, Java and Kotlin declaration types, and generated, compiled and javadoc output folders. Editor tabs, Goto File and Recent Files use the same resolver. Types come from a bounded syntax parse of visible files, served locally and over remote RPC.

Spring stereotypes keep their ordinary type icons, and .class files stay binary.

Fixes #347
2026-10-31 10:40:24 +08:00

64 рядки
2.1 KiB
TypeScript

import { describe, it, expect } from "vitest";
import { buildPresentation, moduleFolderIcon } from "./projectPresentation";
import type { BuildModel } from "./ipc";
const model = (partial: unknown) => ({ maven: null, gradle: null, ...(partial as object) }) as BuildModel;
describe("build presentation context", () => {
it.each(["maven", "gradle"] as const)("uses distinct %s root and nested module glyphs", (tool) => {
const modules = new Map([
["", tool],
["app", tool],
]);
expect(moduleFolderIcon("", true, modules)).toBe(`${tool}-project`);
expect(moduleFolderIcon("app", false, modules)).toBe(`${tool}-module`);
expect(moduleFolderIcon("plain", false, modules)).toBeNull();
});
it("includes Maven aggregators and modules without source roots", () => {
const context = buildPresentation(
model({
maven: {
projects: [
{ dir: "", dependencies: [], plugins: [] },
{ dir: "app", dependencies: [{ groupId: "org.springframework.boot" }], plugins: [] },
],
},
}),
);
expect([...context.modules]).toEqual([
["", "maven"],
["app", "maven"],
]);
expect(context.spring).toBe(true);
});
it("includes Gradle root and nested project directories", () => {
const context = buildPresentation(
model({
gradle: {
projects: [
{ dir: "", tasks: [] },
{ dir: "lib/core", tasks: [] },
],
},
}),
);
expect([...context.modules]).toEqual([
["", "gradle"],
["lib/core", "gradle"],
]);
expect(context.spring).toBe(false);
});
it("detects Spring build plugins and Gradle Boot tasks", () => {
expect(
buildPresentation(
model({
maven: { projects: [{ dir: "", dependencies: [], plugins: [{ groupId: "org.springframework.boot" }] }] },
}),
).spring,
).toBe(true);
expect(buildPresentation(model({ gradle: { projects: [{ dir: "", tasks: [{ name: "bootRun" }] }] } })).spring).toBe(
true,
);
});
it("keeps plain folders plain", () => expect(buildPresentation(model({})).modules.size).toBe(0));
});