test: dedupe discord route fixture setup

This commit is contained in:
Peter Steinberger 2026-03-13 22:23:02 +00:00
parent 97ce1503fd
commit 1b91fa9358
1 changed files with 24 additions and 31 deletions

View File

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