mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 11:41:24 +00:00
perf(test): remove dead telegram bot test scaffolding
This commit is contained in:
@@ -1,7 +1,4 @@
|
|||||||
import fs from "node:fs";
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
import os from "node:os";
|
|
||||||
import path from "node:path";
|
|
||||||
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
||||||
import { escapeRegExp, formatEnvelopeTimestamp } from "../../test/helpers/envelope-timestamp.js";
|
import { escapeRegExp, formatEnvelopeTimestamp } from "../../test/helpers/envelope-timestamp.js";
|
||||||
import { expectInboundContextContract } from "../../test/helpers/inbound-contract.js";
|
import { expectInboundContextContract } from "../../test/helpers/inbound-contract.js";
|
||||||
import {
|
import {
|
||||||
@@ -9,8 +6,7 @@ import {
|
|||||||
listNativeCommandSpecsForConfig,
|
listNativeCommandSpecsForConfig,
|
||||||
} from "../auto-reply/commands-registry.js";
|
} from "../auto-reply/commands-registry.js";
|
||||||
import { resetInboundDedupe } from "../auto-reply/reply/inbound-dedupe.js";
|
import { resetInboundDedupe } from "../auto-reply/reply/inbound-dedupe.js";
|
||||||
import { createTelegramBot, getTelegramSequentialKey } from "./bot.js";
|
import { createTelegramBot } from "./bot.js";
|
||||||
import { resolveTelegramFetch } from "./fetch.js";
|
|
||||||
|
|
||||||
let replyModule: typeof import("../auto-reply/reply.js");
|
let replyModule: typeof import("../auto-reply/reply.js");
|
||||||
const { listSkillCommandsForAgents } = vi.hoisted(() => ({
|
const { listSkillCommandsForAgents } = vi.hoisted(() => ({
|
||||||
@@ -23,13 +19,6 @@ vi.mock("../auto-reply/skill-commands.js", () => ({
|
|||||||
const { sessionStorePath } = vi.hoisted(() => ({
|
const { sessionStorePath } = vi.hoisted(() => ({
|
||||||
sessionStorePath: `/tmp/openclaw-telegram-bot-${Math.random().toString(16).slice(2)}.json`,
|
sessionStorePath: `/tmp/openclaw-telegram-bot-${Math.random().toString(16).slice(2)}.json`,
|
||||||
}));
|
}));
|
||||||
const tempDirs: string[] = [];
|
|
||||||
|
|
||||||
function createTempDir(prefix: string): string {
|
|
||||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
|
|
||||||
tempDirs.push(dir);
|
|
||||||
return dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
function resolveSkillCommands(config: Parameters<typeof listNativeCommandSpecsForConfig>[0]) {
|
function resolveSkillCommands(config: Parameters<typeof listNativeCommandSpecsForConfig>[0]) {
|
||||||
return listSkillCommandsForAgents({ cfg: config });
|
return listSkillCommandsForAgents({ cfg: config });
|
||||||
@@ -149,10 +138,8 @@ vi.mock("grammy", () => ({
|
|||||||
|
|
||||||
const sequentializeMiddleware = vi.fn();
|
const sequentializeMiddleware = vi.fn();
|
||||||
const sequentializeSpy = vi.fn(() => sequentializeMiddleware);
|
const sequentializeSpy = vi.fn(() => sequentializeMiddleware);
|
||||||
let sequentializeKey: ((ctx: unknown) => string) | undefined;
|
|
||||||
vi.mock("@grammyjs/runner", () => ({
|
vi.mock("@grammyjs/runner", () => ({
|
||||||
sequentialize: (keyFn: (ctx: unknown) => string) => {
|
sequentialize: (_keyFn: (ctx: unknown) => string) => {
|
||||||
sequentializeKey = keyFn;
|
|
||||||
return sequentializeSpy();
|
return sequentializeSpy();
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
@@ -209,19 +196,11 @@ describe("createTelegramBot", () => {
|
|||||||
middlewareUseSpy.mockReset();
|
middlewareUseSpy.mockReset();
|
||||||
sequentializeSpy.mockReset();
|
sequentializeSpy.mockReset();
|
||||||
botCtorSpy.mockReset();
|
botCtorSpy.mockReset();
|
||||||
sequentializeKey = undefined;
|
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
process.env.TZ = ORIGINAL_TZ;
|
process.env.TZ = ORIGINAL_TZ;
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(() => {
|
|
||||||
for (const dir of tempDirs) {
|
|
||||||
fs.rmSync(dir, { recursive: true, force: true });
|
|
||||||
}
|
|
||||||
tempDirs.length = 0;
|
|
||||||
});
|
|
||||||
|
|
||||||
it("merges custom commands with native commands", () => {
|
it("merges custom commands with native commands", () => {
|
||||||
const config = {
|
const config = {
|
||||||
channels: {
|
channels: {
|
||||||
|
|||||||
Reference in New Issue
Block a user