From 1b91fa9358115eec19aeb5c8f191a11b6cfa8ac7 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 13 Mar 2026 22:23:02 +0000 Subject: [PATCH] test: dedupe discord route fixture setup --- src/discord/monitor/route-resolution.test.ts | 55 +++++++++----------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/src/discord/monitor/route-resolution.test.ts b/src/discord/monitor/route-resolution.test.ts index d9ec90177bd..3518355165b 100644 --- a/src/discord/monitor/route-resolution.test.ts +++ b/src/discord/monitor/route-resolution.test.ts @@ -2,12 +2,33 @@ import { describe, expect, it } from "vitest"; import type { OpenClawConfig } from "../../config/config.js"; import type { ResolvedAgentRoute } from "../../routing/resolve-route.js"; import { - resolveDiscordBoundConversationRoute, buildDiscordRoutePeer, + resolveDiscordBoundConversationRoute, resolveDiscordConversationRoute, resolveDiscordEffectiveRoute, } from "./route-resolution.js"; +function buildWorkerBindingConfig(peer: { + kind: "channel" | "direct"; + id: string; +}): OpenClawConfig { + return { + agents: { + list: [{ id: "worker" }], + }, + bindings: [ + { + agentId: "worker", + match: { + channel: "discord", + accountId: "default", + peer, + }, + }, + ], + }; +} + describe("discord route resolution helpers", () => { it("builds a direct peer from DM metadata", () => { expect( @@ -78,21 +99,7 @@ describe("discord route resolution helpers", () => { }); it("resolves the same route shape as the inline Discord route inputs", () => { - const cfg: OpenClawConfig = { - agents: { - list: [{ id: "worker" }], - }, - bindings: [ - { - agentId: "worker", - match: { - channel: "discord", - accountId: "default", - peer: { kind: "channel", id: "c1" }, - }, - }, - ], - }; + const cfg = buildWorkerBindingConfig({ kind: "channel", id: "c1" }); expect( resolveDiscordConversationRoute({ @@ -110,21 +117,7 @@ describe("discord route resolution helpers", () => { }); it("composes route building with effective-route overrides", () => { - const cfg: OpenClawConfig = { - agents: { - list: [{ id: "worker" }], - }, - bindings: [ - { - agentId: "worker", - match: { - channel: "discord", - accountId: "default", - peer: { kind: "direct", id: "user-1" }, - }, - }, - ], - }; + const cfg = buildWorkerBindingConfig({ kind: "direct", id: "user-1" }); expect( resolveDiscordBoundConversationRoute({