diff --git a/src/channels/channel-config.test.ts b/src/channels/channel-config.test.ts index 9af6cedc1..807a254e6 100644 --- a/src/channels/channel-config.test.ts +++ b/src/channels/channel-config.test.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from "vitest"; +import type { MsgContext } from "../auto-reply/templating.js"; import { buildChannelKeyCandidates, normalizeChannelSlug, @@ -8,6 +9,7 @@ import { applyChannelMatchMeta, resolveChannelMatchConfig, } from "./channel-config.js"; +import { validateSenderIdentity } from "./sender-identity.js"; describe("buildChannelKeyCandidates", () => { it("dedupes and trims keys", () => { @@ -118,6 +120,33 @@ describe("resolveChannelMatchConfig", () => { }); }); +describe("validateSenderIdentity", () => { + it("allows direct messages without sender fields", () => { + const ctx: MsgContext = { ChatType: "direct" }; + expect(validateSenderIdentity(ctx)).toEqual([]); + }); + + it("requires some sender identity for non-direct chats", () => { + const ctx: MsgContext = { ChatType: "group" }; + expect(validateSenderIdentity(ctx)).toContain( + "missing sender identity (SenderId/SenderName/SenderUsername/SenderE164)", + ); + }); + + it("validates SenderE164 and SenderUsername shape", () => { + const ctx: MsgContext = { + ChatType: "group", + SenderE164: "123", + SenderUsername: "@ada lovelace", + }; + expect(validateSenderIdentity(ctx)).toEqual([ + "invalid SenderE164: 123", + 'SenderUsername should not include "@": @ada lovelace', + "SenderUsername should not include whitespace: @ada lovelace", + ]); + }); +}); + describe("resolveNestedAllowlistDecision", () => { it("allows when outer allowlist is disabled", () => { expect( diff --git a/src/channels/sender-identity.test.ts b/src/channels/sender-identity.test.ts deleted file mode 100644 index 7c93821ef..000000000 --- a/src/channels/sender-identity.test.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { describe, expect, it } from "vitest"; -import type { MsgContext } from "../auto-reply/templating.js"; -import { validateSenderIdentity } from "./sender-identity.js"; - -describe("validateSenderIdentity", () => { - it("allows direct messages without sender fields", () => { - const ctx: MsgContext = { ChatType: "direct" }; - expect(validateSenderIdentity(ctx)).toEqual([]); - }); - - it("requires some sender identity for non-direct chats", () => { - const ctx: MsgContext = { ChatType: "group" }; - expect(validateSenderIdentity(ctx)).toContain( - "missing sender identity (SenderId/SenderName/SenderUsername/SenderE164)", - ); - }); - - it("validates SenderE164 and SenderUsername shape", () => { - const ctx: MsgContext = { - ChatType: "group", - SenderE164: "123", - SenderUsername: "@ada lovelace", - }; - expect(validateSenderIdentity(ctx)).toEqual([ - "invalid SenderE164: 123", - 'SenderUsername should not include "@": @ada lovelace', - "SenderUsername should not include whitespace: @ada lovelace", - ]); - }); -});