Skip to content

Commit 2e29090

Browse files
committed
test: wire qa channel turn fixture
1 parent fd3aa10 commit 2e29090

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

extensions/qa-channel/src/channel.test.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { verifyChannelMessageAdapterCapabilityProofs } from "openclaw/plugin-sdk/channel-message";
2-
import { createStartAccountContext } from "openclaw/plugin-sdk/channel-test-helpers";
2+
import {
3+
createPluginRuntimeMock,
4+
createStartAccountContext,
5+
} from "openclaw/plugin-sdk/channel-test-helpers";
36
import type { PluginRuntime } from "openclaw/plugin-sdk/core";
47
import {
58
createTestRegistry,
@@ -33,7 +36,7 @@ function createMockQaRuntime(params?: {
3336
onDispatch?: (ctx: Record<string, unknown>) => void;
3437
}): PluginRuntime {
3538
const sessionUpdatedAt = new Map<string, number>();
36-
return {
39+
return createPluginRuntimeMock({
3740
channel: {
3841
mentions: {
3942
buildMentionRegexes() {
@@ -96,8 +99,28 @@ function createMockQaRuntime(params?: {
9699
});
97100
},
98101
},
102+
turn: {
103+
async runPrepared(turn) {
104+
await turn.recordInboundSession({
105+
storePath: turn.storePath,
106+
sessionKey:
107+
typeof turn.ctxPayload.SessionKey === "string"
108+
? turn.ctxPayload.SessionKey
109+
: turn.routeSessionKey,
110+
ctx: turn.ctxPayload,
111+
onRecordError: turn.record?.onRecordError ?? (() => undefined),
112+
});
113+
return {
114+
admission: turn.admission ?? { kind: "dispatch" as const },
115+
dispatched: true,
116+
ctxPayload: turn.ctxPayload,
117+
routeSessionKey: turn.routeSessionKey,
118+
dispatchResult: await turn.runDispatch(),
119+
};
120+
},
121+
},
99122
},
100-
} as unknown as PluginRuntime;
123+
} as unknown as PluginRuntime);
101124
}
102125

103126
function createQaChannelConfig(params: { baseUrl: string; allowFrom?: string[] }) {

0 commit comments

Comments
 (0)