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

@@ -41,6 +41,7 @@ vi.mock("../../lib/server/rateLimit", () => ({
rateLimitKeyMock(key, minIntervalMs),
}));
import { RULE_STAKEHOLDER_INVITER_FALLBACK } from "../../lib/server/ruleStakeholderInviteMail";
import { POST } from "../../app/api/invites/rule-stakeholder/resend/route";
beforeEach(() => {
@@ -109,4 +110,39 @@ describe("POST /api/invites/rule-stakeholder/resend", () => {
}),
);
});
it("does not use a fake mailbox when the inviter and owner have no email", async () => {
findUniqueMock.mockResolvedValueOnce({
id: "st-1",
email: "inv@example.com",
inviteTokenHash: "hash-old",
inviteExpiresAt: new Date(Date.now() - 60_000),
invitedBy: null,
rule: {
title: "Juniper Street Food Share",
summary: null,
document: {},
user: { email: null },
},
});
const res = await POST(
new NextRequest("https://x.test/api/invites/rule-stakeholder/resend", {
method: "POST",
body: JSON.stringify({
token: "a".repeat(12),
email: "inv@example.com",
}),
headers: { "content-type": "application/json" },
}),
undefined,
);
expect(res.status).toBe(200);
expect(sendInviteMock).toHaveBeenCalledWith(
expect.objectContaining({
inviterEmail: RULE_STAKEHOLDER_INVITER_FALLBACK,
}),
);
});
});