mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 11:21:23 +00:00
test: remove duplicated scenario scaffolding across runtime tests
This commit is contained in:
@@ -48,16 +48,19 @@ function resolve(params: {
|
||||
});
|
||||
}
|
||||
|
||||
function buildDispatchContextPayload(params: { cfg: OpenClawConfig; message: IMessagePayload }) {
|
||||
const { cfg, message } = params;
|
||||
const groupHistories = new Map();
|
||||
function resolveDispatchDecision(params: {
|
||||
cfg: OpenClawConfig;
|
||||
message: IMessagePayload;
|
||||
groupHistories?: Parameters<typeof resolveIMessageInboundDecision>[0]["groupHistories"];
|
||||
}) {
|
||||
const groupHistories = params.groupHistories ?? new Map();
|
||||
const decision = resolveIMessageInboundDecision({
|
||||
cfg,
|
||||
cfg: params.cfg,
|
||||
accountId: "default",
|
||||
message,
|
||||
message: params.message,
|
||||
opts: {},
|
||||
messageText: message.text ?? "",
|
||||
bodyText: message.text ?? "",
|
||||
messageText: params.message.text ?? "",
|
||||
bodyText: params.message.text ?? "",
|
||||
allowFrom: ["*"],
|
||||
groupAllowFrom: [],
|
||||
groupPolicy: "open",
|
||||
@@ -70,6 +73,12 @@ function buildDispatchContextPayload(params: { cfg: OpenClawConfig; message: IMe
|
||||
if (decision.kind !== "dispatch") {
|
||||
throw new Error("expected dispatch decision");
|
||||
}
|
||||
return { decision, groupHistories };
|
||||
}
|
||||
|
||||
function buildDispatchContextPayload(params: { cfg: OpenClawConfig; message: IMessagePayload }) {
|
||||
const { cfg, message } = params;
|
||||
const { decision, groupHistories } = resolveDispatchDecision({ cfg, message });
|
||||
|
||||
const { ctxPayload } = buildIMessageInboundContext({
|
||||
cfg,
|
||||
@@ -167,25 +176,7 @@ describe("imessage monitor gating + envelope builders", () => {
|
||||
text: "hello",
|
||||
is_group: false,
|
||||
};
|
||||
const decision = resolveIMessageInboundDecision({
|
||||
cfg,
|
||||
accountId: "default",
|
||||
message,
|
||||
opts: {},
|
||||
messageText: message.text ?? "",
|
||||
bodyText: message.text ?? "",
|
||||
allowFrom: ["*"],
|
||||
groupAllowFrom: [],
|
||||
groupPolicy: "open",
|
||||
dmPolicy: "open",
|
||||
storeAllowFrom: [],
|
||||
historyLimit: 0,
|
||||
groupHistories,
|
||||
});
|
||||
expect(decision.kind).toBe("dispatch");
|
||||
if (decision.kind !== "dispatch") {
|
||||
throw new Error("expected dispatch decision");
|
||||
}
|
||||
const { decision } = resolveDispatchDecision({ cfg, message, groupHistories });
|
||||
expect(decision.isGroup).toBe(true);
|
||||
expect(decision.route.sessionKey).toBe("agent:main:imessage:group:2");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user