mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 00:10:42 +00:00
test: tighten telegram context assertions
This commit is contained in:
@@ -208,11 +208,13 @@ describe("buildTelegramMessageContext group sessions without forum", () => {
|
||||
from: { id: 42, first_name: "Alice" },
|
||||
});
|
||||
|
||||
expect(ctx).not.toBeNull();
|
||||
if (!ctx) {
|
||||
throw new Error("expected Telegram non-forum group context");
|
||||
}
|
||||
// Session key should NOT include :topic:42
|
||||
expect(ctx?.ctxPayload?.SessionKey).toBe("agent:main:telegram:group:-1001234567890");
|
||||
expect(ctx.ctxPayload.SessionKey).toBe("agent:main:telegram:group:-1001234567890");
|
||||
// MessageThreadId should be undefined (not a forum)
|
||||
expect(ctx?.ctxPayload?.MessageThreadId).toBeUndefined();
|
||||
expect(ctx.ctxPayload.MessageThreadId).toBeUndefined();
|
||||
});
|
||||
|
||||
it("keeps same session for regular group with and without message_thread_id", async () => {
|
||||
|
||||
@@ -67,7 +67,9 @@ describe("buildTelegramMessageContext DM topic threadId in deliveryContext (#889
|
||||
},
|
||||
});
|
||||
|
||||
expect(ctx?.ctxPayload).toBeDefined();
|
||||
if (!ctx?.ctxPayload) {
|
||||
throw new Error("expected Telegram DM topic context payload");
|
||||
}
|
||||
expect(recordInboundSessionMock).toHaveBeenCalled();
|
||||
|
||||
expectRecordedRoute({ to: "telegram:1234", threadId: "42" });
|
||||
@@ -80,7 +82,9 @@ describe("buildTelegramMessageContext DM topic threadId in deliveryContext (#889
|
||||
},
|
||||
});
|
||||
|
||||
expect(ctx?.ctxPayload).toBeDefined();
|
||||
if (!ctx?.ctxPayload) {
|
||||
throw new Error("expected Telegram DM context payload");
|
||||
}
|
||||
expect(recordInboundSessionMock).toHaveBeenCalled();
|
||||
|
||||
expectRecordedRoute({ to: "telegram:1234" });
|
||||
@@ -97,7 +101,9 @@ describe("buildTelegramMessageContext DM topic threadId in deliveryContext (#889
|
||||
resolveGroupActivation: () => true,
|
||||
});
|
||||
|
||||
expect(ctx?.ctxPayload).toBeDefined();
|
||||
if (!ctx?.ctxPayload) {
|
||||
throw new Error("expected Telegram forum topic context payload");
|
||||
}
|
||||
expect(recordInboundSessionMock).toHaveBeenCalled();
|
||||
|
||||
expectRecordedRoute({ to: "telegram:-1001234567890:topic:99", threadId: "99" });
|
||||
@@ -113,7 +119,9 @@ describe("buildTelegramMessageContext DM topic threadId in deliveryContext (#889
|
||||
resolveGroupActivation: () => true,
|
||||
});
|
||||
|
||||
expect(ctx?.ctxPayload).toBeDefined();
|
||||
if (!ctx?.ctxPayload) {
|
||||
throw new Error("expected Telegram General topic context payload");
|
||||
}
|
||||
expect(recordInboundSessionMock).toHaveBeenCalled();
|
||||
|
||||
expectRecordedRoute({ to: "telegram:-1001234567890:topic:1", threadId: "1" });
|
||||
|
||||
@@ -56,7 +56,9 @@ describe("buildTelegramMessageContext requireMention precedence", () => {
|
||||
}),
|
||||
});
|
||||
|
||||
expect(ctx).not.toBeNull();
|
||||
if (!ctx) {
|
||||
throw new Error("expected Telegram context when topic disables requireMention");
|
||||
}
|
||||
});
|
||||
|
||||
it("lets explicit topic requireMention=false override mention activation", async () => {
|
||||
@@ -72,7 +74,9 @@ describe("buildTelegramMessageContext requireMention precedence", () => {
|
||||
}),
|
||||
});
|
||||
|
||||
expect(ctx?.ctxPayload).toBeDefined();
|
||||
if (!ctx?.ctxPayload) {
|
||||
throw new Error("expected Telegram context payload when topic disables requireMention");
|
||||
}
|
||||
expect(resolveGroupActivation).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
chatId: -1001234567890,
|
||||
@@ -107,6 +111,8 @@ describe("buildTelegramMessageContext requireMention precedence", () => {
|
||||
}),
|
||||
});
|
||||
|
||||
expect(ctx).not.toBeNull();
|
||||
if (!ctx) {
|
||||
throw new Error("expected Telegram context when topic config keeps agent");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -59,7 +59,11 @@ describe("sticker-cache", () => {
|
||||
};
|
||||
|
||||
stickerCache.cacheSticker(sticker);
|
||||
expect(stickerCache.getCachedSticker("unique123")).not.toBeNull();
|
||||
const cachedSticker = stickerCache.getCachedSticker("unique123");
|
||||
if (!cachedSticker) {
|
||||
throw new Error("expected cached Telegram sticker");
|
||||
}
|
||||
expect(cachedSticker.fileUniqueId).toBe("unique123");
|
||||
|
||||
jsonStoreMocks.store.value = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user