refactor(test): share gateway e2e registry helper

This commit is contained in:
Peter Steinberger
2026-02-15 21:41:18 +00:00
parent 84601bf96b
commit c3812a1ffb
5 changed files with 21 additions and 55 deletions

View File

@@ -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;

View File

@@ -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: {

View File

@@ -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;

View 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: [],
});

View File

@@ -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",