mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-21 05:32:53 +00:00
test(telegram): skip session persistence in message-context harness
This commit is contained in:
@@ -70,8 +70,10 @@ let buildTelegramMessageContextLoader:
|
||||
| typeof import("./bot-message-context.js").buildTelegramMessageContext
|
||||
| undefined;
|
||||
let vitestModuleLoader: Promise<typeof import("vitest")> | undefined;
|
||||
let messageContextMocksInstalled = false;
|
||||
|
||||
async function loadBuildTelegramMessageContext() {
|
||||
await installMessageContextTestMocks();
|
||||
if (!buildTelegramMessageContextLoader) {
|
||||
({ buildTelegramMessageContext: buildTelegramMessageContextLoader } =
|
||||
await import("./bot-message-context.js"));
|
||||
@@ -83,3 +85,27 @@ async function loadVitestModule() {
|
||||
vitestModuleLoader ??= import("vitest");
|
||||
return await vitestModuleLoader;
|
||||
}
|
||||
|
||||
async function installMessageContextTestMocks() {
|
||||
if (messageContextMocksInstalled) {
|
||||
return;
|
||||
}
|
||||
const { vi } = await loadVitestModule();
|
||||
vi.doMock("openclaw/plugin-sdk/config-runtime", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/config-runtime")>();
|
||||
return {
|
||||
...actual,
|
||||
readSessionUpdatedAt: () => undefined,
|
||||
resolveStorePath: (storePath?: string) => storePath ?? "/tmp/sessions.json",
|
||||
};
|
||||
});
|
||||
vi.doMock("openclaw/plugin-sdk/conversation-runtime", async (importOriginal) => {
|
||||
const actual =
|
||||
await importOriginal<typeof import("openclaw/plugin-sdk/conversation-runtime")>();
|
||||
return {
|
||||
...actual,
|
||||
recordInboundSession: async () => undefined,
|
||||
};
|
||||
});
|
||||
messageContextMocksInstalled = true;
|
||||
}
|
||||
|
||||
4
test/fixtures/test-timings.channels.json
vendored
4
test/fixtures/test-timings.channels.json
vendored
@@ -169,7 +169,7 @@
|
||||
"durationMs": 1000
|
||||
},
|
||||
"extensions/telegram/src/bot-message-context.audio-transcript.test.ts": {
|
||||
"durationMs": 17310
|
||||
"durationMs": 20350
|
||||
},
|
||||
"extensions/whatsapp/src/monitor-inbox.append-upsert.test.ts": {
|
||||
"durationMs": 999
|
||||
@@ -523,7 +523,7 @@
|
||||
"durationMs": 11
|
||||
},
|
||||
"extensions/telegram/src/bot-message-context.sender-prefix.test.ts": {
|
||||
"durationMs": 19410
|
||||
"durationMs": 20090
|
||||
},
|
||||
"extensions/whatsapp/src/active-listener.test.ts": {
|
||||
"durationMs": 11
|
||||
|
||||
Reference in New Issue
Block a user