дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-26 20:46:22 +02:00
Projects can show a custom icon instead of the coloured initials: an SVG or PNG in `.openidea/icon.*` (or IntelliJ's `.idea/icon.*`, with `icon_dark.*` used in dark themes). Change Project Icon… copies the chosen image there and Reset Project Icon removes it. The project context menu in the title bar project widget and on the Welcome screen now offers Change Project Color…, Change Project Icon… and Reset Project Icon for open projects as well as recent ones; the colour picker is a workbench overlay so it opens from any of these places. Fixes #5613
47 рядки
2.1 KiB
TypeScript
47 рядки
2.1 KiB
TypeScript
import { expect, stubDesktop, test } from "./fixtures";
|
|
|
|
const ICON =
|
|
"data:image/svg+xml;base64," +
|
|
Buffer.from(
|
|
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="8" fill="#e44"/></svg>',
|
|
).toString("base64");
|
|
|
|
test("a project's own icon replaces its initials; any project's colour changes from the project widget", async ({
|
|
workbench: page,
|
|
}) => {
|
|
await stubDesktop(page);
|
|
await page.evaluate((icon) => {
|
|
const handlers = window.__ipc.handlers;
|
|
handlers.recent_projects = () => [{ name: "billing", path: "/dev/billing", branch: null, openedAtMs: 1 }];
|
|
handlers.recent_project_groups = () => [];
|
|
handlers.window_open_projects = () => [{ name: "acme-api", root: "/dev/acme-api", remote: null }];
|
|
// An IntelliJ project with `.idea/icon.svg`.
|
|
handlers.fs_read_image = (args) => {
|
|
if ((args as { path: string }).path === "/dev/billing/.idea/icon.svg") return icon;
|
|
throw new Error("not found");
|
|
};
|
|
}, ICON);
|
|
|
|
const widget = page.getByRole("button", { name: "acme-api", exact: true });
|
|
await widget.click();
|
|
const popup = page.getByRole("dialog", { name: "Projects" });
|
|
const billing = popup.getByRole("option", { name: /billing/ });
|
|
await expect(billing.locator("img")).toHaveAttribute("src", ICON);
|
|
// Without an icon the initials stay.
|
|
const acme = popup.getByRole("option", { name: /acme-api/ });
|
|
await expect(acme.locator("img")).toHaveCount(0);
|
|
await expect(acme).toContainText("AA");
|
|
|
|
const avatar = widget.locator("span[aria-hidden]").first();
|
|
const color = () => avatar.evaluate((el) => getComputedStyle(el).backgroundImage);
|
|
const before = await color();
|
|
await acme.click({ button: "right" });
|
|
await page.getByRole("menuitem", { name: "Change Project Color…" }).click();
|
|
const picker = page.getByRole("dialog", { name: "Project Color" });
|
|
await expect(picker).toBeVisible();
|
|
await picker.getByRole("radio", { name: "Violet" }).click();
|
|
await expect(picker).toBeHidden();
|
|
await expect.poll(color).not.toBe(before);
|
|
expect(await page.evaluate(() => localStorage.getItem("openidea.tabColor.v1:/dev/acme-api"))).toBe("7");
|
|
});
|