fix(scum): gate plugin features by companion support
This commit is contained in:
@@ -18,13 +18,25 @@ describe("SCUM plugin feature module", () => {
|
||||
});
|
||||
|
||||
it("renders plugin-owned configuration, player, reward, state, and trajectory panels with scoped permissions", () => {
|
||||
const nodes: string[] = [];
|
||||
const react = { createElement: (type: unknown, props: Record<string, unknown> | null, ...children: unknown[]) => { if (typeof type === "string") nodes.push(`${type}:${String(props?.["aria-label"] ?? "")}`); return { type, props, children }; } };
|
||||
renderPluginPage(react, { context: { serverInstanceId: "server-1", permissions: ["server.game-client.read", "server.game-client.command", "server.game-client.maintenance"] }, availability: { available: true }, workspace: {} });
|
||||
const nodes: string[] = []; const buttons = new Map<string, boolean>();
|
||||
const react = { createElement: (type: unknown, props: Record<string, unknown> | null, ...children: unknown[]) => { if (typeof type === "string") nodes.push(`${type}:${String(props?.["aria-label"] ?? "")}`); if (type === "button") buttons.set(String(children[0]), Boolean(props?.disabled)); return { type, props, children }; } };
|
||||
renderPluginPage(react, { context: { serverInstanceId: "server-1", permissions: ["server.game-client.read", "server.game-client.command", "server.game-client.maintenance"] }, availability: { available: true, features: [{ key: "config.manage", available: true }, { key: "player.intelligence", available: false, reason: "no event producer" }, { key: "reward.delivery", available: false, reason: "no delivery handler" }, { key: "state.patch", available: false, reason: "no state handler" }, { key: "trajectory.collect", available: false, reason: "no position producer" }] }, workspace: {} });
|
||||
expect(nodes).toContain("section:SCUM 配置工作台");
|
||||
expect(nodes).toContain("section:SCUM 玩家档案");
|
||||
expect(nodes).toContain("section:SCUM 礼物与通知");
|
||||
expect(nodes).toContain("section:SCUM 受控状态修改");
|
||||
expect(nodes).toContain("section:SCUM 地图轨迹");
|
||||
expect(buttons.get("读取配置")).toBe(false);
|
||||
expect(buttons.get("查询玩家")).toBe(true);
|
||||
expect(buttons.get("申请投递")).toBe(true);
|
||||
expect(buttons.get("创建修改申请")).toBe(true);
|
||||
expect(buttons.get("读取轨迹")).toBe(true);
|
||||
});
|
||||
|
||||
it("fails closed when a generally online Companion omits feature availability", () => {
|
||||
const buttons = new Map<string, boolean>();
|
||||
const react = { createElement: (type: unknown, props: Record<string, unknown> | null, ...children: unknown[]) => { if (type === "button") buttons.set(String(children[0]), Boolean(props?.disabled)); return { type, props, children }; } };
|
||||
renderPluginPage(react, { context: { serverInstanceId: "server-1", permissions: ["server.game-client.read", "server.game-client.command", "server.game-client.maintenance"] }, availability: { available: true }, workspace: {} });
|
||||
for (const label of ["读取配置", "查询玩家", "申请投递", "创建修改申请", "读取轨迹"]) expect(buttons.get(label)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user