diff --git a/server/service/config/registry.test.ts b/server/service/config/registry.test.ts index 3cbbaec..0abe72a 100644 --- a/server/service/config/registry.test.ts +++ b/server/service/config/registry.test.ts @@ -2,6 +2,10 @@ import { describe, expect, test } from "bun:test"; import { getConfigDefinition, validateConfigValue } from "./registry"; describe("comment email config validation", () => { + test("accepts an empty commentMailFromEmail", () => { + expect(validateConfigValue("commentMailFromEmail" as never, "")).toBe(true); + }); + test("accepts a valid commentMailFromEmail", () => { expect(validateConfigValue("commentMailFromEmail" as never, "noreply@example.com")).toBe(true); }); @@ -17,16 +21,64 @@ describe("comment email config validation", () => { }); test("enforces commentSmtpPort boundaries", () => { + expect(validateConfigValue("commentSmtpPort" as never, 1)).toBe(true); + expect(validateConfigValue("commentSmtpPort" as never, 65535)).toBe(true); expect(validateConfigValue("commentSmtpPort" as never, 0)).toBe(false); expect(validateConfigValue("commentSmtpPort" as never, 65536)).toBe(false); expect(validateConfigValue("commentSmtpPort" as never, 465)).toBe(true); }); - test("defines commentNotifyEnabled as user-overridable both-scope key", () => { - const definition = getConfigDefinition("commentNotifyEnabled" as never); - expect(definition.scope).toBe("both"); - expect(definition.valueType).toBe("boolean"); - expect(definition.defaultValue).toBe(true); - expect(definition.userOverridable).toBe(true); + test("keeps metadata consistent for new global comment config keys", () => { + expect(getConfigDefinition("commentEmailNotifyEnabled" as never)).toMatchObject({ + scope: "global", + valueType: "boolean", + defaultValue: false, + userOverridable: false, + }); + expect(getConfigDefinition("commentMailFromEmail" as never)).toMatchObject({ + scope: "global", + valueType: "string", + defaultValue: "", + userOverridable: false, + }); + expect(getConfigDefinition("commentSmtpHost" as never)).toMatchObject({ + scope: "global", + valueType: "string", + defaultValue: "", + userOverridable: false, + }); + expect(getConfigDefinition("commentSmtpPort" as never)).toMatchObject({ + scope: "global", + valueType: "number", + defaultValue: 465, + userOverridable: false, + }); + expect(getConfigDefinition("commentSmtpSecure" as never)).toMatchObject({ + scope: "global", + valueType: "boolean", + defaultValue: true, + userOverridable: false, + }); + expect(getConfigDefinition("commentSmtpUser" as never)).toMatchObject({ + scope: "global", + valueType: "string", + defaultValue: "", + userOverridable: false, + }); + expect(getConfigDefinition("commentSmtpPass" as never)).toMatchObject({ + scope: "global", + valueType: "string", + defaultValue: "", + userOverridable: false, + }); + }); + + test("keeps metadata consistent for commentNotifyEnabled", () => { + expect(getConfigDefinition("commentNotifyEnabled" as never)).toMatchObject({ + scope: "both", + valueType: "boolean", + defaultValue: true, + userOverridable: true, + }); }); });