Files
openclaw-zero-token/gateway/server.minimal-channel-pin.test.ts
sjhu 571e14a236 feat: upgrade to upstream v2026.3.28
Major upgrade from e26988a38 to upstream v2026.3.28 (f9b107928).
Key changes:
- Upstream src/, ui/, extensions/ (89 bundled extensions)
- Zero-token web providers preserved in src/zero-token/
- AskOnce plugin restored and registered as CLI command
- Added missing packages: @anthropic-ai/vertex-sdk, @modelcontextprotocol/sdk
- Fixed tsconfig rootDir, skipLibCheck for plugin-sdk DTS build
- Added askonce to bundled plugin metadata and package.json exports
- Fixed AskOnce CLI command registration (missing commands metadata)
- Restored AskOnce adapter imports (correct 5-level relative paths)
- Removed stale migration artifacts from root directory
2026-03-30 17:58:12 +08:00

58 lines
1.8 KiB
TypeScript

import { afterEach, expect, test } from "vitest";
import { getChannelPlugin } from "../channels/plugins/index.js";
import {
getActivePluginRegistry,
resetPluginRuntimeStateForTest,
setActivePluginRegistry,
} from "../plugins/runtime.js";
import { createOutboundTestPlugin } from "../test-utils/channel-plugins.js";
import { createRegistry } from "./server.e2e-registry-helpers.js";
import { getFreePort, installGatewayTestHooks, startGatewayServer } from "./test-helpers.js";
installGatewayTestHooks({ scope: "suite" });
const whatsappOutbound = {
deliveryMode: "direct" as const,
sendText: async () => ({ channel: "whatsapp", messageId: "text-1" }),
sendMedia: async () => ({ channel: "whatsapp", messageId: "media-1" }),
};
const replacementPlugin = createOutboundTestPlugin({
id: "whatsapp",
outbound: whatsappOutbound,
label: "WhatsApp Replacement",
});
const replacementRegistry = createRegistry([
{
pluginId: "whatsapp",
source: "test-replacement",
plugin: replacementPlugin,
},
]);
afterEach(() => {
resetPluginRuntimeStateForTest();
});
test("minimal gateway tracks later channel registry updates", async () => {
const prevRegistry = getActivePluginRegistry();
const prevVitest = process.env.VITEST;
resetPluginRuntimeStateForTest();
process.env.VITEST = "1";
const port = await getFreePort();
const server = await startGatewayServer(port);
try {
expect(getChannelPlugin("whatsapp")).not.toBe(replacementPlugin);
setActivePluginRegistry(replacementRegistry);
expect(getChannelPlugin("whatsapp")).toBe(replacementPlugin);
} finally {
await server.close();
process.env.VITEST = prevVitest;
resetPluginRuntimeStateForTest();
if (prevRegistry) {
setActivePluginRegistry(prevRegistry);
}
}
});