дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 17:21:13 +02:00
128 рядки
4.8 KiB
TypeScript
128 рядки
4.8 KiB
TypeScript
import type { AgentPluginCatalog, AgentPluginState } from "../src/bindings";
|
|
import { expect, stubDesktop, test } from "./fixtures";
|
|
|
|
const makePlugin = (name: string, consentRequired: boolean): AgentPluginState => ({
|
|
plugin: {
|
|
id: name,
|
|
name,
|
|
displayName: name,
|
|
version: "26.1021.31345",
|
|
description: "A plugin with a long description explaining what it can do for the agent in this workspace.",
|
|
marketplace: "context-engineering-marketplace-with-a-long-name",
|
|
source: "claudeUser",
|
|
scope: "user",
|
|
formats: ["claude", "codex", "copilot"],
|
|
rootPath: "/Users/dev/.claude/plugins/cache/context-engineering-marketplace/agent-plugin",
|
|
defaultEnabled: false,
|
|
approxTokens: 2550,
|
|
capabilities: {
|
|
skillCount: 17,
|
|
mcpCount: 1,
|
|
ruleCount: 2,
|
|
subagentCount: 3,
|
|
commandCount: 0,
|
|
hookFiles: consentRequired ? ["hooks/a-very-long-lifecycle-hook-file-name.json"] : [],
|
|
requiresConsent: consentRequired,
|
|
},
|
|
valid: true,
|
|
},
|
|
enabled: !consentRequired,
|
|
origin: consentRequired ? "consent" : "none",
|
|
consentRequired,
|
|
});
|
|
|
|
test("agent plugin metadata stays clear of enable and review controls at narrow widths", async ({
|
|
workbench: page,
|
|
}) => {
|
|
const longName = "Context Engineering with an exceptionally long plugin display name";
|
|
const catalog: AgentPluginCatalog = {
|
|
plugins: [makePlugin(longName, true), makePlugin("Frontend Design", false)],
|
|
marketplaces: [
|
|
{
|
|
id: "official",
|
|
name: "claude-plugins-official",
|
|
source: "example/official",
|
|
scope: "user",
|
|
discovered: true,
|
|
},
|
|
{
|
|
id: "community",
|
|
name: "context-engineering-marketplace-with-a-long-name",
|
|
source: "example/community",
|
|
scope: "user",
|
|
discovered: true,
|
|
},
|
|
],
|
|
projectedSkills: 17,
|
|
projectedMcpServers: 1,
|
|
projectedRules: 2,
|
|
};
|
|
await stubDesktop(page);
|
|
await page.evaluate(async (catalog) => {
|
|
window.__ipc.handlers.agent_plugins_list = () => structuredClone(catalog);
|
|
window.__ipc.handlers.window_open_settings = () => {
|
|
throw { kind: "unavailable", message: "separate settings window disabled in browser test", detail: null };
|
|
};
|
|
const actionsModule = "/src/platform/actions.ts";
|
|
const { executeAction } = await import(/* @vite-ignore */ actionsModule);
|
|
await executeAction("file.settings", "agents.plugins");
|
|
}, catalog);
|
|
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
|
|
await expect(dialog).toBeVisible();
|
|
const group = dialog.getByRole("region", { name: "Claude Code · User" });
|
|
const rows = group.getByRole("listitem");
|
|
await expect(rows).toHaveCount(2);
|
|
const review = rows.first().getByRole("button", { name: "Review & Enable…" });
|
|
await expect(review).toBeVisible();
|
|
for (const width of [1120, 780, 580, 520]) {
|
|
await page.setViewportSize({ width, height: 760 });
|
|
await expect(async () => {
|
|
const fit = await rows.evaluateAll((items) =>
|
|
items.every((row) => {
|
|
const expand = row.querySelector("button[aria-expanded]")!;
|
|
const action = expand.nextElementSibling!;
|
|
const bounds = row.getBoundingClientRect();
|
|
const a = expand.getBoundingClientRect();
|
|
const b = action.getBoundingClientRect();
|
|
const title = expand.querySelector("[title]")!.getBoundingClientRect();
|
|
return (
|
|
title.width > 0 &&
|
|
a.right <= bounds.right + 1 &&
|
|
b.right <= bounds.right + 1 &&
|
|
(a.right <= b.left + 1 || a.bottom <= b.top + 1) &&
|
|
expand.scrollWidth <= expand.clientWidth + 1
|
|
);
|
|
}),
|
|
);
|
|
expect(fit).toBe(true);
|
|
}).toPass();
|
|
if (process.env.SETTINGS_EVIDENCE)
|
|
await dialog.screenshot({
|
|
path: `${process.env.SETTINGS_EVIDENCE}/plugins-${width}.png`,
|
|
animations: "disabled",
|
|
});
|
|
}
|
|
|
|
await rows
|
|
.first()
|
|
.getByRole("button", { name: new RegExp(longName) })
|
|
.click();
|
|
await expect(rows.first().getByText(catalog.plugins[0]!.plugin.marketplace!)).toBeVisible();
|
|
await expect(rows.first().getByText(".claude-plugin · .codex-plugin · .plugin")).toBeVisible();
|
|
await expect(rows.first().getByText(catalog.plugins[0]!.plugin.description, { exact: true })).toBeVisible();
|
|
if (process.env.SETTINGS_EVIDENCE) {
|
|
await page.setViewportSize({ width: 1120, height: 760 });
|
|
await page.evaluate(async () => {
|
|
const themePath = "/src/workbench/theme.ts";
|
|
const { setTheme } = await import(/* @vite-ignore */ themePath);
|
|
await setTheme("dark");
|
|
});
|
|
await dialog.screenshot({
|
|
path: `${process.env.SETTINGS_EVIDENCE}/plugins-expanded-dark.png`,
|
|
animations: "disabled",
|
|
});
|
|
}
|
|
await review.click();
|
|
await expect(page.getByRole("dialog", { name: /Approve Plugin Capabilities/ })).toBeVisible();
|
|
});
|