fix(plugins): 插件管理 - 修正官方应用插件的分类与状态显示

AI 审美分析和剪辑工作台在管理页显示为"已停用",原因是三处插件
分类清单不一致:

- 后端 officialApplicationPolicies 缺少 editor-shell
- 管理页 officialApplicationIds 同时缺少 ai-art-critique 和 editor-shell
- 用户插件页另有一份重复清单

后端把这两个插件当作系统协议处理(Kind=protocol),platformAvailable
回退为 false,于是返回"管理员已停用该插件",管理页据此渲染成"已停用"。

修复:

- 后端补上 editor-shell 应用策略(权威修复,决定平台可用性)
- 前端抽取唯一清单 OFFICIAL_APPLICATION_PLUGIN_IDS,管理页与用户插件页
  共用,删除两份重复实现
- 补前后端回归测试,锁定这 8 个官方应用插件

验证:tsc --noEmit 通过;前端 17 项测试通过;后端 TestEditorShell* 与
既有插件测试通过;前后端镜像构建通过。
This commit is contained in:
jay
2026-09-12 21:16:42 +08:00
parent 4eeef3cfd8
commit fbd6962d8f
7 changed files with 139 additions and 15 deletions

View File

@@ -0,0 +1,52 @@
import { describe, expect, test } from "bun:test";
import { readFileSync } from "node:fs";
import { resolve } from "node:path";
import {
OFFICIAL_APPLICATION_PLUGIN_IDS,
isOfficialApplicationPluginId,
} from "../src/lib/plugins/official-applications";
describe("official application plugin classification", () => {
test("covers every built-in application plugin, including editor and art critique", () => {
// Regression: the admin plugin page kept its own list and missed these
// two, so both rendered as disabled system protocols.
expect(isOfficialApplicationPluginId("editor-shell")).toBe(true);
expect(isOfficialApplicationPluginId("ai-art-critique")).toBe(true);
expect(isOfficialApplicationPluginId("portrait-clearance")).toBe(true);
expect(isOfficialApplicationPluginId("media-conversion")).toBe(true);
expect(isOfficialApplicationPluginId("prompt-optimizer")).toBe(true);
expect(isOfficialApplicationPluginId("eagle-asset-connector")).toBe(true);
expect(isOfficialApplicationPluginId("runninghub-workflow-provider")).toBe(true);
expect(isOfficialApplicationPluginId("comfyui-workflow-provider")).toBe(true);
});
test("does not treat uploaded or unknown plugins as official applications", () => {
expect(isOfficialApplicationPluginId("some-uploaded-plugin")).toBe(false);
expect(isOfficialApplicationPluginId("")).toBe(false);
});
test("exposes a single de-duplicated id list", () => {
const ids = [...OFFICIAL_APPLICATION_PLUGIN_IDS];
expect(new Set(ids).size).toBe(ids.length);
expect(ids.length).toBe(8);
});
test("both plugin pages consume the shared list instead of a local copy", () => {
const adminPage = readFileSync(
resolve(import.meta.dir, "../src/pages/admin/plugins/plugins-page.tsx"),
"utf8",
);
const userPage = readFileSync(
resolve(import.meta.dir, "../src/pages/plugins/index.tsx"),
"utf8",
);
expect(adminPage).toContain("isOfficialApplicationPluginId");
expect(userPage).toContain("isOfficialApplicationPluginId");
// No page may reintroduce a hand-maintained id array.
expect(adminPage).not.toContain("const officialApplicationIds = new Set([");
expect(userPage).not.toContain("function isOfficialApplicationPlugin(pluginId: string) {");
});
});