mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-14 02:31:24 +00:00
test: use channel schemas in config regressions
This commit is contained in:
@@ -1,26 +1,69 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { validateConfigObject } from "./validation.js";
|
||||
import {
|
||||
BlueBubblesConfigSchema,
|
||||
IMessageConfigSchema,
|
||||
SignalConfigSchema,
|
||||
TelegramConfigSchema,
|
||||
} from "./zod-schema.providers-core.js";
|
||||
import { WhatsAppConfigSchema } from "./zod-schema.providers-whatsapp.js";
|
||||
|
||||
describe("config schema regressions", () => {
|
||||
it("accepts nested telegram groupPolicy overrides", () => {
|
||||
const res = validateConfigObject({
|
||||
channels: {
|
||||
telegram: {
|
||||
groups: {
|
||||
"-1001234567890": {
|
||||
groupPolicy: "open",
|
||||
topics: {
|
||||
"42": {
|
||||
groupPolicy: "disabled",
|
||||
},
|
||||
},
|
||||
const res = TelegramConfigSchema.safeParse({
|
||||
groups: {
|
||||
"-1001234567890": {
|
||||
groupPolicy: "open",
|
||||
topics: {
|
||||
"42": {
|
||||
groupPolicy: "disabled",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(res.ok).toBe(true);
|
||||
expect(res.success).toBe(true);
|
||||
});
|
||||
|
||||
it("accepts telegram actions editMessage and createForumTopic", () => {
|
||||
const res = TelegramConfigSchema.safeParse({
|
||||
actions: {
|
||||
editMessage: true,
|
||||
createForumTopic: false,
|
||||
},
|
||||
});
|
||||
|
||||
expect(res.success).toBe(true);
|
||||
});
|
||||
|
||||
it("accepts channels.whatsapp.enabled", () => {
|
||||
const res = WhatsAppConfigSchema.safeParse({
|
||||
enabled: true,
|
||||
});
|
||||
|
||||
expect(res.success).toBe(true);
|
||||
});
|
||||
|
||||
it("accepts signal accountUuid for loop protection", () => {
|
||||
const res = SignalConfigSchema.safeParse({
|
||||
accountUuid: "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
});
|
||||
|
||||
expect(res.success).toBe(true);
|
||||
});
|
||||
|
||||
it("accepts BlueBubbles enrichGroupParticipantsFromContacts at channel and account scope", () => {
|
||||
const res = BlueBubblesConfigSchema.safeParse({
|
||||
enrichGroupParticipantsFromContacts: true,
|
||||
accounts: {
|
||||
work: {
|
||||
enrichGroupParticipantsFromContacts: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(res.success).toBe(true);
|
||||
});
|
||||
|
||||
it('accepts memorySearch fallback "voyage"', () => {
|
||||
@@ -105,72 +148,31 @@ describe("config schema regressions", () => {
|
||||
});
|
||||
|
||||
it("accepts safe iMessage remoteHost", () => {
|
||||
const res = validateConfigObject({
|
||||
channels: {
|
||||
imessage: {
|
||||
remoteHost: "bot@gateway-host",
|
||||
},
|
||||
},
|
||||
const res = IMessageConfigSchema.safeParse({
|
||||
remoteHost: "bot@gateway-host",
|
||||
});
|
||||
|
||||
expect(res.ok).toBe(true);
|
||||
});
|
||||
|
||||
it("accepts channels.whatsapp.enabled", () => {
|
||||
const res = validateConfigObject({
|
||||
channels: {
|
||||
whatsapp: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(res.ok).toBe(true);
|
||||
});
|
||||
|
||||
it("accepts BlueBubbles enrichGroupParticipantsFromContacts at channel and account scope", () => {
|
||||
const res = validateConfigObject({
|
||||
channels: {
|
||||
bluebubbles: {
|
||||
enrichGroupParticipantsFromContacts: true,
|
||||
accounts: {
|
||||
work: {
|
||||
enrichGroupParticipantsFromContacts: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(res.ok).toBe(true);
|
||||
expect(res.success).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects unsafe iMessage remoteHost", () => {
|
||||
const res = validateConfigObject({
|
||||
channels: {
|
||||
imessage: {
|
||||
remoteHost: "bot@gateway-host -oProxyCommand=whoami",
|
||||
},
|
||||
},
|
||||
const res = IMessageConfigSchema.safeParse({
|
||||
remoteHost: "bot@gateway-host -oProxyCommand=whoami",
|
||||
});
|
||||
|
||||
expect(res.ok).toBe(false);
|
||||
if (!res.ok) {
|
||||
expect(res.issues[0]?.path).toBe("channels.imessage.remoteHost");
|
||||
expect(res.success).toBe(false);
|
||||
if (!res.success) {
|
||||
expect(res.error.issues[0]?.path.join(".")).toBe("remoteHost");
|
||||
}
|
||||
});
|
||||
|
||||
it("accepts iMessage attachment root patterns", () => {
|
||||
const res = validateConfigObject({
|
||||
channels: {
|
||||
imessage: {
|
||||
attachmentRoots: ["/Users/*/Library/Messages/Attachments"],
|
||||
remoteAttachmentRoots: ["/Volumes/relay/attachments"],
|
||||
},
|
||||
},
|
||||
const res = IMessageConfigSchema.safeParse({
|
||||
attachmentRoots: ["/Users/*/Library/Messages/Attachments"],
|
||||
remoteAttachmentRoots: ["/Volumes/relay/attachments"],
|
||||
});
|
||||
|
||||
expect(res.ok).toBe(true);
|
||||
expect(res.success).toBe(true);
|
||||
});
|
||||
|
||||
it("accepts string values for agents defaults model inputs", () => {
|
||||
@@ -221,17 +223,13 @@ describe("config schema regressions", () => {
|
||||
});
|
||||
|
||||
it("rejects relative iMessage attachment roots", () => {
|
||||
const res = validateConfigObject({
|
||||
channels: {
|
||||
imessage: {
|
||||
attachmentRoots: ["./attachments"],
|
||||
},
|
||||
},
|
||||
const res = IMessageConfigSchema.safeParse({
|
||||
attachmentRoots: ["./attachments"],
|
||||
});
|
||||
|
||||
expect(res.ok).toBe(false);
|
||||
if (!res.ok) {
|
||||
expect(res.issues[0]?.path).toBe("channels.imessage.attachmentRoots.0");
|
||||
expect(res.success).toBe(false);
|
||||
if (!res.success) {
|
||||
expect(res.error.issues[0]?.path.join(".")).toBe("attachmentRoots.0");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -255,33 +253,6 @@ describe("config schema regressions", () => {
|
||||
expect(res.ok).toBe(false);
|
||||
});
|
||||
|
||||
it("accepts signal accountUuid for loop protection", () => {
|
||||
const res = validateConfigObject({
|
||||
channels: {
|
||||
signal: {
|
||||
accountUuid: "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(res.ok).toBe(true);
|
||||
});
|
||||
|
||||
it("accepts telegram actions editMessage and createForumTopic", () => {
|
||||
const res = validateConfigObject({
|
||||
channels: {
|
||||
telegram: {
|
||||
actions: {
|
||||
editMessage: true,
|
||||
createForumTopic: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(res.ok).toBe(true);
|
||||
});
|
||||
|
||||
it("accepts discovery.wideArea.domain for unicast DNS-SD", () => {
|
||||
const res = validateConfigObject({
|
||||
discovery: {
|
||||
|
||||
Reference in New Issue
Block a user