mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-27 17:11:46 +00:00
Verified: - pnpm build - pnpm check - pnpm test (ran; one unrelated existing failure in models forward-compat test) - pnpm vitest src/agents/pi-embedded-runner.history-limit-from-session-key.test.ts Co-authored-by: shadril238 <63901551+shadril238@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import type { OpenClawConfig } from "../config/config.js";
|
|
import { getDmHistoryLimitFromSessionKey } from "./pi-embedded-runner.js";
|
|
|
|
describe("getDmHistoryLimitFromSessionKey", () => {
|
|
it("keeps backward compatibility for dm/direct session kinds", () => {
|
|
const config = {
|
|
channels: { telegram: { dmHistoryLimit: 10 } },
|
|
} as OpenClawConfig;
|
|
|
|
expect(getDmHistoryLimitFromSessionKey("telegram:dm:123", config)).toBe(10);
|
|
expect(getDmHistoryLimitFromSessionKey("telegram:direct:123", config)).toBe(10);
|
|
});
|
|
|
|
it("returns historyLimit for channel and group session kinds", () => {
|
|
const config = {
|
|
channels: { discord: { historyLimit: 12, dmHistoryLimit: 5 } },
|
|
} as OpenClawConfig;
|
|
|
|
expect(getDmHistoryLimitFromSessionKey("discord:channel:123", config)).toBe(12);
|
|
expect(getDmHistoryLimitFromSessionKey("discord:group:456", config)).toBe(12);
|
|
});
|
|
|
|
it("returns undefined for unsupported session kinds", () => {
|
|
const config = {
|
|
channels: { discord: { historyLimit: 12, dmHistoryLimit: 5 } },
|
|
} as OpenClawConfig;
|
|
|
|
expect(getDmHistoryLimitFromSessionKey("discord:slash:123", config)).toBeUndefined();
|
|
});
|
|
});
|