mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 11:20:36 +00:00
Outbound: scope core send media roots by agent (#17268)
Merged with gates skipped by maintainer request.
Prepared head SHA: 663ac49b3a
This commit is contained in:
committed by
GitHub
parent
b4f16001aa
commit
9adcccadb1
55
src/infra/outbound/outbound-send-service.test.ts
Normal file
55
src/infra/outbound/outbound-send-service.test.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
dispatchChannelMessageAction: vi.fn(),
|
||||
sendMessage: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("../../channels/plugins/message-actions.js", () => ({
|
||||
dispatchChannelMessageAction: (...args: unknown[]) => mocks.dispatchChannelMessageAction(...args),
|
||||
}));
|
||||
|
||||
vi.mock("./message.js", () => ({
|
||||
sendMessage: (...args: unknown[]) => mocks.sendMessage(...args),
|
||||
sendPoll: vi.fn(),
|
||||
}));
|
||||
|
||||
import { executeSendAction } from "./outbound-send-service.js";
|
||||
|
||||
describe("executeSendAction", () => {
|
||||
beforeEach(() => {
|
||||
mocks.dispatchChannelMessageAction.mockReset();
|
||||
mocks.sendMessage.mockReset();
|
||||
});
|
||||
|
||||
it("forwards ctx.agentId to sendMessage on core outbound path", async () => {
|
||||
mocks.dispatchChannelMessageAction.mockResolvedValue(null);
|
||||
mocks.sendMessage.mockResolvedValue({
|
||||
channel: "discord",
|
||||
to: "channel:123",
|
||||
via: "direct",
|
||||
mediaUrl: null,
|
||||
});
|
||||
|
||||
await executeSendAction({
|
||||
ctx: {
|
||||
cfg: {},
|
||||
channel: "discord",
|
||||
params: {},
|
||||
agentId: "work",
|
||||
dryRun: false,
|
||||
},
|
||||
to: "channel:123",
|
||||
message: "hello",
|
||||
});
|
||||
|
||||
expect(mocks.sendMessage).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
agentId: "work",
|
||||
channel: "discord",
|
||||
to: "channel:123",
|
||||
content: "hello",
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user