Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+52
@@ -0,0 +1,52 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { parseMailjetSuppressionSignal } from "./mailjet-suppression.js";
|
||||
|
||||
const tenantPayload = JSON.stringify({ t: "tenant-1" });
|
||||
|
||||
describe("parseMailjetSuppressionSignal", () => {
|
||||
it("suppresses a hard bounce with a JSON tenant payload", () => {
|
||||
const body = JSON.stringify({ event: "bounce", email: "Hard@Bounce.test", Payload: tenantPayload, error: "user unknown" });
|
||||
expect(parseMailjetSuppressionSignal(body)).toEqual({
|
||||
action: "suppress",
|
||||
tenantId: "tenant-1",
|
||||
emailAddress: "Hard@Bounce.test",
|
||||
suppressionReason: "bounce",
|
||||
detail: "bounce: user unknown",
|
||||
});
|
||||
});
|
||||
|
||||
it("classifies a spam event as a complaint", () => {
|
||||
const body = JSON.stringify({ event: "spam", email: "a@x.test", CustomID: "tenant-9" });
|
||||
expect(parseMailjetSuppressionSignal(body)).toMatchObject({ action: "suppress", tenantId: "tenant-9", suppressionReason: "complaint" });
|
||||
});
|
||||
|
||||
it("accepts a bare tenant id in the payload", () => {
|
||||
const body = JSON.stringify({ event: "blocked", email: "a@x.test", Payload: "tenant-7" });
|
||||
expect(parseMailjetSuppressionSignal(body)).toMatchObject({ action: "suppress", tenantId: "tenant-7", suppressionReason: "bounce" });
|
||||
});
|
||||
|
||||
it("folds a batched array to its first event", () => {
|
||||
const body = JSON.stringify([{ event: "bounce", email: "a@x.test", Payload: tenantPayload }]);
|
||||
expect(parseMailjetSuppressionSignal(body)).toMatchObject({ action: "suppress", tenantId: "tenant-1" });
|
||||
});
|
||||
|
||||
it("ignores non-suppression events", () => {
|
||||
expect(parseMailjetSuppressionSignal(JSON.stringify({ event: "open", email: "a@x.test", Payload: tenantPayload }))).toEqual({
|
||||
action: "ignore",
|
||||
reason: "non-suppression-event:open",
|
||||
});
|
||||
});
|
||||
|
||||
it("ignores a bounce whose tenant cannot be resolved", () => {
|
||||
expect(parseMailjetSuppressionSignal(JSON.stringify({ event: "bounce", email: "a@x.test" }))).toEqual({ action: "ignore", reason: "unresolved-tenant" });
|
||||
});
|
||||
|
||||
it("ignores a bounce with no recipient", () => {
|
||||
expect(parseMailjetSuppressionSignal(JSON.stringify({ event: "bounce", Payload: tenantPayload }))).toEqual({ action: "ignore", reason: "missing-email" });
|
||||
});
|
||||
|
||||
it("ignores invalid JSON", () => {
|
||||
expect(parseMailjetSuppressionSignal("not json")).toEqual({ action: "ignore", reason: "invalid-json" });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user