mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 07:40:21 +00:00
chore: Fix types in tests 39/N.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { MsgContext } from "../auto-reply/templating.js";
|
||||
import {
|
||||
type ChannelMatchSource,
|
||||
buildChannelKeyCandidates,
|
||||
normalizeChannelSlug,
|
||||
resolveChannelEntryMatch,
|
||||
@@ -95,10 +96,8 @@ describe("resolveChannelEntryMatchWithFallback", () => {
|
||||
|
||||
describe("applyChannelMatchMeta", () => {
|
||||
it("copies match metadata onto resolved configs", () => {
|
||||
const resolved = applyChannelMatchMeta(
|
||||
{ allowed: true },
|
||||
{ matchKey: "general", matchSource: "direct" },
|
||||
);
|
||||
const base: { matchKey?: string; matchSource?: ChannelMatchSource } = {};
|
||||
const resolved = applyChannelMatchMeta(base, { matchKey: "general", matchSource: "direct" });
|
||||
expect(resolved.matchKey).toBe("general");
|
||||
expect(resolved.matchSource).toBe("direct");
|
||||
});
|
||||
@@ -106,14 +105,20 @@ describe("applyChannelMatchMeta", () => {
|
||||
|
||||
describe("resolveChannelMatchConfig", () => {
|
||||
it("returns null when no entry is matched", () => {
|
||||
const resolved = resolveChannelMatchConfig({ matchKey: "x" }, () => ({ allowed: true }));
|
||||
const resolved = resolveChannelMatchConfig({ matchKey: "x" }, () => {
|
||||
const out: { matchKey?: string; matchSource?: ChannelMatchSource } = {};
|
||||
return out;
|
||||
});
|
||||
expect(resolved).toBeNull();
|
||||
});
|
||||
|
||||
it("resolves entry and applies match metadata", () => {
|
||||
const resolved = resolveChannelMatchConfig(
|
||||
{ entry: { allow: true }, matchKey: "*", matchSource: "wildcard" },
|
||||
() => ({ allowed: true }),
|
||||
() => {
|
||||
const out: { matchKey?: string; matchSource?: ChannelMatchSource } = {};
|
||||
return out;
|
||||
},
|
||||
);
|
||||
expect(resolved?.matchKey).toBe("*");
|
||||
expect(resolved?.matchSource).toBe("wildcard");
|
||||
|
||||
@@ -436,9 +436,13 @@ describe("telegramMessageActions", () => {
|
||||
|
||||
it("rejects non-integer messageId for edit before reaching telegram-actions", async () => {
|
||||
const cfg = { channels: { telegram: { botToken: "tok" } } } as OpenClawConfig;
|
||||
const handleAction = telegramMessageActions.handleAction;
|
||||
if (!handleAction) {
|
||||
throw new Error("telegram handleAction unavailable");
|
||||
}
|
||||
|
||||
await expect(
|
||||
telegramMessageActions.handleAction({
|
||||
handleAction({
|
||||
channel: "telegram",
|
||||
action: "edit",
|
||||
params: {
|
||||
@@ -595,9 +599,13 @@ describe("signalMessageActions", () => {
|
||||
const cfg = {
|
||||
channels: { signal: { account: "+15550001111", actions: { reactions: false } } },
|
||||
} as OpenClawConfig;
|
||||
const handleAction = signalMessageActions.handleAction;
|
||||
if (!handleAction) {
|
||||
throw new Error("signal handleAction unavailable");
|
||||
}
|
||||
|
||||
await expect(
|
||||
signalMessageActions.handleAction({
|
||||
handleAction({
|
||||
channel: "signal",
|
||||
action: "react",
|
||||
params: { to: "+15550001111", messageId: "123", emoji: "✅" },
|
||||
@@ -661,9 +669,13 @@ describe("signalMessageActions", () => {
|
||||
const cfg = {
|
||||
channels: { signal: { account: "+15550001111" } },
|
||||
} as OpenClawConfig;
|
||||
const handleAction = signalMessageActions.handleAction;
|
||||
if (!handleAction) {
|
||||
throw new Error("signal handleAction unavailable");
|
||||
}
|
||||
|
||||
await expect(
|
||||
signalMessageActions.handleAction({
|
||||
handleAction({
|
||||
channel: "signal",
|
||||
action: "react",
|
||||
params: { to: "signal:group:group-id", messageId: "123", emoji: "✅" },
|
||||
|
||||
@@ -121,6 +121,9 @@ describe("channel plugin catalog", () => {
|
||||
const createRegistry = (channels: PluginRegistry["channels"]): PluginRegistry => ({
|
||||
plugins: [],
|
||||
tools: [],
|
||||
hooks: [],
|
||||
typedHooks: [],
|
||||
commands: [],
|
||||
channels,
|
||||
providers: [],
|
||||
gatewayHandlers: {},
|
||||
|
||||
Reference in New Issue
Block a user