refactor: move test harnesses off infra runtime

This commit is contained in:
Peter Steinberger
2026-03-28 06:51:17 +00:00
parent f0a57fad42
commit 61936938e9
7 changed files with 17 additions and 5 deletions

View File

@@ -1666,6 +1666,15 @@
"path": "src/infra/heartbeat-events.ts"
}
},
{
"declaration": "export function resetSystemEventsForTest(): void;",
"exportName": "resetSystemEventsForTest",
"kind": "function",
"source": {
"line": 157,
"path": "src/infra/system-events.ts"
}
},
{
"declaration": "export function resolveHeartbeatVisibility(params: { cfg: OpenClawConfig; channel: GatewayMessageChannel; accountId?: string | undefined; }): ResolvedHeartbeatVisibility;",
"exportName": "resolveHeartbeatVisibility",

View File

@@ -182,6 +182,7 @@
{"declaration":"export function recordChannelActivity(params: { channel: ChannelId; accountId?: string | null | undefined; direction: ChannelDirection; at?: number | undefined; }): void;","entrypoint":"channel-runtime","exportName":"recordChannelActivity","importSpecifier":"openclaw/plugin-sdk/channel-runtime","kind":"function","recordType":"export","sourceLine":26,"sourcePath":"src/infra/channel-activity.ts"}
{"declaration":"export function reduceInteractiveReply<TState>(interactive: InteractiveReply | undefined, initialState: TState, reduce: (state: TState, block: InteractiveReplyBlock, index: number) => TState): TState;","entrypoint":"channel-runtime","exportName":"reduceInteractiveReply","importSpecifier":"openclaw/plugin-sdk/channel-runtime","kind":"function","recordType":"export","sourceLine":3,"sourcePath":"src/channels/plugins/outbound/interactive.ts"}
{"declaration":"export function resetHeartbeatEventsForTest(): void;","entrypoint":"channel-runtime","exportName":"resetHeartbeatEventsForTest","importSpecifier":"openclaw/plugin-sdk/channel-runtime","kind":"function","recordType":"export","sourceLine":65,"sourcePath":"src/infra/heartbeat-events.ts"}
{"declaration":"export function resetSystemEventsForTest(): void;","entrypoint":"channel-runtime","exportName":"resetSystemEventsForTest","importSpecifier":"openclaw/plugin-sdk/channel-runtime","kind":"function","recordType":"export","sourceLine":157,"sourcePath":"src/infra/system-events.ts"}
{"declaration":"export function resolveHeartbeatVisibility(params: { cfg: OpenClawConfig; channel: GatewayMessageChannel; accountId?: string | undefined; }): ResolvedHeartbeatVisibility;","entrypoint":"channel-runtime","exportName":"resolveHeartbeatVisibility","importSpecifier":"openclaw/plugin-sdk/channel-runtime","kind":"function","recordType":"export","sourceLine":22,"sourcePath":"src/infra/heartbeat-visibility.ts"}
{"declaration":"export function resolveIndicatorType(status: \"sent\" | \"ok-empty\" | \"ok-token\" | \"skipped\" | \"failed\"): HeartbeatIndicatorType | undefined;","entrypoint":"channel-runtime","exportName":"resolveIndicatorType","importSpecifier":"openclaw/plugin-sdk/channel-runtime","kind":"function","recordType":"export","sourceLine":23,"sourcePath":"src/infra/heartbeat-events.ts"}
{"declaration":"export function resolvePollMaxSelections(optionCount: number, allowMultiselect: boolean | undefined): number;","entrypoint":"channel-runtime","exportName":"resolvePollMaxSelections","importSpecifier":"openclaw/plugin-sdk/channel-runtime","kind":"function","recordType":"export","sourceLine":29,"sourcePath":"src/polls.ts"}

View File

@@ -197,7 +197,7 @@ export function installSignalToolResultTestHooks() {
beforeEach(async () => {
const [{ resetInboundDedupe }, { resetSystemEventsForTest }] = await Promise.all([
import("openclaw/plugin-sdk/reply-runtime"),
import("openclaw/plugin-sdk/infra-runtime"),
import("openclaw/plugin-sdk/channel-runtime"),
]);
resetInboundDedupe();
config = {

View File

@@ -1,4 +1,4 @@
import * as ssrf from "openclaw/plugin-sdk/infra-runtime";
import * as ssrf from "openclaw/plugin-sdk/ssrf-runtime";
import { afterEach, beforeEach, expect, vi, type Mock } from "vitest";
import * as harness from "./bot.media.e2e-harness.js";

View File

@@ -2,9 +2,10 @@ import "./test-helpers.js";
import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import * as ssrf from "openclaw/plugin-sdk/infra-runtime";
import { createPinnedLookup } from "openclaw/plugin-sdk/fetch-runtime";
import { resetInboundDedupe } from "openclaw/plugin-sdk/reply-runtime";
import { resetLogger, setLoggerOverride } from "openclaw/plugin-sdk/runtime-env";
import * as ssrf from "openclaw/plugin-sdk/ssrf-runtime";
import { afterAll, afterEach, beforeAll, beforeEach, vi } from "vitest";
import type { WebInboundMessage, WebListenerCloseReason } from "./inbound.js";
import {
@@ -145,7 +146,7 @@ export function installWebAutoReplyUnitTestHooks(opts?: { pinDns?: boolean }) {
return {
hostname: normalized,
addresses,
lookup: ssrf.createPinnedLookup({ hostname: normalized, addresses }),
lookup: createPinnedLookup({ hostname: normalized, addresses }),
};
});
}

View File

@@ -11,7 +11,7 @@ export * from "../channels/plugins/normalize/whatsapp.js";
export * from "../channels/plugins/outbound/interactive.js";
export * from "../channels/plugins/whatsapp-heartbeat.js";
export * from "../polls.js";
export { enqueueSystemEvent } from "../infra/system-events.js";
export { enqueueSystemEvent, resetSystemEventsForTest } from "../infra/system-events.js";
export { recordChannelActivity } from "../infra/channel-activity.js";
export * from "../infra/heartbeat-events.ts";
export * from "../infra/heartbeat-visibility.ts";

View File

@@ -5,6 +5,7 @@ export {
closeDispatcher,
createPinnedDispatcher,
isBlockedHostnameOrIp,
resolvePinnedHostname,
resolvePinnedHostnameWithPolicy,
type LookupFn,
type SsrFPolicy,