test(gateway): share plugin approval no-route context

This commit is contained in:
Vincent Koc
2026-04-12 17:59:17 +01:00
parent 2c5290a7b1
commit b35becfb1d

View File

@@ -32,6 +32,14 @@ function createMockOptions(
} as unknown as GatewayRequestHandlerOptions;
}
function createNoExecApprovalContext(): GatewayRequestHandlerOptions["context"] {
return {
broadcast: vi.fn(),
logGateway: { error: vi.fn(), warn: vi.fn(), info: vi.fn(), debug: vi.fn() },
hasExecApprovalClients: () => false,
} as unknown as GatewayRequestHandlerOptions["context"];
}
describe("createPluginApprovalHandlers", () => {
let manager: ExecApprovalManager<PluginApprovalRequestPayload>;
@@ -126,11 +134,7 @@ describe("createPluginApprovalHandlers", () => {
description: "Desc",
},
{
context: {
broadcast: vi.fn(),
logGateway: { error: vi.fn(), warn: vi.fn(), info: vi.fn(), debug: vi.fn() },
hasExecApprovalClients: () => false,
} as unknown as GatewayRequestHandlerOptions["context"],
context: createNoExecApprovalContext(),
},
);
await handlers["plugin.approval.request"](opts);
@@ -294,11 +298,7 @@ describe("createPluginApprovalHandlers", () => {
"plugin.approval.request",
{ title: "T", description: "D" },
{
context: {
broadcast: vi.fn(),
logGateway: { error: vi.fn(), warn: vi.fn(), info: vi.fn(), debug: vi.fn() },
hasExecApprovalClients: () => false,
} as unknown as GatewayRequestHandlerOptions["context"],
context: createNoExecApprovalContext(),
},
);