mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-29 02:41:07 +00:00
refactor: add public channel contract test seams
This commit is contained in:
@@ -17,3 +17,5 @@ export * from "./src/resolve-channels.js";
|
||||
export * from "./src/resolve-users.js";
|
||||
export * from "./src/outbound-session-route.js";
|
||||
export * from "./src/send.js";
|
||||
|
||||
export const discordSessionBindingAdapterChannels = ["discord"] as const;
|
||||
|
||||
1
extensions/discord/test-api.ts
Normal file
1
extensions/discord/test-api.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { buildFinalizedDiscordDirectInboundContext } from "./src/monitor/inbound-context.test-helpers.js";
|
||||
@@ -3,3 +3,5 @@ export * from "./src/setup-core.js";
|
||||
export * from "./src/setup-surface.js";
|
||||
export * from "./src/thread-bindings.js";
|
||||
export { __testing as feishuThreadBindingTesting } from "./src/thread-bindings.js";
|
||||
|
||||
export const feishuSessionBindingAdapterChannels = ["feishu"] as const;
|
||||
|
||||
@@ -6,3 +6,5 @@ export {
|
||||
resetMatrixThreadBindingsForTests,
|
||||
} from "./src/matrix/thread-bindings.js";
|
||||
export { matrixOnboardingAdapter as matrixSetupWizard } from "./src/onboarding.js";
|
||||
|
||||
export const matrixSessionBindingAdapterChannels = ["matrix"] as const;
|
||||
|
||||
4
extensions/slack/test-api.ts
Normal file
4
extensions/slack/test-api.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export type { ResolvedSlackAccount } from "./src/accounts.js";
|
||||
export type { SlackMessageEvent } from "./src/types.js";
|
||||
export { prepareSlackMessage } from "./src/monitor/message-handler/prepare.js";
|
||||
export { createInboundSlackTestContext } from "./src/monitor/message-handler/prepare.test-helpers.js";
|
||||
@@ -83,3 +83,5 @@ export {
|
||||
setTelegramThreadBindingMaxAgeBySessionKey,
|
||||
} from "./src/thread-bindings.js";
|
||||
export { resolveTelegramToken } from "./src/token.js";
|
||||
|
||||
export const telegramSessionBindingAdapterChannels = ["telegram"] as const;
|
||||
|
||||
1
extensions/telegram/test-api.ts
Normal file
1
extensions/telegram/test-api.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { buildTelegramMessageContextForTest } from "./src/bot-message-context.test-harness.js";
|
||||
@@ -1,7 +1,12 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { buildFinalizedDiscordDirectInboundContext } from "../../../../extensions/discord/src/monitor/inbound-context.test-helpers.js";
|
||||
import type { ResolvedSlackAccount } from "../../../../extensions/slack/src/accounts.js";
|
||||
import type { SlackMessageEvent } from "../../../../extensions/slack/src/types.js";
|
||||
import { buildFinalizedDiscordDirectInboundContext } from "../../../../extensions/discord/test-api.js";
|
||||
import {
|
||||
createInboundSlackTestContext,
|
||||
prepareSlackMessage,
|
||||
type ResolvedSlackAccount,
|
||||
type SlackMessageEvent,
|
||||
} from "../../../../extensions/slack/test-api.js";
|
||||
import { buildTelegramMessageContextForTest } from "../../../../extensions/telegram/test-api.js";
|
||||
import { withTempHome } from "../../../../test/helpers/temp-home.js";
|
||||
import type { MsgContext } from "../../../auto-reply/templating.js";
|
||||
import type { OpenClawConfig } from "../../../config/config.js";
|
||||
@@ -75,12 +80,6 @@ vi.mock("../../../../extensions/whatsapp/src/auto-reply/deliver-reply.js", () =>
|
||||
}));
|
||||
|
||||
const { finalizeInboundContext } = await import("../../../auto-reply/reply/inbound-context.js");
|
||||
const { prepareSlackMessage } =
|
||||
await import("../../../../extensions/slack/src/monitor/message-handler/prepare.js");
|
||||
const { createInboundSlackTestContext } =
|
||||
await import("../../../../extensions/slack/src/monitor/message-handler/prepare.test-helpers.js");
|
||||
const { buildTelegramMessageContextForTest } =
|
||||
await import("../../../../extensions/telegram/src/bot-message-context.test-harness.js");
|
||||
|
||||
function createSlackAccount(config: ResolvedSlackAccount["config"] = {}): ResolvedSlackAccount {
|
||||
return {
|
||||
|
||||
@@ -1,27 +1,19 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { discordSessionBindingAdapterChannels } from "../../../../extensions/discord/runtime-api.js";
|
||||
import { feishuSessionBindingAdapterChannels } from "../../../../extensions/feishu/api.js";
|
||||
import { matrixSessionBindingAdapterChannels } from "../../../../extensions/matrix/api.js";
|
||||
import { telegramSessionBindingAdapterChannels } from "../../../../extensions/telegram/runtime-api.js";
|
||||
import { sessionBindingContractChannelIds } from "./manifest.js";
|
||||
|
||||
const sessionBindingAdapterFiles = [
|
||||
"../../../../extensions/discord/src/monitor/thread-bindings.manager.ts",
|
||||
"../../../../extensions/feishu/src/thread-bindings.ts",
|
||||
"../../../../extensions/matrix/src/matrix/thread-bindings.ts",
|
||||
"../../../../extensions/telegram/src/thread-bindings.ts",
|
||||
] as const;
|
||||
|
||||
function discoverSessionBindingChannels() {
|
||||
const channels = new Set<string>();
|
||||
for (const relativePath of sessionBindingAdapterFiles) {
|
||||
const filePath = path.resolve(import.meta.dirname, relativePath);
|
||||
const source = fs.readFileSync(filePath, "utf8");
|
||||
for (const match of source.matchAll(
|
||||
/registerSessionBindingAdapter\(\{[\s\S]*?channel:\s*"([^"]+)"/g,
|
||||
)) {
|
||||
channels.add(match[1]);
|
||||
}
|
||||
}
|
||||
return [...channels].toSorted();
|
||||
return [
|
||||
...new Set([
|
||||
...discordSessionBindingAdapterChannels,
|
||||
...feishuSessionBindingAdapterChannels,
|
||||
...matrixSessionBindingAdapterChannels,
|
||||
...telegramSessionBindingAdapterChannels,
|
||||
]),
|
||||
].toSorted();
|
||||
}
|
||||
|
||||
describe("channel contract registry", () => {
|
||||
|
||||
Reference in New Issue
Block a user