|
7 | 7 | listRegisteredNodeHostCapsAndCommands, |
8 | 8 | } from "./plugin-node-host.js"; |
9 | 9 |
|
| 10 | +const availabilityContext = { config: {}, env: {} }; |
| 11 | + |
10 | 12 | afterEach(() => { |
11 | 13 | resetPluginRuntimeStateForTest(); |
12 | 14 | }); |
@@ -48,12 +50,50 @@ describe("plugin node-host registry", () => { |
48 | 50 | ]; |
49 | 51 | setActivePluginRegistry(registry); |
50 | 52 |
|
51 | | - expect(listRegisteredNodeHostCapsAndCommands()).toEqual({ |
| 53 | + expect(listRegisteredNodeHostCapsAndCommands(availabilityContext)).toEqual({ |
52 | 54 | caps: ["browser", "photos"], |
53 | 55 | commands: ["browser.inspect", "browser.proxy", "photos.proxy"], |
54 | 56 | }); |
55 | 57 | }); |
56 | 58 |
|
| 59 | + it("omits commands and capabilities unavailable in the node-local config", () => { |
| 60 | + const registry = createEmptyPluginRegistry(); |
| 61 | + registry.nodeHostCommands = [ |
| 62 | + { |
| 63 | + pluginId: "browser", |
| 64 | + pluginName: "Browser", |
| 65 | + command: { |
| 66 | + command: "browser.proxy", |
| 67 | + cap: "browser", |
| 68 | + isAvailable: ({ config }) => config.browser?.enabled !== false, |
| 69 | + handle: vi.fn(async () => "{}"), |
| 70 | + }, |
| 71 | + source: "test", |
| 72 | + }, |
| 73 | + { |
| 74 | + pluginId: "photos", |
| 75 | + pluginName: "Photos", |
| 76 | + command: { |
| 77 | + command: "photos.proxy", |
| 78 | + cap: "photos", |
| 79 | + handle: vi.fn(async () => "{}"), |
| 80 | + }, |
| 81 | + source: "test", |
| 82 | + }, |
| 83 | + ]; |
| 84 | + setActivePluginRegistry(registry); |
| 85 | + |
| 86 | + expect( |
| 87 | + listRegisteredNodeHostCapsAndCommands({ |
| 88 | + config: { browser: { enabled: false } }, |
| 89 | + env: {}, |
| 90 | + }), |
| 91 | + ).toEqual({ |
| 92 | + caps: ["photos"], |
| 93 | + commands: ["photos.proxy"], |
| 94 | + }); |
| 95 | + }); |
| 96 | + |
57 | 97 | it("dispatches plugin-declared node-host commands", async () => { |
58 | 98 | const handle = vi.fn(async (paramsJSON?: string | null) => paramsJSON ?? ""); |
59 | 99 | const registry = createEmptyPluginRegistry(); |
|
0 commit comments