mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-16 03:31:10 +00:00
Tests: move cron session-scoping delivery to dispatch seam
This commit is contained in:
@@ -249,40 +249,6 @@ describe("runCronIsolatedAgentTurn", () => {
|
||||
setupIsolatedAgentTurnMocks({ fast: true });
|
||||
});
|
||||
|
||||
it("delivers explicit targets directly with per-channel-peer session scoping", async () => {
|
||||
await withTelegramAnnounceFixture(async ({ home, storePath, deps }) => {
|
||||
mockAgentPayloads([{ text: "hello from cron" }]);
|
||||
|
||||
const res = await runCronIsolatedAgentTurn({
|
||||
cfg: makeCfg(home, storePath, {
|
||||
session: {
|
||||
store: storePath,
|
||||
mainKey: "main",
|
||||
dmScope: "per-channel-peer",
|
||||
},
|
||||
channels: {
|
||||
telegram: { botToken: "t-1" },
|
||||
},
|
||||
}),
|
||||
deps,
|
||||
job: {
|
||||
...makeJob({ kind: "agentTurn", message: "do it" }),
|
||||
delivery: { mode: "announce", channel: "telegram", to: "123" },
|
||||
},
|
||||
message: "do it",
|
||||
sessionKey: "cron:job-1",
|
||||
lane: "cron",
|
||||
});
|
||||
|
||||
expectDeliveredOk(res);
|
||||
expect(runSubagentAnnounceFlow).not.toHaveBeenCalled();
|
||||
expectDirectTelegramDelivery(deps, {
|
||||
chatId: "123",
|
||||
text: "hello from cron",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("routes threaded announce targets through direct delivery", async () => {
|
||||
await withTempHome(async (home) => {
|
||||
const storePath = await writeSessionStore(home, { lastProvider: "webchat", lastTo: "" });
|
||||
|
||||
@@ -67,6 +67,7 @@ vi.mock("./subagent-followup.runtime.js", () => ({
|
||||
import { countActiveDescendantRuns } from "../../agents/subagent-registry-read.js";
|
||||
import { callGateway } from "../../gateway/call.runtime.js";
|
||||
import { deliverOutboundPayloads } from "../../infra/outbound/deliver.js";
|
||||
import { buildOutboundSessionContext } from "../../infra/outbound/session-context.js";
|
||||
import { enqueueSystemEvent } from "../../infra/system-events.js";
|
||||
import { shouldEnqueueCronMainSummary } from "../heartbeat-policy.js";
|
||||
import {
|
||||
@@ -690,6 +691,27 @@ describe("dispatchCronDelivery — double-announce guard", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("builds outbound session context from the run session key under per-channel-peer scoping", async () => {
|
||||
vi.mocked(countActiveDescendantRuns).mockReturnValue(0);
|
||||
vi.mocked(isLikelyInterimCronMessage).mockReturnValue(false);
|
||||
|
||||
const params = makeBaseParams({ synthesizedText: "hello from cron" });
|
||||
params.cfgWithAgentDefaults = {
|
||||
session: { dmScope: "per-channel-peer" },
|
||||
} as never;
|
||||
params.agentSessionKey = "agent:main:telegram:123456";
|
||||
|
||||
const state = await dispatchCronDelivery(params);
|
||||
|
||||
expect(state.result).toBeUndefined();
|
||||
expect(state.delivered).toBe(true);
|
||||
expect(buildOutboundSessionContext).toHaveBeenCalledWith({
|
||||
cfg: params.cfgWithAgentDefaults,
|
||||
agentId: "main",
|
||||
sessionKey: "agent:main:telegram:123456",
|
||||
});
|
||||
});
|
||||
|
||||
it("suppresses NO_REPLY payload with surrounding whitespace", async () => {
|
||||
vi.mocked(countActiveDescendantRuns).mockReturnValue(0);
|
||||
vi.mocked(isLikelyInterimCronMessage).mockReturnValue(false);
|
||||
|
||||
Reference in New Issue
Block a user