openpetswithchatandmcp/apps/desktop/tests/plugin-js-host-sdk-dispatch.test.ts
2026-06-19 20:41:23 +00:00

18 lines
1.6 KiB
TypeScript

import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
const desktopRoot = process.env.FAMILIAROS_DESKTOP_ROOT ?? resolve(dirname(fileURLToPath(import.meta.url)), "..");
const pluginJsHostSource = readFileSync(resolve(desktopRoot, "src/plugin-js-host.ts"), "utf8");
const pluginJsHostSdkDispatchSource = readFileSync(resolve(desktopRoot, "src/plugin-js-host-sdk-dispatch.ts"), "utf8");
assert.match(pluginJsHostSource, /from "\.\/plugin-js-host-sdk-dispatch(?:\.js)?"/, "plugin JS host must import the extracted SDK dispatch seam.");
assert.match(pluginJsHostSource, /installPluginJsSdkHandler\(/, "plugin JS host must delegate SDK IPC installation through the extracted seam.");
assert.match(pluginJsHostSdkDispatchSource, /export function installPluginJsSdkHandler/, "plugin JS host SDK dispatch seam must export IPC handler installation.");
assert.match(pluginJsHostSdkDispatchSource, /export const sdkCallHandlers/, "plugin JS host SDK dispatch seam must own the SDK route handler table.");
assert.match(pluginJsHostSdkDispatchSource, /__familiarOSError/, "plugin JS host SDK dispatch seam must preserve FamiliarOS sandbox error shaping.");
assert.match(pluginJsHostSdkDispatchSource, /__familiarOSRunCallback \?\? globalThis\.__openPetsRunCallback/, "plugin JS host SDK dispatch seam must preserve legacy callback bridging.");
assert.match(pluginJsHostSdkDispatchSource, /configDisposers = new WeakMap/, "plugin JS host SDK dispatch seam must own config listener disposer tracking.");
console.error("Plugin JS host SDK dispatch seam validation passed.");