mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 07:57:39 +00:00
test: remove duplicate target-resolution cases from outbound suite
This commit is contained in:
@@ -36,7 +36,7 @@ import {
|
|||||||
normalizeOutboundPayloads,
|
normalizeOutboundPayloads,
|
||||||
normalizeOutboundPayloadsForJson,
|
normalizeOutboundPayloadsForJson,
|
||||||
} from "./payloads.js";
|
} from "./payloads.js";
|
||||||
import { resolveOutboundTarget, resolveSessionDeliveryTarget } from "./targets.js";
|
import { resolveOutboundTarget } from "./targets.js";
|
||||||
|
|
||||||
describe("delivery-queue", () => {
|
describe("delivery-queue", () => {
|
||||||
let tmpDir: string;
|
let tmpDir: string;
|
||||||
@@ -981,108 +981,3 @@ describe("resolveOutboundTarget", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("resolveSessionDeliveryTarget", () => {
|
|
||||||
it("derives implicit delivery from the last route", () => {
|
|
||||||
const resolved = resolveSessionDeliveryTarget({
|
|
||||||
entry: {
|
|
||||||
sessionId: "sess-1",
|
|
||||||
updatedAt: 1,
|
|
||||||
lastChannel: " whatsapp ",
|
|
||||||
lastTo: " +1555 ",
|
|
||||||
lastAccountId: " acct-1 ",
|
|
||||||
},
|
|
||||||
requestedChannel: "last",
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(resolved).toEqual({
|
|
||||||
channel: "whatsapp",
|
|
||||||
to: "+1555",
|
|
||||||
accountId: "acct-1",
|
|
||||||
threadId: undefined,
|
|
||||||
threadIdExplicit: false,
|
|
||||||
mode: "implicit",
|
|
||||||
lastChannel: "whatsapp",
|
|
||||||
lastTo: "+1555",
|
|
||||||
lastAccountId: "acct-1",
|
|
||||||
lastThreadId: undefined,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("prefers explicit targets without reusing lastTo", () => {
|
|
||||||
const resolved = resolveSessionDeliveryTarget({
|
|
||||||
entry: {
|
|
||||||
sessionId: "sess-2",
|
|
||||||
updatedAt: 1,
|
|
||||||
lastChannel: "whatsapp",
|
|
||||||
lastTo: "+1555",
|
|
||||||
},
|
|
||||||
requestedChannel: "telegram",
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(resolved).toEqual({
|
|
||||||
channel: "telegram",
|
|
||||||
to: undefined,
|
|
||||||
accountId: undefined,
|
|
||||||
threadId: undefined,
|
|
||||||
threadIdExplicit: false,
|
|
||||||
mode: "implicit",
|
|
||||||
lastChannel: "whatsapp",
|
|
||||||
lastTo: "+1555",
|
|
||||||
lastAccountId: undefined,
|
|
||||||
lastThreadId: undefined,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("allows mismatched lastTo when configured", () => {
|
|
||||||
const resolved = resolveSessionDeliveryTarget({
|
|
||||||
entry: {
|
|
||||||
sessionId: "sess-3",
|
|
||||||
updatedAt: 1,
|
|
||||||
lastChannel: "whatsapp",
|
|
||||||
lastTo: "+1555",
|
|
||||||
},
|
|
||||||
requestedChannel: "telegram",
|
|
||||||
allowMismatchedLastTo: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(resolved).toEqual({
|
|
||||||
channel: "telegram",
|
|
||||||
to: "+1555",
|
|
||||||
accountId: undefined,
|
|
||||||
threadId: undefined,
|
|
||||||
threadIdExplicit: false,
|
|
||||||
mode: "implicit",
|
|
||||||
lastChannel: "whatsapp",
|
|
||||||
lastTo: "+1555",
|
|
||||||
lastAccountId: undefined,
|
|
||||||
lastThreadId: undefined,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("falls back to a provided channel when requested is unsupported", () => {
|
|
||||||
const resolved = resolveSessionDeliveryTarget({
|
|
||||||
entry: {
|
|
||||||
sessionId: "sess-4",
|
|
||||||
updatedAt: 1,
|
|
||||||
lastChannel: "whatsapp",
|
|
||||||
lastTo: "+1555",
|
|
||||||
},
|
|
||||||
requestedChannel: "webchat",
|
|
||||||
fallbackChannel: "slack",
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(resolved).toEqual({
|
|
||||||
channel: "slack",
|
|
||||||
to: undefined,
|
|
||||||
accountId: undefined,
|
|
||||||
threadId: undefined,
|
|
||||||
threadIdExplicit: false,
|
|
||||||
mode: "implicit",
|
|
||||||
lastChannel: "whatsapp",
|
|
||||||
lastTo: "+1555",
|
|
||||||
lastAccountId: undefined,
|
|
||||||
lastThreadId: undefined,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|||||||
Reference in New Issue
Block a user