mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 01:31:08 +00:00
test: speed up irc channel seam tests
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { ircPlugin } from "./channel.js";
|
||||
import { ircOutboundBaseAdapter } from "./outbound-base.js";
|
||||
import { clearIrcRuntime } from "./runtime.js";
|
||||
|
||||
describe("irc outbound chunking", () => {
|
||||
@@ -8,11 +8,9 @@ describe("irc outbound chunking", () => {
|
||||
});
|
||||
|
||||
it("chunks outbound text without requiring IRC runtime initialization", () => {
|
||||
const chunker = ircPlugin.outbound?.chunker;
|
||||
if (!chunker) {
|
||||
throw new Error("irc outbound.chunker unavailable");
|
||||
}
|
||||
|
||||
expect(chunker("alpha beta", 5)).toEqual(["alpha", "beta"]);
|
||||
expect(ircOutboundBaseAdapter.chunker("alpha beta", 5)).toEqual(["alpha", "beta"]);
|
||||
expect(ircOutboundBaseAdapter.deliveryMode).toBe("direct");
|
||||
expect(ircOutboundBaseAdapter.chunkerMode).toBe("markdown");
|
||||
expect(ircOutboundBaseAdapter.textChunkLimit).toBe(350);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,7 +14,6 @@ import {
|
||||
createChannelDirectoryAdapter,
|
||||
createResolvedDirectoryEntriesLister,
|
||||
} from "openclaw/plugin-sdk/directory-runtime";
|
||||
import { sanitizeForPlainText } from "openclaw/plugin-sdk/outbound-runtime";
|
||||
import {
|
||||
createComputedAccountStatusAdapter,
|
||||
createDefaultChannelRuntimeState,
|
||||
@@ -27,7 +26,6 @@ import {
|
||||
} from "./accounts.js";
|
||||
import {
|
||||
buildBaseChannelStatusSummary,
|
||||
chunkTextForOutbound,
|
||||
DEFAULT_ACCOUNT_ID,
|
||||
PAIRING_APPROVED_MESSAGE,
|
||||
type ChannelPlugin,
|
||||
@@ -41,6 +39,7 @@ import {
|
||||
normalizeIrcAllowEntry,
|
||||
normalizeIrcMessagingTarget,
|
||||
} from "./normalize.js";
|
||||
import { ircOutboundBaseAdapter } from "./outbound-base.js";
|
||||
import { resolveIrcGroupMatch, resolveIrcRequireMention } from "./policy.js";
|
||||
import { probeIrc } from "./probe.js";
|
||||
import { collectRuntimeConfigAssignments, secretTargetRegistryEntries } from "./secret-contract.js";
|
||||
@@ -342,13 +341,7 @@ export const ircPlugin: ChannelPlugin<ResolvedIrcAccount, IrcProbe> = createChat
|
||||
collectWarnings: collectIrcSecurityWarnings,
|
||||
},
|
||||
outbound: {
|
||||
base: {
|
||||
deliveryMode: "direct",
|
||||
chunker: chunkTextForOutbound,
|
||||
chunkerMode: "markdown",
|
||||
textChunkLimit: 350,
|
||||
sanitizeText: ({ text }) => sanitizeForPlainText(text),
|
||||
},
|
||||
base: ircOutboundBaseAdapter,
|
||||
attachedResults: {
|
||||
channel: "irc",
|
||||
sendText: async ({ cfg, to, text, accountId, replyToId }) => {
|
||||
|
||||
10
extensions/irc/src/outbound-base.ts
Normal file
10
extensions/irc/src/outbound-base.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { sanitizeForPlainText } from "openclaw/plugin-sdk/outbound-runtime";
|
||||
import { chunkTextForOutbound } from "./channel-api.js";
|
||||
|
||||
export const ircOutboundBaseAdapter = {
|
||||
deliveryMode: "direct" as const,
|
||||
chunker: chunkTextForOutbound,
|
||||
chunkerMode: "markdown" as const,
|
||||
textChunkLimit: 350,
|
||||
sanitizeText: ({ text }: { text: string }) => sanitizeForPlainText(text),
|
||||
};
|
||||
Reference in New Issue
Block a user