mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 13:50:22 +00:00
refactor(test): share gateway e2e registry helper
This commit is contained in:
@@ -5,6 +5,7 @@ import { afterAll, beforeAll, describe, expect, test, vi } from "vitest";
|
|||||||
import type { ChannelPlugin } from "../channels/plugins/types.js";
|
import type { ChannelPlugin } from "../channels/plugins/types.js";
|
||||||
import type { PluginRegistry } from "../plugins/registry.js";
|
import type { PluginRegistry } from "../plugins/registry.js";
|
||||||
import { setRegistry } from "./server.agent.gateway-server-agent.mocks.js";
|
import { setRegistry } from "./server.agent.gateway-server-agent.mocks.js";
|
||||||
|
import { createRegistry } from "./server.e2e-registry-helpers.js";
|
||||||
import {
|
import {
|
||||||
agentCommand,
|
agentCommand,
|
||||||
connectOk,
|
connectOk,
|
||||||
@@ -42,19 +43,6 @@ function expectChannels(call: Record<string, unknown>, channel: string) {
|
|||||||
expect(runContext?.messageChannel).toBe(channel);
|
expect(runContext?.messageChannel).toBe(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
const createRegistry = (channels: PluginRegistry["channels"]): PluginRegistry => ({
|
|
||||||
plugins: [],
|
|
||||||
tools: [],
|
|
||||||
channels,
|
|
||||||
providers: [],
|
|
||||||
gatewayHandlers: {},
|
|
||||||
httpHandlers: [],
|
|
||||||
httpRoutes: [],
|
|
||||||
cliRegistrars: [],
|
|
||||||
services: [],
|
|
||||||
diagnostics: [],
|
|
||||||
});
|
|
||||||
|
|
||||||
const createStubChannelPlugin = (params: {
|
const createStubChannelPlugin = (params: {
|
||||||
id: ChannelPlugin["id"];
|
id: ChannelPlugin["id"];
|
||||||
label: string;
|
label: string;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { BARE_SESSION_RESET_PROMPT } from "../auto-reply/reply/session-reset-pro
|
|||||||
import { emitAgentEvent, registerAgentRunContext } from "../infra/agent-events.js";
|
import { emitAgentEvent, registerAgentRunContext } from "../infra/agent-events.js";
|
||||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js";
|
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js";
|
||||||
import { setRegistry } from "./server.agent.gateway-server-agent.mocks.js";
|
import { setRegistry } from "./server.agent.gateway-server-agent.mocks.js";
|
||||||
|
import { createRegistry } from "./server.e2e-registry-helpers.js";
|
||||||
import {
|
import {
|
||||||
agentCommand,
|
agentCommand,
|
||||||
connectOk,
|
connectOk,
|
||||||
@@ -42,22 +43,6 @@ afterAll(async () => {
|
|||||||
await server.close();
|
await server.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
const _BASE_IMAGE_PNG =
|
|
||||||
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+X3mIAAAAASUVORK5CYII=";
|
|
||||||
|
|
||||||
const createRegistry = (channels: PluginRegistry["channels"]): PluginRegistry => ({
|
|
||||||
plugins: [],
|
|
||||||
tools: [],
|
|
||||||
channels,
|
|
||||||
providers: [],
|
|
||||||
gatewayHandlers: {},
|
|
||||||
httpHandlers: [],
|
|
||||||
httpRoutes: [],
|
|
||||||
cliRegistrars: [],
|
|
||||||
services: [],
|
|
||||||
diagnostics: [],
|
|
||||||
});
|
|
||||||
|
|
||||||
const createMSTeamsPlugin = (params?: { aliases?: string[] }): ChannelPlugin => ({
|
const createMSTeamsPlugin = (params?: { aliases?: string[] }): ChannelPlugin => ({
|
||||||
id: "msteams",
|
id: "msteams",
|
||||||
meta: {
|
meta: {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { afterAll, beforeAll, describe, expect, test, vi } from "vitest";
|
|||||||
import type { ChannelPlugin } from "../channels/plugins/types.js";
|
import type { ChannelPlugin } from "../channels/plugins/types.js";
|
||||||
import type { PluginRegistry } from "../plugins/registry.js";
|
import type { PluginRegistry } from "../plugins/registry.js";
|
||||||
import { setActivePluginRegistry } from "../plugins/runtime.js";
|
import { setActivePluginRegistry } from "../plugins/runtime.js";
|
||||||
|
import { createRegistry } from "./server.e2e-registry-helpers.js";
|
||||||
import {
|
import {
|
||||||
connectOk,
|
connectOk,
|
||||||
installGatewayTestHooks,
|
installGatewayTestHooks,
|
||||||
@@ -41,19 +42,6 @@ vi.mock("./server-plugins.js", async () => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const createRegistry = (channels: PluginRegistry["channels"]): PluginRegistry => ({
|
|
||||||
plugins: [],
|
|
||||||
tools: [],
|
|
||||||
channels,
|
|
||||||
providers: [],
|
|
||||||
gatewayHandlers: {},
|
|
||||||
httpHandlers: [],
|
|
||||||
httpRoutes: [],
|
|
||||||
cliRegistrars: [],
|
|
||||||
services: [],
|
|
||||||
diagnostics: [],
|
|
||||||
});
|
|
||||||
|
|
||||||
const createStubChannelPlugin = (params: {
|
const createStubChannelPlugin = (params: {
|
||||||
id: ChannelPlugin["id"];
|
id: ChannelPlugin["id"];
|
||||||
label: string;
|
label: string;
|
||||||
|
|||||||
17
src/gateway/server.e2e-registry-helpers.ts
Normal file
17
src/gateway/server.e2e-registry-helpers.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import type { PluginRegistry } from "../plugins/registry.js";
|
||||||
|
|
||||||
|
export const createRegistry = (channels: PluginRegistry["channels"]): PluginRegistry => ({
|
||||||
|
plugins: [],
|
||||||
|
tools: [],
|
||||||
|
hooks: [],
|
||||||
|
typedHooks: [],
|
||||||
|
channels,
|
||||||
|
providers: [],
|
||||||
|
gatewayHandlers: {},
|
||||||
|
httpHandlers: [],
|
||||||
|
httpRoutes: [],
|
||||||
|
cliRegistrars: [],
|
||||||
|
services: [],
|
||||||
|
commands: [],
|
||||||
|
diagnostics: [],
|
||||||
|
});
|
||||||
@@ -12,6 +12,7 @@ import { GatewayLockError } from "../infra/gateway-lock.js";
|
|||||||
import { getActivePluginRegistry, setActivePluginRegistry } from "../plugins/runtime.js";
|
import { getActivePluginRegistry, setActivePluginRegistry } from "../plugins/runtime.js";
|
||||||
import { createOutboundTestPlugin } from "../test-utils/channel-plugins.js";
|
import { createOutboundTestPlugin } from "../test-utils/channel-plugins.js";
|
||||||
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js";
|
import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../utils/message-channel.js";
|
||||||
|
import { createRegistry } from "./server.e2e-registry-helpers.js";
|
||||||
import {
|
import {
|
||||||
connectOk,
|
connectOk,
|
||||||
getFreePort,
|
getFreePort,
|
||||||
@@ -67,19 +68,6 @@ const whatsappPlugin = createOutboundTestPlugin({
|
|||||||
label: "WhatsApp",
|
label: "WhatsApp",
|
||||||
});
|
});
|
||||||
|
|
||||||
const createRegistry = (channels: PluginRegistry["channels"]): PluginRegistry => ({
|
|
||||||
plugins: [],
|
|
||||||
tools: [],
|
|
||||||
channels,
|
|
||||||
providers: [],
|
|
||||||
gatewayHandlers: {},
|
|
||||||
httpHandlers: [],
|
|
||||||
httpRoutes: [],
|
|
||||||
cliRegistrars: [],
|
|
||||||
services: [],
|
|
||||||
diagnostics: [],
|
|
||||||
});
|
|
||||||
|
|
||||||
const whatsappRegistry = createRegistry([
|
const whatsappRegistry = createRegistry([
|
||||||
{
|
{
|
||||||
pluginId: "whatsapp",
|
pluginId: "whatsapp",
|
||||||
|
|||||||
Reference in New Issue
Block a user