Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
@@ -14,7 +14,11 @@ function jsonResponse(body: unknown, init: ResponseInit = {}) {
|
||||
}
|
||||
|
||||
function successBody(messageUuid = "uuid-123") {
|
||||
return { Messages: [{ Status: "success", To: [{ Email: "to@example.com", MessageID: 456, MessageUUID: messageUuid, MessageHref: "https://api.mailjet.com/v3/message/456" }] }] };
|
||||
return {
|
||||
Messages: [
|
||||
{ Status: "success", To: [{ Email: "to@example.com", MessageID: 456, MessageUUID: messageUuid, MessageHref: "https://api.mailjet.com/v3/message/456" }] },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
function captureError(fn: () => unknown): unknown {
|
||||
@@ -115,6 +119,41 @@ describe("MailjetProvider", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("serializes disabled tracking settings to Mailjet v3.1 flags", async () => {
|
||||
const fetchMock = vi.fn(async () => jsonResponse(successBody(), { status: 200 }));
|
||||
const provider = new MailjetProvider({
|
||||
apiKey: "api_key",
|
||||
secretKey: "secret_key",
|
||||
fromEmail: "sender@example.com",
|
||||
fetch: fetchMock as unknown as typeof fetch,
|
||||
});
|
||||
|
||||
await provider.send({
|
||||
to: ["user@example.com"],
|
||||
subject: "Portal setup",
|
||||
text: "Complete your setup",
|
||||
settings: { trackClicks: false, trackOpens: false },
|
||||
});
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledWith(
|
||||
"https://api.mailjet.com/v3.1/send",
|
||||
expect.objectContaining({
|
||||
body: JSON.stringify({
|
||||
Messages: [
|
||||
{
|
||||
From: { Email: "sender@example.com" },
|
||||
To: [{ Email: "user@example.com" }],
|
||||
Subject: "Portal setup",
|
||||
TextPart: "Complete your setup",
|
||||
TrackOpens: "disabled",
|
||||
TrackClicks: "disabled",
|
||||
},
|
||||
],
|
||||
}),
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
test("creates providers only from explicit Mailjet fixture env", async () => {
|
||||
const fetchMock = vi.fn(async () => jsonResponse(successBody("msg_fixture"), { status: 200 }));
|
||||
const provider = createMailjetProviderFromEnv({
|
||||
@@ -164,6 +203,36 @@ describe("MailjetProvider", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("preserves 64-character CustomIDs and deterministically compacts longer signup keys", async () => {
|
||||
const fetchMock = vi.fn(async (_input: Parameters<typeof fetch>[0], _init?: Parameters<typeof fetch>[1]) =>
|
||||
jsonResponse(successBody("msg_compacted"), { status: 200 })
|
||||
);
|
||||
const provider = new MailjetProvider({
|
||||
apiKey: "api_key",
|
||||
secretKey: "secret_key",
|
||||
fromEmail: "sender@example.com",
|
||||
fetch: fetchMock as unknown as typeof fetch,
|
||||
});
|
||||
const acceptedBoundary = "a".repeat(64);
|
||||
const signupKey = `mail:signup-welcome:tenant_1:${"b".repeat(64)}`;
|
||||
const distinctSignupKey = `${signupKey.slice(0, -1)}c`;
|
||||
|
||||
for (const idempotencyKey of [acceptedBoundary, signupKey, signupKey, distinctSignupKey]) {
|
||||
await provider.send({ to: ["user@example.com"], subject: "Welcome", text: "Hello", idempotencyKey });
|
||||
}
|
||||
|
||||
const customIds = fetchMock.mock.calls.map(([_, init]) => {
|
||||
const payload = JSON.parse(String(init?.body)) as { Messages: Array<{ CustomID: string }> };
|
||||
return payload.Messages[0]?.CustomID;
|
||||
});
|
||||
expect(customIds[0]).toBe(acceptedBoundary);
|
||||
expect(customIds[1]).toMatch(/^hivegrid-id:[a-f0-9]{52}$/);
|
||||
expect(customIds[1]).toBe(customIds[2]);
|
||||
expect(customIds[1]).not.toBe(customIds[3]);
|
||||
expect(customIds.every((customId) => customId !== undefined && customId.length <= 64)).toBe(true);
|
||||
expect(JSON.stringify(fetchMock.mock.calls)).not.toContain(signupKey);
|
||||
});
|
||||
|
||||
test("adds the SandboxMode flag when sandbox is enabled", async () => {
|
||||
const fetchMock = vi.fn(async () => jsonResponse(successBody(), { status: 200 }));
|
||||
const provider = new MailjetProvider({
|
||||
|
||||
Reference in new issue
Block a user