mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 08:48:37 +00:00
test: dedupe discord route fixture setup
This commit is contained in:
@@ -2,12 +2,33 @@ import { describe, expect, it } from "vitest";
|
|||||||
import type { OpenClawConfig } from "../../config/config.js";
|
import type { OpenClawConfig } from "../../config/config.js";
|
||||||
import type { ResolvedAgentRoute } from "../../routing/resolve-route.js";
|
import type { ResolvedAgentRoute } from "../../routing/resolve-route.js";
|
||||||
import {
|
import {
|
||||||
resolveDiscordBoundConversationRoute,
|
|
||||||
buildDiscordRoutePeer,
|
buildDiscordRoutePeer,
|
||||||
|
resolveDiscordBoundConversationRoute,
|
||||||
resolveDiscordConversationRoute,
|
resolveDiscordConversationRoute,
|
||||||
resolveDiscordEffectiveRoute,
|
resolveDiscordEffectiveRoute,
|
||||||
} from "./route-resolution.js";
|
} 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", () => {
|
describe("discord route resolution helpers", () => {
|
||||||
it("builds a direct peer from DM metadata", () => {
|
it("builds a direct peer from DM metadata", () => {
|
||||||
expect(
|
expect(
|
||||||
@@ -78,21 +99,7 @@ describe("discord route resolution helpers", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("resolves the same route shape as the inline Discord route inputs", () => {
|
it("resolves the same route shape as the inline Discord route inputs", () => {
|
||||||
const cfg: OpenClawConfig = {
|
const cfg = buildWorkerBindingConfig({ kind: "channel", id: "c1" });
|
||||||
agents: {
|
|
||||||
list: [{ id: "worker" }],
|
|
||||||
},
|
|
||||||
bindings: [
|
|
||||||
{
|
|
||||||
agentId: "worker",
|
|
||||||
match: {
|
|
||||||
channel: "discord",
|
|
||||||
accountId: "default",
|
|
||||||
peer: { kind: "channel", id: "c1" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
resolveDiscordConversationRoute({
|
resolveDiscordConversationRoute({
|
||||||
@@ -110,21 +117,7 @@ describe("discord route resolution helpers", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("composes route building with effective-route overrides", () => {
|
it("composes route building with effective-route overrides", () => {
|
||||||
const cfg: OpenClawConfig = {
|
const cfg = buildWorkerBindingConfig({ kind: "direct", id: "user-1" });
|
||||||
agents: {
|
|
||||||
list: [{ id: "worker" }],
|
|
||||||
},
|
|
||||||
bindings: [
|
|
||||||
{
|
|
||||||
agentId: "worker",
|
|
||||||
match: {
|
|
||||||
channel: "discord",
|
|
||||||
accountId: "default",
|
|
||||||
peer: { kind: "direct", id: "user-1" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
resolveDiscordBoundConversationRoute({
|
resolveDiscordBoundConversationRoute({
|
||||||
|
|||||||
Reference in New Issue
Block a user