Keep a published rule when some invitation emails already went out, and only set Reply-To when the inviter address is a mailbox.

This commit is contained in:
adilallo committed 2026-11-06 09:22:06 -07:00
1 parent 3c984e00c5
commit ab6a0c807d
7 files changed
+161 -10

No files matched your search

@@ -1,13 +1,47 @@
import { describe, expect, it } from "vitest";
import {
RULE_STAKEHOLDER_INVITE_LOGO_PATH,
RULE_STAKEHOLDER_INVITER_FALLBACK,
buildRuleStakeholderInviteMail,
ruleStakeholderInviteCopyUrl,
stakeholderInviteInviterLabel,
stakeholderInviteReplyTo,
} from "../../lib/server/ruleStakeholderInviteMail";
const VERIFY_URL =
"https://communityrule.info/api/invites/rule-stakeholder/verify?token=abc";
describe("stakeholder invite reply address", () => {
it("uses a mailbox as Reply-To and keeps a missing address out of the header", () => {
expect(stakeholderInviteReplyTo(" Maya@Example.org ")).toBe(
"maya@example.org",
);
expect(stakeholderInviteReplyTo(RULE_STAKEHOLDER_INVITER_FALLBACK)).toBe(
undefined,
);
expect(stakeholderInviteReplyTo("CommunityRule")).toBe(undefined);
});
it("names a missing inviter without turning the label into an address", () => {
expect(stakeholderInviteInviterLabel("")).toBe(
RULE_STAKEHOLDER_INVITER_FALLBACK,
);
expect(stakeholderInviteInviterLabel("Maya@Example.org")).toBe(
"maya@example.org",
);
const mail = buildRuleStakeholderInviteMail({
to: "rosa@example.org",
verifyUrl: VERIFY_URL,
origin: "https://communityrule.info",
communityName: "Juniper Street Food Share",
inviterEmail: RULE_STAKEHOLDER_INVITER_FALLBACK,
});
expect(mail.text).toContain(
`${RULE_STAKEHOLDER_INVITER_FALLBACK} sent the invitation.`,
);
});
});
describe("ruleStakeholderInviteCopyUrl", () => {
it("adds copy=1 to the invitation link", () => {
expect(ruleStakeholderInviteCopyUrl(VERIFY_URL)).toBe(