@@ -6,10 +6,11 @@ import {
|
6 | 6 | import type { TelegramGroupConfig } from "openclaw/plugin-sdk/config-contracts"; |
7 | 7 | import type { GetReplyOptions, MsgContext } from "openclaw/plugin-sdk/reply-runtime"; |
8 | 8 | import { sanitizeTerminalText } from "openclaw/plugin-sdk/test-fixtures"; |
9 | | -import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; |
| 9 | +import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; |
10 | 10 | import type { TelegramBotOptions } from "./bot.types.js"; |
11 | 11 | import type { TelegramGetChat } from "./bot/types.js"; |
12 | 12 | const harness = await import("./bot.create-telegram-bot.test-harness.js"); |
| 13 | +const pluginStateTestRuntime = await import("openclaw/plugin-sdk/plugin-state-test-runtime"); |
13 | 14 | const conversationRuntime = await import("openclaw/plugin-sdk/conversation-runtime"); |
14 | 15 | const configMutation = await import("openclaw/plugin-sdk/config-mutation"); |
15 | 16 | const sessionStoreRuntime = await import("openclaw/plugin-sdk/session-store-runtime"); |
@@ -57,6 +58,7 @@ const {
|
57 | 58 | } = await import("./bot-core.js"); |
58 | 59 | const { resolveTelegramConversationRoute } = await import("./conversation-route.js"); |
59 | 60 | const { clearAccountThrottlersForTest } = await import("./account-throttler.js"); |
| 61 | +const messageDispatchDedupe = await import("./message-dispatch-dedupe.js"); |
60 | 62 | const { |
61 | 63 | buildTelegramGroupFrom, |
62 | 64 | buildTelegramThreadParams, |
@@ -232,7 +234,11 @@ describe("createTelegramBot", () => {
|
232 | 234 | process.env.TZ = ORIGINAL_TZ; |
233 | 235 | } |
234 | 236 | }); |
235 | | -beforeEach(() => { |
| 237 | +afterEach(() => { |
| 238 | +messageDispatchDedupe.setTelegramMessageDispatchDedupeStoreForTest(undefined); |
| 239 | +pluginStateTestRuntime.resetPluginStateStoreForTests(); |
| 240 | +}); |
| 241 | +beforeEach(async () => { |
236 | 242 | resetTelegramForumFlagCacheForTest(); |
237 | 243 | clearAccountThrottlersForTest(); |
238 | 244 | throttlerSpy.mockReset(); |
@@ -244,6 +250,15 @@ describe("createTelegramBot", () => {
|
244 | 250 | ...opts, |
245 | 251 | telegramDeps: telegramBotDepsForTest, |
246 | 252 | }); |
| 253 | +pluginStateTestRuntime.resetPluginStateStoreForTests({ closeDatabase: false }); |
| 254 | +const store = pluginStateTestRuntime.createPluginStateKeyedStoreForTests("telegram", { |
| 255 | +namespace: messageDispatchDedupe.TELEGRAM_MESSAGE_DISPATCH_DEDUPE_NAMESPACE, |
| 256 | +maxEntries: messageDispatchDedupe.TELEGRAM_MESSAGE_DISPATCH_DEDUPE_MAX_ENTRIES, |
| 257 | +}) as NonNullable< |
| 258 | +Parameters<typeof messageDispatchDedupe.setTelegramMessageDispatchDedupeStoreForTest>[0] |
| 259 | +>; |
| 260 | +await store.clear(); |
| 261 | +messageDispatchDedupe.setTelegramMessageDispatchDedupeStoreForTest(store); |
247 | 262 | }); |
248 | 263 | |
249 | 264 | // groupPolicy tests |
|