// Line tests cover config schema plugin behavior. import { describe, expect, it } from "vitest"; import { LineConfigSchema } from "./config-schema.js"; describe("LineConfigSchema", () => { it('rejects dmPolicy="open" without wildcard allowFrom', () => { const result = LineConfigSchema.safeParse({ channelAccessToken: "token", channelSecret: "secret", dmPolicy: "open", }); if (result.success) { throw new Error("Expected config validation to fail"); } expect(result.error.issues).toHaveLength(1); expect(result.error.issues[0]?.path).toEqual(["allowFrom"]); expect(result.error.issues[0]?.message).toBe( 'channels.line.dmPolicy="open" requires channels.line.allowFrom to include "*"', ); }); it('accepts dmPolicy="open" with wildcard allowFrom', () => { const result = LineConfigSchema.safeParse({ channelAccessToken: "token", channelSecret: "secret", dmPolicy: "open", allowFrom: ["*"], }); expect(result.success).toBe(true); }); it('rejects account dmPolicy="open" without wildcard allowFrom', () => { const result = LineConfigSchema.safeParse({ accounts: { work: { channelAccessToken: "token", channelSecret: "secret", dmPolicy: "open", }, }, }); if (result.success) { throw new Error("Expected account config validation to fail"); } expect(result.error.issues).toHaveLength(1); expect(result.error.issues[0]?.path).toEqual(["accounts", "work", "allowFrom"]); expect(result.error.issues[0]?.message).toBe( 'channels.line.dmPolicy="open" requires channels.line.allowFrom to include "*"', ); }); });