From 40975ec9f1a960b378b4e7cdd38e53ef684e3fe7 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 11 Apr 2026 05:01:14 +0100 Subject: [PATCH] test: use channel schemas in config regressions --- src/config/config.schema-regressions.test.ts | 173 ++++++++----------- 1 file changed, 72 insertions(+), 101 deletions(-) diff --git a/src/config/config.schema-regressions.test.ts b/src/config/config.schema-regressions.test.ts index fa48afe74f5..8a8b004b9e2 100644 --- a/src/config/config.schema-regressions.test.ts +++ b/src/config/config.schema-regressions.test.ts @@ -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: {