mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:30:43 +00:00
test: share telegram thread binding fixture
This commit is contained in:
@@ -44,6 +44,27 @@ function createBoundRoute(params: { accountId: string; sessionKey: string; agent
|
||||
} as const;
|
||||
}
|
||||
|
||||
function createForumTopicMessage() {
|
||||
return {
|
||||
message_id: 1,
|
||||
chat: { id: -100200300, type: "supergroup", is_forum: true },
|
||||
message_thread_id: 77,
|
||||
date: 1_700_000_000,
|
||||
text: "hello",
|
||||
from: { id: 42, first_name: "Alice" },
|
||||
} as const;
|
||||
}
|
||||
|
||||
async function buildForumTopicMessageContext(accountId?: string) {
|
||||
return await buildTelegramMessageContextForTest({
|
||||
...(accountId ? { accountId } : {}),
|
||||
sessionRuntime: threadBindingSessionRuntime,
|
||||
message: createForumTopicMessage(),
|
||||
options: { forceWasMentioned: true },
|
||||
resolveGroupActivation: () => true,
|
||||
});
|
||||
}
|
||||
|
||||
describe("buildTelegramMessageContext thread binding override", () => {
|
||||
beforeEach(() => {
|
||||
recordInboundSessionMock.mockClear();
|
||||
@@ -59,19 +80,7 @@ describe("buildTelegramMessageContext thread binding override", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
const ctx = await buildTelegramMessageContextForTest({
|
||||
sessionRuntime: threadBindingSessionRuntime,
|
||||
message: {
|
||||
message_id: 1,
|
||||
chat: { id: -100200300, type: "supergroup", is_forum: true },
|
||||
message_thread_id: 77,
|
||||
date: 1_700_000_000,
|
||||
text: "hello",
|
||||
from: { id: 42, first_name: "Alice" },
|
||||
},
|
||||
options: { forceWasMentioned: true },
|
||||
resolveGroupActivation: () => true,
|
||||
});
|
||||
const ctx = await buildForumTopicMessageContext();
|
||||
|
||||
expect(resolveTelegramConversationRouteMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
@@ -98,20 +107,7 @@ describe("buildTelegramMessageContext thread binding override", () => {
|
||||
}),
|
||||
);
|
||||
|
||||
const ctx = await buildTelegramMessageContextForTest({
|
||||
accountId: "work",
|
||||
sessionRuntime: threadBindingSessionRuntime,
|
||||
message: {
|
||||
message_id: 1,
|
||||
chat: { id: -100200300, type: "supergroup", is_forum: true },
|
||||
message_thread_id: 77,
|
||||
date: 1_700_000_000,
|
||||
text: "hello",
|
||||
from: { id: 42, first_name: "Alice" },
|
||||
},
|
||||
options: { forceWasMentioned: true },
|
||||
resolveGroupActivation: () => true,
|
||||
});
|
||||
const ctx = await buildForumTopicMessageContext("work");
|
||||
|
||||
expect(resolveTelegramConversationRouteMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
|
||||
Reference in New Issue
Block a user