test: share telegram thread binding fixture

This commit is contained in:
Peter Steinberger
2026-04-20 17:51:49 +01:00
parent 873ef6cf45
commit 78cf0e95ad

View File

@@ -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({