mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-14 04:38:35 +00:00
test: speed up heavy suites with shared fixtures
This commit is contained in:
@@ -9,7 +9,7 @@ type AnyMock = MockFn<(...args: unknown[]) => unknown>;
|
||||
type AnyAsyncMock = MockFn<(...args: unknown[]) => Promise<unknown>>;
|
||||
|
||||
const { sessionStorePath } = vi.hoisted(() => ({
|
||||
sessionStorePath: `/tmp/openclaw-telegram-${Math.random().toString(16).slice(2)}.json`,
|
||||
sessionStorePath: `/tmp/openclaw-telegram-${process.pid}-${process.env.VITEST_POOL_ID ?? "0"}.json`,
|
||||
}));
|
||||
|
||||
const { loadWebMedia } = vi.hoisted((): { loadWebMedia: AnyMock } => ({
|
||||
@@ -212,6 +212,17 @@ export const getOnHandler = (event: string) => {
|
||||
return handler as (ctx: Record<string, unknown>) => Promise<void>;
|
||||
};
|
||||
|
||||
const DEFAULT_TELEGRAM_TEST_CONFIG: OpenClawConfig = {
|
||||
agents: {
|
||||
defaults: {
|
||||
envelopeTimezone: "utc",
|
||||
},
|
||||
},
|
||||
channels: {
|
||||
telegram: { dmPolicy: "open", allowFrom: ["*"] },
|
||||
},
|
||||
};
|
||||
|
||||
export function makeTelegramMessageCtx(params: {
|
||||
chat: {
|
||||
id: number;
|
||||
@@ -265,16 +276,7 @@ export function makeForumGroupMessageCtx(params?: {
|
||||
beforeEach(() => {
|
||||
resetInboundDedupe();
|
||||
loadConfig.mockReset();
|
||||
loadConfig.mockReturnValue({
|
||||
agents: {
|
||||
defaults: {
|
||||
envelopeTimezone: "utc",
|
||||
},
|
||||
},
|
||||
channels: {
|
||||
telegram: { dmPolicy: "open", allowFrom: ["*"] },
|
||||
},
|
||||
});
|
||||
loadConfig.mockReturnValue(DEFAULT_TELEGRAM_TEST_CONFIG);
|
||||
loadWebMedia.mockReset();
|
||||
readChannelAllowFromStore.mockReset();
|
||||
readChannelAllowFromStore.mockResolvedValue([]);
|
||||
|
||||
Reference in New Issue
Block a user