



























@@ -1,13 +1,14 @@
11import fs from "node:fs/promises";
22import os from "node:os";
33import path from "node:path";
4-import { describe, expect, test, vi } from "vitest";
4+import { beforeEach, describe, expect, test, vi } from "vitest";
55import { WebSocket } from "ws";
66import type { DeviceIdentity } from "../infra/device-identity.js";
77import { loadOrCreateDeviceIdentity } from "../infra/device-identity.js";
88import { approveDevicePairing, listDevicePairing } from "../infra/device-pairing.js";
99import { approveNodePairing, requestNodePairing } from "../infra/node-pairing.js";
1010import { resolveRestartSentinelPath } from "../infra/restart-sentinel.js";
11+import { getActiveRuntimePluginRegistry } from "../plugins/active-runtime-registry.js";
1112import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js";
1213import type { GatewayClient } from "./client.js";
1314@@ -38,6 +39,38 @@ const FAST_WAIT_OPTS = { timeout: 1_000, interval: 2 } as const;
3839let ws: WebSocket;
3940let port: number;
404142+function installCanvasNodePolicyForTest() {
43+const registry = getActiveRuntimePluginRegistry();
44+if (!registry) {
45+throw new Error("active plugin registry is required for canvas node command tests");
46+}
47+if (
48+(registry.nodeInvokePolicies ?? []).some((entry) =>
49+entry.policy.commands.includes("canvas.snapshot"),
50+)
51+) {
52+return;
53+}
54+registry.nodeInvokePolicies ??= [];
55+registry.nodeInvokePolicies.push({
56+pluginId: "canvas",
57+pluginName: "Canvas",
58+source: "test",
59+rootDir: "extensions/canvas",
60+pluginConfig: {},
61+policy: {
62+commands: ["canvas.snapshot"],
63+defaultPlatforms: ["ios", "android", "macos", "windows", "unknown"],
64+foregroundRestrictedOnIos: true,
65+handle: (ctx) => ctx.invokeNode(),
66+},
67+});
68+}
69+70+beforeEach(() => {
71+installCanvasNodePolicyForTest();
72+});
73+4174installConnectedControlUiServerSuite((started) => {
4275ws = started.ws;
4376port = started.port;
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。