mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 17:24:58 +00:00
Channels: add thread-aware model overrides
This commit is contained in:
@@ -1,53 +0,0 @@
|
||||
import { ChannelType } from "discord-api-types/v10";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { registerDiscordComponentEntries } from "./components-registry.js";
|
||||
import { sendDiscordComponentMessage } from "./send.components.js";
|
||||
import { makeDiscordRest } from "./send.test-harness.js";
|
||||
|
||||
const loadConfigMock = vi.hoisted(() => vi.fn(() => ({ session: { dmScope: "main" } })));
|
||||
|
||||
vi.mock("../config/config.js", async () => {
|
||||
const actual = await vi.importActual<typeof import("../config/config.js")>("../config/config.js");
|
||||
return {
|
||||
...actual,
|
||||
loadConfig: () => loadConfigMock(),
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("./components-registry.js", () => ({
|
||||
registerDiscordComponentEntries: vi.fn(),
|
||||
}));
|
||||
|
||||
describe("sendDiscordComponentMessage", () => {
|
||||
const registerMock = vi.mocked(registerDiscordComponentEntries);
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it("maps DM channel targets to direct-session component entries", async () => {
|
||||
const { rest, postMock, getMock } = makeDiscordRest();
|
||||
getMock.mockResolvedValueOnce({
|
||||
type: ChannelType.DM,
|
||||
recipients: [{ id: "user-1" }],
|
||||
});
|
||||
postMock.mockResolvedValueOnce({ id: "msg1", channel_id: "dm-1" });
|
||||
|
||||
await sendDiscordComponentMessage(
|
||||
"channel:dm-1",
|
||||
{
|
||||
blocks: [{ type: "actions", buttons: [{ label: "Tap" }] }],
|
||||
},
|
||||
{
|
||||
rest,
|
||||
token: "t",
|
||||
sessionKey: "agent:main:discord:channel:dm-1",
|
||||
agentId: "main",
|
||||
},
|
||||
);
|
||||
|
||||
expect(registerMock).toHaveBeenCalledTimes(1);
|
||||
const args = registerMock.mock.calls[0]?.[0];
|
||||
expect(args?.entries[0]?.sessionKey).toBe("agent:main:main");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user