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
@@ -1,4 +1,4 @@
|
||||
# @toolctrl/mail
|
||||
# @hivegrid/mail
|
||||
|
||||
Source-only mail provider boundary for queued transactional delivery.
|
||||
|
||||
@@ -9,7 +9,7 @@ This package provides the Mailjet adapter used by the worker mail runtime. Web a
|
||||
`MailProvider` exposes one delivery method:
|
||||
|
||||
```ts
|
||||
import { createMailjetProviderFromEnv } from "@toolctrl/mail";
|
||||
import { createMailjetProviderFromEnv } from "@hivegrid/mail";
|
||||
|
||||
const mail = createMailjetProviderFromEnv();
|
||||
|
||||
@@ -35,6 +35,6 @@ Required in the worker environment when Mailjet delivery is enabled:
|
||||
|
||||
## Runtime Boundary
|
||||
|
||||
- Web/API transactional send paths enqueue `toolctrl.email` jobs through `@toolctrl/queue`.
|
||||
- Web/API transactional send paths enqueue `hivegrid.email` jobs through `@hivegrid/queue`.
|
||||
- Worker handlers instantiate `createMailjetProviderFromEnv` and deliver queued jobs.
|
||||
- Do not add provider credentials, SDKs, or direct Mailjet calls to route modules.
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "@toolctrl/mail",
|
||||
"name": "@hivegrid/mail",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
@@ -16,8 +16,8 @@
|
||||
"dependencies": {
|
||||
"@react-email/components": "^0.5.6",
|
||||
"@react-email/render": "^1.3.2",
|
||||
"@toolctrl/brand": "workspace:*",
|
||||
"@toolctrl/queue": "workspace:*",
|
||||
"@hivegrid/brand": "workspace:*",
|
||||
"@hivegrid/queue": "workspace:*",
|
||||
"react": "19.2.3",
|
||||
"react-dom": "19.2.3"
|
||||
},
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
/**
|
||||
* Local React-Email preview server.
|
||||
*
|
||||
* Run via `pnpm --filter @toolctrl/mail preview` and visit
|
||||
* Run via `pnpm --filter @hivegrid/mail preview` and visit
|
||||
* http://localhost:3001 — the index lists every transactional
|
||||
* template; clicking a name renders the template with the sample
|
||||
* props from `previews.ts` so designers can iterate without
|
||||
* triggering live email sends.
|
||||
*
|
||||
* Intentionally tiny — uses Node's built-in `http` server so the
|
||||
* mail package keeps a small dep footprint. For production-grade
|
||||
* preview workflows (visual-regression diffing, screenshot capture)
|
||||
* mount the React-Email components in Storybook (Phase 08).
|
||||
* Intentionally tiny: uses Node's built-in `http` server so the
|
||||
* mail package keeps a small dep footprint.
|
||||
*/
|
||||
import { createServer, type IncomingMessage, type ServerResponse } from "node:http";
|
||||
import { reactTransactionalTemplateNames, renderTransactionalEmail } from "../src/templates-react/render.js";
|
||||
|
||||
@@ -7,7 +7,7 @@ import { withBrandDefaults } from "../src/templates-react/_layout/theme.js";
|
||||
import type { ReactTemplatePropsMap } from "../src/templates-react/render.js";
|
||||
|
||||
const brand = withBrandDefaults({
|
||||
productName: "ToolCTRL",
|
||||
productName: "HiveGrid",
|
||||
tenantName: "Acme Inc",
|
||||
primaryColor: "#2563eb",
|
||||
});
|
||||
@@ -60,7 +60,7 @@ export const samplePropsByTemplate: { [K in keyof ReactTemplatePropsMap]: ReactT
|
||||
amountFormatted: "€99.00",
|
||||
issueDate: "2026-05-17",
|
||||
dueDate: "2026-06-17",
|
||||
actionUrl: "https://invoice.stripe.com/i/abc",
|
||||
actionUrl: "https://invoice.mollie.com/i/abc",
|
||||
},
|
||||
"tenant-notification": {
|
||||
brand,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
export { createMailjetProvider, createMailjetProviderFromEnv, mailjetApiBaseUrl, MailjetProvider } from "./mailjet.js";
|
||||
export { createQueuedMailProvider, createQueuedMailProviderFromEnv, QueuedMailProvider } from "./queue.js";
|
||||
export { createMailjetDnsProvisioner } from "./mailjet-dns.js";
|
||||
export type { MailjetDnsProvisioner, MailjetDnsProvisionerOptions, MailjetDnsRecords, MailjetRecordStatus } from "./mailjet-dns.js";
|
||||
export type { QueueMailProviderEnv, QueueMailProviderFromEnvOptions, QueueMailProviderOptions, QueueMailProviderWarning } from "./queue.js";
|
||||
export type { MailjetEnv, MailjetProviderOptions, MailMetricsHook } from "./mailjet.js";
|
||||
export type {
|
||||
@@ -19,7 +21,7 @@ export { MailProviderError } from "./types.js";
|
||||
|
||||
// React-Email transactional templates — the canonical render API. The
|
||||
// pre-19 string-template renderer (`renderTransactionalMailTemplate`)
|
||||
// was retired alongside the Stripe-19 cleanup; downstream callers that
|
||||
// was retired alongside the React-Email cleanup; downstream callers that
|
||||
// need a translator-bound function should go through the host
|
||||
// application (see apps/web/app/locale/mail-translator.server.ts).
|
||||
export {
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { createMailjetDnsProvisioner } from "./mailjet-dns.js";
|
||||
import { MailProviderError } from "./types.js";
|
||||
|
||||
function jsonResponse(body: unknown, status = 200): Response {
|
||||
return new Response(JSON.stringify(body), { status, headers: { "Content-Type": "application/json" } });
|
||||
}
|
||||
|
||||
const DNS_PAYLOAD = {
|
||||
Count: 1,
|
||||
Data: [
|
||||
{
|
||||
ID: 12345,
|
||||
DKIMRecordName: "mailjet._domainkey.acme.test",
|
||||
DKIMRecordValue: "v=DKIM1; k=rsa; p=MIIB...",
|
||||
SPFRecordValue: "v=spf1 include:spf.mailjet.com ~all",
|
||||
DKIMStatus: "OK",
|
||||
SPFStatus: "Error",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
describe("createMailjetDnsProvisioner", () => {
|
||||
it("sends Basic auth and reads back normalized DKIM/SPF records", async () => {
|
||||
const fetchImpl = vi.fn<(url: string, init?: RequestInit) => Promise<Response>>(async () => jsonResponse(DNS_PAYLOAD));
|
||||
const provisioner = createMailjetDnsProvisioner({ apiKey: "key", secretKey: "secret", fetch: fetchImpl as unknown as typeof fetch });
|
||||
|
||||
const records = await provisioner.getRecords("acme.test");
|
||||
|
||||
expect(records).toEqual({
|
||||
dnsId: "12345",
|
||||
dkimSelector: "mailjet._domainkey.acme.test",
|
||||
dkimRecord: "v=DKIM1; k=rsa; p=MIIB...",
|
||||
spfRecord: "v=spf1 include:spf.mailjet.com ~all",
|
||||
dkimStatus: "ok",
|
||||
spfStatus: "error",
|
||||
});
|
||||
const [url, init] = fetchImpl.mock.calls[0]!;
|
||||
expect(url).toBe("https://api.mailjet.com/v3/REST/dns/acme.test");
|
||||
expect(init?.headers).toMatchObject({ Authorization: `Basic ${Buffer.from("key:secret").toString("base64")}` });
|
||||
});
|
||||
|
||||
it("registers a wildcard sender for the domain and tolerates a 400 (already exists)", async () => {
|
||||
const fetchImpl = vi.fn<(url: string, init?: RequestInit) => Promise<Response>>(async () => jsonResponse({ ErrorMessage: "already exists" }, 400));
|
||||
const provisioner = createMailjetDnsProvisioner({ apiKey: "k", secretKey: "s", fetch: fetchImpl as unknown as typeof fetch });
|
||||
|
||||
await expect(provisioner.registerDomain("acme.test")).resolves.toEqual({ ok: true });
|
||||
const [url, init] = fetchImpl.mock.calls[0]!;
|
||||
expect(url).toBe("https://api.mailjet.com/v3/REST/sender");
|
||||
expect(JSON.parse(init?.body as string)).toEqual({ Email: "*@acme.test", IsDefaultSender: false });
|
||||
});
|
||||
|
||||
it("maps a check response to per-record status", async () => {
|
||||
const fetchImpl = vi.fn(async () => jsonResponse(DNS_PAYLOAD));
|
||||
const provisioner = createMailjetDnsProvisioner({ apiKey: "k", secretKey: "s", fetch: fetchImpl as unknown as typeof fetch });
|
||||
await expect(provisioner.check("acme.test")).resolves.toEqual({ dkimStatus: "ok", spfStatus: "error" });
|
||||
});
|
||||
|
||||
it("throws a MailProviderError on a non-400 failure", async () => {
|
||||
const fetchImpl = vi.fn(async () => jsonResponse({ error: "server" }, 500));
|
||||
const provisioner = createMailjetDnsProvisioner({ apiKey: "k", secretKey: "s", fetch: fetchImpl as unknown as typeof fetch });
|
||||
await expect(provisioner.getRecords("acme.test")).rejects.toBeInstanceOf(MailProviderError);
|
||||
});
|
||||
|
||||
it("returns pending defaults when Mailjet returns no data rows", async () => {
|
||||
const fetchImpl = vi.fn(async () => jsonResponse({ Count: 0, Data: [] }));
|
||||
const provisioner = createMailjetDnsProvisioner({ apiKey: "k", secretKey: "s", fetch: fetchImpl as unknown as typeof fetch });
|
||||
await expect(provisioner.getRecords("acme.test")).resolves.toMatchObject({ dkimStatus: "pending", spfStatus: "pending", dkimRecord: null });
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,132 @@
|
||||
// AK-P14a · P14 Email — per-tenant Mailjet sending-domain provisioning seam.
|
||||
//
|
||||
// The SMTP-provider abstraction for sending domains (AD-6, EU provider = Mailjet,
|
||||
// no US-core dependency). A tenant adds a domain → we register a Mailjet sender
|
||||
// for it and read back the DKIM/SPF records the tenant must publish (Mailjet
|
||||
// generates + holds the DKIM key, so no private key is stored on our side). The
|
||||
// 5-minute worker probe (email-domain-probe-cron) verifies the published records
|
||||
// against live DNS; `check()` here additionally asks Mailjet to re-validate.
|
||||
//
|
||||
// Behind a typed interface so the host app depends on the capability, not the
|
||||
// HTTP shape, and the unit tests inject a fake fetch. Basic auth mirrors
|
||||
// MailjetProvider (apiKey:secretKey, base64).
|
||||
|
||||
import { MailProviderError } from "./types.js";
|
||||
|
||||
export const mailjetApiBaseUrl = "https://api.mailjet.com";
|
||||
const DEFAULT_TIMEOUT_MS = 10_000;
|
||||
|
||||
type Fetch = typeof fetch;
|
||||
|
||||
/** Mailjet per-record status, normalized to our verification vocabulary. */
|
||||
export type MailjetRecordStatus = "ok" | "pending" | "error";
|
||||
|
||||
/** The DNS records a tenant must publish, as returned by Mailjet. */
|
||||
export type MailjetDnsRecords = {
|
||||
dnsId: string | null;
|
||||
dkimSelector: string | null;
|
||||
dkimRecord: string | null;
|
||||
spfRecord: string | null;
|
||||
dkimStatus: MailjetRecordStatus;
|
||||
spfStatus: MailjetRecordStatus;
|
||||
};
|
||||
|
||||
export type MailjetDnsProvisioner = {
|
||||
/** Register a sending domain (idempotent on Mailjet's side). */
|
||||
registerDomain(domain: string): Promise<{ ok: true }>;
|
||||
/** Read the DKIM/SPF records + current Mailjet status for a domain. */
|
||||
getRecords(domain: string): Promise<MailjetDnsRecords>;
|
||||
/** Ask Mailjet to re-validate the domain's DNS now. */
|
||||
check(domain: string): Promise<{ dkimStatus: MailjetRecordStatus; spfStatus: MailjetRecordStatus }>;
|
||||
};
|
||||
|
||||
export type MailjetDnsProvisionerOptions = {
|
||||
apiKey: string;
|
||||
secretKey: string;
|
||||
baseUrl?: string;
|
||||
fetch?: Fetch;
|
||||
timeoutMs?: number;
|
||||
};
|
||||
|
||||
function normalizeStatus(raw: unknown): MailjetRecordStatus {
|
||||
const value = typeof raw === "string" ? raw.trim().toLowerCase() : "";
|
||||
if (value === "ok") return "ok";
|
||||
if (value === "error") return "error";
|
||||
return "pending";
|
||||
}
|
||||
|
||||
function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === "object" && value !== null;
|
||||
}
|
||||
|
||||
function readString(value: unknown): string | null {
|
||||
return typeof value === "string" && value.trim() ? value.trim() : null;
|
||||
}
|
||||
|
||||
export function createMailjetDnsProvisioner(options: MailjetDnsProvisionerOptions): MailjetDnsProvisioner {
|
||||
const authorization = `Basic ${Buffer.from(`${options.apiKey}:${options.secretKey}`, "utf8").toString("base64")}`;
|
||||
const baseUrl = (options.baseUrl ?? mailjetApiBaseUrl).replace(/\/+$/, "");
|
||||
const fetchImpl = options.fetch ?? fetch;
|
||||
const timeoutMs = options.timeoutMs && options.timeoutMs > 0 ? options.timeoutMs : DEFAULT_TIMEOUT_MS;
|
||||
|
||||
async function request(method: string, path: string, body?: unknown): Promise<unknown> {
|
||||
const controller = new AbortController();
|
||||
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
||||
let response: Response;
|
||||
try {
|
||||
response = await fetchImpl(`${baseUrl}${path}`, {
|
||||
method,
|
||||
headers: { Authorization: authorization, "Content-Type": "application/json", Accept: "application/json" },
|
||||
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
|
||||
signal: controller.signal,
|
||||
});
|
||||
} catch (error) {
|
||||
if (error instanceof Error && error.name === "AbortError") {
|
||||
throw new MailProviderError("Mailjet DNS request timed out.", { provider: "mailjet" });
|
||||
}
|
||||
throw error;
|
||||
} finally {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
// 400 on register often means "already exists" — treat as success upstream.
|
||||
if (!response.ok && response.status !== 400) {
|
||||
throw new MailProviderError(`Mailjet DNS request failed with ${response.status}.`, { provider: "mailjet", statusCode: response.status });
|
||||
}
|
||||
try {
|
||||
return (await response.json()) as unknown;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function parseRecords(payload: unknown): MailjetDnsRecords {
|
||||
const data = isRecord(payload) && Array.isArray(payload["Data"]) ? payload["Data"][0] : undefined;
|
||||
if (!isRecord(data)) {
|
||||
return { dnsId: null, dkimSelector: null, dkimRecord: null, spfRecord: null, dkimStatus: "pending", spfStatus: "pending" };
|
||||
}
|
||||
return {
|
||||
dnsId: readString(data["ID"]) ?? (typeof data["ID"] === "number" ? String(data["ID"]) : null),
|
||||
dkimSelector: readString(data["DKIMRecordName"]),
|
||||
dkimRecord: readString(data["DKIMRecordValue"]),
|
||||
spfRecord: readString(data["SPFRecordValue"]),
|
||||
dkimStatus: normalizeStatus(data["DKIMStatus"]),
|
||||
spfStatus: normalizeStatus(data["SPFStatus"]),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
async registerDomain(domain) {
|
||||
// A Mailjet "sender" for the wildcard domain registers it for DNS setup.
|
||||
await request("POST", "/v3/REST/sender", { Email: `*@${domain}`, IsDefaultSender: false });
|
||||
return { ok: true };
|
||||
},
|
||||
async getRecords(domain) {
|
||||
return parseRecords(await request("GET", `/v3/REST/dns/${encodeURIComponent(domain)}`));
|
||||
},
|
||||
async check(domain) {
|
||||
const payload = await request("POST", `/v3/REST/dns/${encodeURIComponent(domain)}/check`);
|
||||
const records = parseRecords(payload);
|
||||
return { dkimStatus: records.dkimStatus, spfStatus: records.spfStatus };
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
import { describe, expect, test, vi } from "vitest";
|
||||
import { createMailjetProvider, createMailjetProviderFromEnv, MailjetProvider } from "./mailjet.js";
|
||||
import { MailProviderError } from "./types.js";
|
||||
|
||||
type FetchMock = ReturnType<typeof vi.fn>;
|
||||
|
||||
function jsonResponse(body: unknown, init: ResponseInit = {}) {
|
||||
return new Response(JSON.stringify(body), {
|
||||
headers: { "content-type": "application/json", ...init.headers },
|
||||
...init,
|
||||
});
|
||||
}
|
||||
|
||||
function successBody(messageUuid = "uuid-123") {
|
||||
return {
|
||||
Messages: [
|
||||
{
|
||||
Status: "success",
|
||||
To: [{ Email: "to@example.com", MessageID: 456, MessageUUID: messageUuid }],
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
/** Parse the JSON body that was passed to the mocked fetch on its first call. */
|
||||
function sentPayload(fetchMock: FetchMock): {
|
||||
Messages: Array<Record<string, unknown>>;
|
||||
SandboxMode?: boolean;
|
||||
} {
|
||||
const init = fetchMock.mock.calls[0]?.[1] as RequestInit | undefined;
|
||||
if (!init || typeof init.body !== "string") {
|
||||
throw new Error("fetch was not called with a string body");
|
||||
}
|
||||
return JSON.parse(init.body);
|
||||
}
|
||||
|
||||
function provider(fetchMock: FetchMock, overrides: Partial<Parameters<typeof createMailjetProvider>[0]> = {}) {
|
||||
return new MailjetProvider({
|
||||
apiKey: "api_key",
|
||||
secretKey: "secret_key",
|
||||
fromEmail: "sender@example.com",
|
||||
fetch: fetchMock as unknown as typeof fetch,
|
||||
...overrides,
|
||||
});
|
||||
}
|
||||
|
||||
describe("createMailjetProvider factory", () => {
|
||||
test("returns a working provider that posts to the Mailjet send endpoint", async () => {
|
||||
const fetchMock = vi.fn(async () => jsonResponse(successBody("uuid-factory"), { status: 200 }));
|
||||
const mailer = createMailjetProvider({
|
||||
apiKey: "api_key",
|
||||
secretKey: "secret_key",
|
||||
fromEmail: "sender@example.com",
|
||||
fetch: fetchMock as unknown as typeof fetch,
|
||||
});
|
||||
|
||||
await expect(mailer.send({ to: ["user@example.com"], subject: "Hi", text: "Body" })).resolves.toMatchObject({
|
||||
provider: "mailjet",
|
||||
status: "queued",
|
||||
messageId: "uuid-factory",
|
||||
});
|
||||
expect(fetchMock).toHaveBeenCalledWith("https://api.mailjet.com/v3.1/send", expect.any(Object));
|
||||
});
|
||||
});
|
||||
|
||||
describe("MailjetProvider content validation", () => {
|
||||
test("rejects a send with neither text, html nor templateId before calling Mailjet", async () => {
|
||||
const fetchMock = vi.fn();
|
||||
await expect(provider(fetchMock).send({ to: ["user@example.com"], subject: "Empty" })).rejects.toMatchObject({
|
||||
provider: "mailjet",
|
||||
message: "Email text, html or templateId is required.",
|
||||
} satisfies Partial<MailProviderError>);
|
||||
expect(fetchMock).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("MailjetProvider per-recipient personalization", () => {
|
||||
test("splits into one message per recipient and copies Cc/Bcc only onto the first", async () => {
|
||||
const fetchMock = vi.fn(async () => jsonResponse(successBody(), { status: 200 }));
|
||||
await provider(fetchMock).send({
|
||||
to: ["first@example.com", "second@example.com"],
|
||||
cc: ["cc@example.com"],
|
||||
bcc: ["bcc@example.com"],
|
||||
subject: "Digest",
|
||||
text: "Body",
|
||||
personalization: [
|
||||
{ email: "first@example.com", data: { firstName: "Ada" } },
|
||||
{ email: "second@example.com", data: { firstName: "Grace" } },
|
||||
],
|
||||
});
|
||||
|
||||
const { Messages } = sentPayload(fetchMock);
|
||||
expect(Messages).toHaveLength(2);
|
||||
expect(Messages[0]).toMatchObject({
|
||||
To: [{ Email: "first@example.com" }],
|
||||
Variables: { firstName: "Ada" },
|
||||
Cc: [{ Email: "cc@example.com" }],
|
||||
Bcc: [{ Email: "bcc@example.com" }],
|
||||
});
|
||||
expect(Messages[1]).toMatchObject({
|
||||
To: [{ Email: "second@example.com" }],
|
||||
Variables: { firstName: "Grace" },
|
||||
});
|
||||
// Shared recipients must not be duplicated onto every personalized copy.
|
||||
expect(Messages[1]).not.toHaveProperty("Cc");
|
||||
expect(Messages[1]).not.toHaveProperty("Bcc");
|
||||
});
|
||||
});
|
||||
|
||||
describe("MailjetProvider attachment mapping", () => {
|
||||
test("routes inline attachments to InlinedAttachments with a ContentID and omits the regular bucket", async () => {
|
||||
const fetchMock = vi.fn(async () => jsonResponse(successBody(), { status: 200 }));
|
||||
await provider(fetchMock).send({
|
||||
to: ["user@example.com"],
|
||||
subject: "Logo",
|
||||
html: "<p>x</p>",
|
||||
attachments: [
|
||||
{ content: "YWJj", filename: "logo.png", disposition: "inline", id: "logo-cid" },
|
||||
{ content: "ZGVm", filename: "header.png", disposition: "inline" },
|
||||
],
|
||||
});
|
||||
|
||||
const message = sentPayload(fetchMock).Messages[0]!;
|
||||
expect(message).not.toHaveProperty("Attachments");
|
||||
expect(message.InlinedAttachments).toEqual([
|
||||
{ ContentType: "image/png", Filename: "logo.png", Base64Content: "YWJj", ContentID: "logo-cid" },
|
||||
// Falls back to the filename when no explicit Content-ID is provided.
|
||||
{ ContentType: "image/png", Filename: "header.png", Base64Content: "ZGVm", ContentID: "header.png" },
|
||||
]);
|
||||
});
|
||||
|
||||
test("keeps regular and inline attachments in separate buckets", async () => {
|
||||
const fetchMock = vi.fn(async () => jsonResponse(successBody(), { status: 200 }));
|
||||
await provider(fetchMock).send({
|
||||
to: ["user@example.com"],
|
||||
subject: "Mixed",
|
||||
html: "<p>x</p>",
|
||||
attachments: [
|
||||
{ content: "YWJj", filename: "report.pdf", disposition: "attachment" },
|
||||
{ content: "ZGVm", filename: "logo.png", disposition: "inline", id: "logo" },
|
||||
],
|
||||
});
|
||||
|
||||
const message = sentPayload(fetchMock).Messages[0]!;
|
||||
expect(message.Attachments).toEqual([
|
||||
{ ContentType: "application/pdf", Filename: "report.pdf", Base64Content: "YWJj" },
|
||||
]);
|
||||
expect(message.InlinedAttachments).toEqual([
|
||||
{ ContentType: "image/png", Filename: "logo.png", Base64Content: "ZGVm", ContentID: "logo" },
|
||||
]);
|
||||
});
|
||||
|
||||
test("falls back to application/octet-stream for missing and unknown extensions", async () => {
|
||||
const fetchMock = vi.fn(async () => jsonResponse(successBody(), { status: 200 }));
|
||||
await provider(fetchMock).send({
|
||||
to: ["user@example.com"],
|
||||
subject: "Files",
|
||||
html: "<p>x</p>",
|
||||
attachments: [
|
||||
{ content: "YWJj", filename: "noextension" },
|
||||
{ content: "ZGVm", filename: "archive.unknownext" },
|
||||
],
|
||||
});
|
||||
|
||||
const types = (sentPayload(fetchMock).Messages[0]!.Attachments as Array<{ ContentType: string }>).map(
|
||||
(a) => a.ContentType
|
||||
);
|
||||
expect(types).toEqual(["application/octet-stream", "application/octet-stream"]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("MailjetProvider response parsing edge cases", () => {
|
||||
test("uses the numeric MessageID when no MessageUUID is present", async () => {
|
||||
const fetchMock = vi.fn(async () =>
|
||||
jsonResponse({ Messages: [{ Status: "success", To: [{ Email: "to@example.com", MessageID: 789 }] }] }, { status: 200 })
|
||||
);
|
||||
await expect(provider(fetchMock).send({ to: ["to@example.com"], subject: "x", text: "y" })).resolves.toMatchObject({
|
||||
messageId: "789",
|
||||
});
|
||||
});
|
||||
|
||||
test("returns an undefined messageId when the recipient list is empty", async () => {
|
||||
const fetchMock = vi.fn(async () => jsonResponse({ Messages: [{ Status: "success", To: [] }] }, { status: 200 }));
|
||||
const result = await provider(fetchMock).send({ to: ["to@example.com"], subject: "x", text: "y" });
|
||||
expect(result.messageId).toBeUndefined();
|
||||
expect(result.status).toBe("queued");
|
||||
});
|
||||
|
||||
test("returns an undefined messageId when the recipient carries neither UUID nor MessageID", async () => {
|
||||
const fetchMock = vi.fn(async () =>
|
||||
jsonResponse({ Messages: [{ Status: "success", To: [{ Email: "to@example.com" }] }] }, { status: 200 })
|
||||
);
|
||||
const result = await provider(fetchMock).send({ to: ["to@example.com"], subject: "x", text: "y" });
|
||||
expect(result.messageId).toBeUndefined();
|
||||
expect(result.status).toBe("queued");
|
||||
});
|
||||
|
||||
test("accepts a 2xx response with no body and reports a queued send", async () => {
|
||||
const fetchMock = vi.fn(async () => new Response(null, { status: 200 }));
|
||||
const result = await provider(fetchMock).send({ to: ["to@example.com"], subject: "x", text: "y" });
|
||||
expect(result).toEqual({ provider: "mailjet", status: "queued", messageId: undefined });
|
||||
});
|
||||
|
||||
test("tolerates a 2xx body whose Messages field is not an array", async () => {
|
||||
const fetchMock = vi.fn(async () => jsonResponse({ Messages: "not-an-array" }, { status: 200 }));
|
||||
const result = await provider(fetchMock).send({ to: ["to@example.com"], subject: "x", text: "y" });
|
||||
expect(result.messageId).toBeUndefined();
|
||||
expect(result.status).toBe("queued");
|
||||
});
|
||||
});
|
||||
|
||||
describe("createMailjetProviderFromEnv passthrough options", () => {
|
||||
test("wires onMetric and sandbox from the options bag", async () => {
|
||||
const fetchMock = vi.fn(async () => jsonResponse(successBody("uuid-env"), { status: 200 }));
|
||||
const samples: Array<{ provider: string; status: string }> = [];
|
||||
const mailer = createMailjetProviderFromEnv(
|
||||
{
|
||||
MAILJET_API_KEY: "k",
|
||||
MAILJET_SECRET_KEY: "s",
|
||||
MAILJET_FROM_EMAIL: "sender@example.com",
|
||||
},
|
||||
{ onMetric: (sample) => samples.push(sample), sandbox: true }
|
||||
) as MailjetProvider;
|
||||
Object.defineProperty(mailer, "fetchImpl", { value: fetchMock });
|
||||
|
||||
await mailer.send({ to: ["user@example.com"], subject: "x", text: "y" });
|
||||
|
||||
expect(samples).toEqual([{ provider: "mailjet", status: "delivered" }]);
|
||||
expect(sentPayload(fetchMock).SandboxMode).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,62 @@
|
||||
import { describe, expect, test, vi } from "vitest";
|
||||
import { queueNames, type TypedQueue } from "@hivegrid/queue";
|
||||
import { createQueuedMailProvider } from "./queue.js";
|
||||
import { MailProviderError } from "./types.js";
|
||||
|
||||
function createQueueMock() {
|
||||
return {
|
||||
add: vi.fn(async () => ({ id: "job_123" })),
|
||||
close: vi.fn(async () => undefined),
|
||||
} as unknown as TypedQueue<typeof queueNames.email> & {
|
||||
add: ReturnType<typeof vi.fn>;
|
||||
close: ReturnType<typeof vi.fn>;
|
||||
};
|
||||
}
|
||||
|
||||
describe("QueuedMailProvider recipient validation", () => {
|
||||
test("rejects an empty recipient list before building a job descriptor", async () => {
|
||||
const queue = createQueueMock();
|
||||
const provider = createQueuedMailProvider({ queue });
|
||||
|
||||
await expect(provider.send({ to: [], subject: "Welcome", text: "Hello" })).rejects.toMatchObject({
|
||||
provider: "queue",
|
||||
message: "At least one recipient is required.",
|
||||
} satisfies Partial<MailProviderError>);
|
||||
expect(queue.add).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("QueuedMailProvider sendAt normalization", () => {
|
||||
test("passes a numeric unix-seconds sendAt through unchanged", async () => {
|
||||
const queue = createQueueMock();
|
||||
const provider = createQueuedMailProvider({ queue });
|
||||
const epochSeconds = 1_778_580_000;
|
||||
|
||||
await provider.send({ to: ["user@example.com"], subject: "Later", text: "Hello", sendAt: epochSeconds });
|
||||
|
||||
expect(queue.add).toHaveBeenCalledWith(
|
||||
"send-transactional-email",
|
||||
expect.objectContaining({ sendAt: epochSeconds }),
|
||||
expect.any(Object)
|
||||
);
|
||||
});
|
||||
|
||||
test("converts a Date sendAt to floored unix seconds", async () => {
|
||||
const queue = createQueueMock();
|
||||
const provider = createQueuedMailProvider({ queue });
|
||||
|
||||
await provider.send({
|
||||
to: ["user@example.com"],
|
||||
subject: "Later",
|
||||
text: "Hello",
|
||||
// 1.999s past the second boundary must floor down, not round up.
|
||||
sendAt: new Date(1_778_580_001_999),
|
||||
});
|
||||
|
||||
expect(queue.add).toHaveBeenCalledWith(
|
||||
"send-transactional-email",
|
||||
expect.objectContaining({ sendAt: 1_778_580_001 }),
|
||||
expect.any(Object)
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,9 +1,9 @@
|
||||
import { describe, expect, test, vi } from "vitest";
|
||||
import { queueNames, type QueueEnqueueOptions, type TypedQueue } from "@toolctrl/queue";
|
||||
import { queueNames, type QueueEnqueueOptions, type TypedQueue } from "@hivegrid/queue";
|
||||
import { createQueuedMailProvider as createQueuedMailProviderFromIndex } from "./index.js";
|
||||
import { createQueuedMailProvider, createQueuedMailProviderFromEnv } from "./queue.js";
|
||||
|
||||
vi.mock("@toolctrl/queue/runtime", () => ({
|
||||
vi.mock("@hivegrid/queue/runtime", () => ({
|
||||
createQueue: vi.fn(),
|
||||
}));
|
||||
|
||||
@@ -193,7 +193,7 @@ describe("QueuedMailProvider", () => {
|
||||
});
|
||||
|
||||
test("closes only internally-created queues after enqueue attempts", async () => {
|
||||
const { createQueue } = await import("@toolctrl/queue/runtime");
|
||||
const { createQueue } = await import("@hivegrid/queue/runtime");
|
||||
const injectedQueue = createQueueMock();
|
||||
const internalQueue = createQueueMock();
|
||||
vi.mocked(createQueue).mockReturnValueOnce(internalQueue);
|
||||
@@ -210,7 +210,7 @@ describe("QueuedMailProvider", () => {
|
||||
});
|
||||
|
||||
test("closes internally-created queues when enqueue fails", async () => {
|
||||
const { createQueue } = await import("@toolctrl/queue/runtime");
|
||||
const { createQueue } = await import("@hivegrid/queue/runtime");
|
||||
const internalQueue = createQueueMock();
|
||||
const error = new Error("enqueue failed");
|
||||
internalQueue.add.mockRejectedValueOnce(error);
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
type ConnectionOptions,
|
||||
type RedisConnectionEnv,
|
||||
type TypedQueue,
|
||||
} from "@toolctrl/queue";
|
||||
} from "@hivegrid/queue";
|
||||
import { MailProviderError, type MailPersonalization, type MailProvider, type SendMailInput, type SendMailResult } from "./types.js";
|
||||
|
||||
export type QueueMailProviderWarning = {
|
||||
@@ -85,7 +85,7 @@ class LazyQueuedMailProvider implements MailProvider {
|
||||
) {}
|
||||
|
||||
async send(input: SendMailInput): Promise<SendMailResult> {
|
||||
const { createQueue } = await import("@toolctrl/queue/runtime");
|
||||
const { createQueue } = await import("@hivegrid/queue/runtime");
|
||||
const queue = createQueue(queueNames.email, { connection: this.connection });
|
||||
try {
|
||||
return await new QueuedMailProvider({ queue, enqueueOptions: this.enqueueOptions }).send(input);
|
||||
|
||||
+5
-5
@@ -1,14 +1,14 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`BaseLayout > applies tenant brand overrides (logo + primary color) 1`] = `"<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="image" href="https://cdn.acme.test/logo.png"/><title>Hi</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;font-size:16px;line-height:1.5"><div style="display:none;font-size:1px;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden">snippet</div><div style="width:100%;max-width:560px;margin:0 auto;padding:24px 16px"><div style="background-color:#ffffff;border:1px solid #e2e8f0;border-radius:20px;padding:32px"><div style="padding-bottom:16px;text-align:left"><img src="https://cdn.acme.test/logo.png" alt="Acme" width="48" height="48" style="display:block;border:0;border-radius:12px"/></div><p>Body</p><div style="margin-top:24px;padding-top:16px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e2e8f0;color:#475569"><div><a href="https://tool-ctrl.de/privacy" style="text-decoration:underline;color:#2563eb">Privacy</a><span style="margin:0 6px">·</span><a href="https://tool-ctrl.de/terms" style="text-decoration:underline;color:#2563eb">Terms</a><span style="margin:0 6px">·</span><a href="https://tool-ctrl.de/imprint" style="text-decoration:underline;color:#2563eb">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:info@tool-ctrl.de" style="text-decoration:underline;color:#2563eb">info@tool-ctrl.de</a>.</div></div></div></div></body></html>"`;
|
||||
exports[`BaseLayout > applies tenant brand overrides (logo + primary color) 1`] = `"<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="image" href="https://cdn.acme.test/logo.png"/><title>Hi</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;font-size:16px;line-height:1.5"><div style="display:none;font-size:1px;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden">snippet</div><div style="width:100%;max-width:560px;margin:0 auto;padding:24px 16px"><div style="background-color:#ffffff;border:1px solid #e2e8f0;border-radius:20px;padding:32px"><div style="padding-bottom:16px;text-align:left"><img src="https://cdn.acme.test/logo.png" alt="Acme" width="48" height="48" style="display:block;border:0;border-radius:12px"/></div><p>Body</p><div style="margin-top:24px;padding-top:16px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e2e8f0;color:#475569"><div><a href="https://hivegrid.de/datenschutz" style="text-decoration:underline;color:#2563eb">Privacy</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/agb" style="text-decoration:underline;color:#2563eb">Terms</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/impressum" style="text-decoration:underline;color:#2563eb">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:support@hivegrid.de" style="text-decoration:underline;color:#2563eb">support@hivegrid.de</a>.</div></div></div></div></body></html>"`;
|
||||
|
||||
exports[`BaseLayout > renders default-brand snapshot 1`] = `"<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>Hello</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;font-size:16px;line-height:1.5"><div style="display:none;font-size:1px;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden">A preview</div><div style="width:100%;max-width:560px;margin:0 auto;padding:24px 16px"><div style="background-color:#ffffff;border:1px solid #e2e8f0;border-radius:20px;padding:32px"><div style="padding-bottom:16px;text-align:left"><strong style="color:#0f172a;font-size:18px">ToolCTRL</strong></div><div style="color:#475569;font-size:13px;font-weight:700;letter-spacing:0.08em;text-transform:uppercase;margin-bottom:8px">Eyebrow</div><h1>Title</h1><div style="margin-top:24px;padding-top:16px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e2e8f0;color:#475569"><div><a href="https://tool-ctrl.de/privacy" style="text-decoration:underline;color:#2563eb">Privacy</a><span style="margin:0 6px">·</span><a href="https://tool-ctrl.de/terms" style="text-decoration:underline;color:#2563eb">Terms</a><span style="margin:0 6px">·</span><a href="https://tool-ctrl.de/imprint" style="text-decoration:underline;color:#2563eb">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:info@tool-ctrl.de" style="text-decoration:underline;color:#2563eb">info@tool-ctrl.de</a>.</div></div></div></div></body></html>"`;
|
||||
exports[`BaseLayout > renders default-brand snapshot 1`] = `"<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>Hello</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;font-size:16px;line-height:1.5"><div style="display:none;font-size:1px;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden">A preview</div><div style="width:100%;max-width:560px;margin:0 auto;padding:24px 16px"><div style="background-color:#ffffff;border:1px solid #e2e8f0;border-radius:20px;padding:32px"><div style="padding-bottom:16px;text-align:left"><strong style="color:#0f172a;font-size:18px">HiveGrid</strong></div><div style="color:#475569;font-size:13px;font-weight:700;letter-spacing:0.08em;text-transform:uppercase;margin-bottom:8px">Eyebrow</div><h1>Title</h1><div style="margin-top:24px;padding-top:16px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e2e8f0;color:#475569"><div><a href="https://hivegrid.de/datenschutz" style="text-decoration:underline;color:#2563eb">Privacy</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/agb" style="text-decoration:underline;color:#2563eb">Terms</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/impressum" style="text-decoration:underline;color:#2563eb">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:support@hivegrid.de" style="text-decoration:underline;color:#2563eb">support@hivegrid.de</a>.</div></div></div></div></body></html>"`;
|
||||
|
||||
exports[`BaseLayout > renders default-brand snapshot 2`] = `
|
||||
"A preview
|
||||
ToolCTRL
|
||||
HiveGrid
|
||||
Eyebrow
|
||||
Title
|
||||
Privacy (https://tool-ctrl.de/privacy)·Terms (https://tool-ctrl.de/terms)·Imprint (https://tool-ctrl.de/imprint)
|
||||
Questions? Email us at info@tool-ctrl.de (mailto:info@tool-ctrl.de)."
|
||||
Privacy (https://hivegrid.de/datenschutz)·Terms (https://hivegrid.de/agb)·Imprint (https://hivegrid.de/impressum)
|
||||
Questions? Email us at support@hivegrid.de (mailto:support@hivegrid.de)."
|
||||
`;
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { renderReactEmail } from "../render-helpers.js";
|
||||
import { BaseLayout } from "./BaseLayout.js";
|
||||
import { Footer } from "./Footer.js";
|
||||
import { defaultMailBrand, withBrandDefaults } from "./theme.js";
|
||||
|
||||
describe("Footer legal-link branches", () => {
|
||||
test("renders no legal links and shows an unsubscribe link when legal URLs are absent", () => {
|
||||
const brand = withBrandDefaults({ privacyUrl: undefined, termsUrl: undefined, imprintUrl: undefined });
|
||||
const { html } = renderReactEmail(
|
||||
<Footer brand={brand} unsubscribeUrl="https://app.example.com/unsubscribe?token=abc" />
|
||||
);
|
||||
|
||||
expect(html).not.toContain(">Privacy<");
|
||||
expect(html).not.toContain(">Terms<");
|
||||
expect(html).not.toContain(">Imprint<");
|
||||
expect(html).toContain(">Unsubscribe<");
|
||||
expect(html).toContain('href="https://app.example.com/unsubscribe?token=abc"');
|
||||
// The support contact line is always rendered.
|
||||
expect(html).toContain(`mailto:${brand.supportEmail}`);
|
||||
});
|
||||
|
||||
test("renders only the privacy link (no separators) when terms and imprint are absent", () => {
|
||||
const brand = withBrandDefaults({ termsUrl: undefined, imprintUrl: undefined });
|
||||
const { html } = renderReactEmail(<Footer brand={brand} />);
|
||||
|
||||
expect(html).toContain(">Privacy<");
|
||||
expect(html).not.toContain(">Terms<");
|
||||
expect(html).not.toContain(">Imprint<");
|
||||
// No middot separator should be emitted when only one legal link exists.
|
||||
expect(html).not.toContain(">·<");
|
||||
// No unsubscribe link when none was supplied.
|
||||
expect(html).not.toContain(">Unsubscribe<");
|
||||
});
|
||||
});
|
||||
|
||||
describe("BaseLayout preview-text branch", () => {
|
||||
test("omits the hidden preview div when no previewText is supplied", () => {
|
||||
const { html } = renderReactEmail(
|
||||
<BaseLayout brand={defaultMailBrand} title="No preview">
|
||||
<p>Body</p>
|
||||
</BaseLayout>
|
||||
);
|
||||
|
||||
// The preview snippet container uses a 1px font-size — it must be absent here.
|
||||
expect(html).not.toContain("font-size:1px");
|
||||
expect(html).toContain("Body");
|
||||
});
|
||||
});
|
||||
+8
-8
@@ -1,9 +1,9 @@
|
||||
/**
|
||||
* Default brand-theme tokens for React-Email transactional templates.
|
||||
*
|
||||
* Templates accept a `brand` prop derived from `@toolctrl/brand`'s
|
||||
* Templates accept a `brand` prop derived from `@hivegrid/brand`'s
|
||||
* `BrandTokens`. When undefined we fall back to these defaults so
|
||||
* preview/storybook renders stay deterministic regardless of tenant
|
||||
* preview renders stay deterministic regardless of tenant
|
||||
* configuration. Keep this aligned with `packages/brand/src/index.ts`.
|
||||
*/
|
||||
export interface MailBrand {
|
||||
@@ -27,7 +27,7 @@ export interface MailBrand {
|
||||
}
|
||||
|
||||
export const defaultMailBrand: MailBrand = {
|
||||
productName: "ToolCTRL",
|
||||
productName: "HiveGrid",
|
||||
primaryColor: "#2563eb",
|
||||
primaryTextColor: "#ffffff",
|
||||
textColor: "#0f172a",
|
||||
@@ -38,11 +38,11 @@ export const defaultMailBrand: MailBrand = {
|
||||
linkColor: "#2563eb",
|
||||
fontFamily:
|
||||
"ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif",
|
||||
supportEmail: "info@tool-ctrl.de",
|
||||
supportFromName: "ToolCTRL Support",
|
||||
privacyUrl: "https://tool-ctrl.de/privacy",
|
||||
termsUrl: "https://tool-ctrl.de/terms",
|
||||
imprintUrl: "https://tool-ctrl.de/imprint",
|
||||
supportEmail: "support@hivegrid.de",
|
||||
supportFromName: "HiveGrid Support",
|
||||
privacyUrl: "https://hivegrid.de/datenschutz",
|
||||
termsUrl: "https://hivegrid.de/agb",
|
||||
imprintUrl: "https://hivegrid.de/impressum",
|
||||
} as const;
|
||||
|
||||
export function withBrandDefaults(override?: Partial<MailBrand>): MailBrand {
|
||||
|
||||
+2
-2
@@ -17,12 +17,12 @@ describe("htmlToPlainText", () => {
|
||||
"<head><title>Ignored</title></head>",
|
||||
"<style>.hidden { display: none; }</style>",
|
||||
'<script>alert("ignored")</script>',
|
||||
"<div>ToolCTRL & friends</div>",
|
||||
"<div>HiveGrid & friends</div>",
|
||||
"<div><safe> 'quoted' "copy"</div>",
|
||||
"<br><p>Done</p>",
|
||||
].join("")
|
||||
);
|
||||
|
||||
expect(text).toBe("ToolCTRL & friends\n<safe> 'quoted' \"copy\"\n\nDone");
|
||||
expect(text).toBe("HiveGrid & friends\n<safe> 'quoted' \"copy\"\n\nDone");
|
||||
});
|
||||
});
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { buildBrand, defaultMailBrand } from "./render.js";
|
||||
|
||||
describe("buildBrand", () => {
|
||||
test("returns the default brand when no override is supplied", () => {
|
||||
expect(buildBrand()).toEqual(defaultMailBrand);
|
||||
});
|
||||
|
||||
test("merges a partial override on top of the default brand", () => {
|
||||
const brand = buildBrand({ productName: "Acme", primaryColor: "#123456" });
|
||||
|
||||
expect(brand.productName).toBe("Acme");
|
||||
expect(brand.primaryColor).toBe("#123456");
|
||||
// Untouched tokens fall back to the defaults.
|
||||
expect(brand.supportEmail).toBe(defaultMailBrand.supportEmail);
|
||||
expect(brand.linkColor).toBe(defaultMailBrand.linkColor);
|
||||
});
|
||||
});
|
||||
+3
-3
@@ -28,8 +28,8 @@ describe("renderTransactionalEmail", () => {
|
||||
recipientName: "Ada",
|
||||
actionUrl: "https://app.example.com/login",
|
||||
});
|
||||
expect(result.html).toContain("Welcome to ToolCTRL, Ada!");
|
||||
expect(result.text).toContain("Welcome to ToolCTRL, Ada!");
|
||||
expect(result.html).toContain("Welcome to HiveGrid, Ada!");
|
||||
expect(result.text).toContain("Welcome to HiveGrid, Ada!");
|
||||
});
|
||||
|
||||
test("renders invitation via dispatch", () => {
|
||||
@@ -39,7 +39,7 @@ describe("renderTransactionalEmail", () => {
|
||||
senderOrganization: "Example Org",
|
||||
actionUrl: "https://app.example.com/invite",
|
||||
});
|
||||
expect(result.html).toContain("Grace invited you to ToolCTRL");
|
||||
expect(result.html).toContain("Grace invited you to HiveGrid");
|
||||
expect(result.text).toContain("Join Example Org");
|
||||
});
|
||||
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ import { InfoBox } from "../_layout/InfoBox.js";
|
||||
import type { MailBrand } from "../_layout/theme.js";
|
||||
|
||||
/**
|
||||
* InvoiceSentEmail — notifies a customer that a Stripe invoice PDF
|
||||
* InvoiceSentEmail — notifies a customer that a invoice PDF
|
||||
* has been issued. CTA points to the hosted-invoice URL so the user
|
||||
* can download the PDF without authenticating.
|
||||
*/
|
||||
|
||||
+4
-4
@@ -14,7 +14,7 @@ describe("InvoiceSentEmail", () => {
|
||||
amountFormatted="€99.00"
|
||||
issueDate="2026-05-17"
|
||||
dueDate="2026-06-17"
|
||||
actionUrl="https://invoice.stripe.com/i/abc"
|
||||
actionUrl="https://billing.hivegrid.test/invoices/abc"
|
||||
/>
|
||||
);
|
||||
expect(result.html).toMatchSnapshot("html");
|
||||
@@ -28,7 +28,7 @@ describe("InvoiceSentEmail", () => {
|
||||
invoiceNumber="INV-€-001"
|
||||
amountFormatted="€99.00 🎉"
|
||||
issueDate="2026-05-17"
|
||||
actionUrl="https://invoice.stripe.com/i/abc"
|
||||
actionUrl="https://billing.hivegrid.test/invoices/abc"
|
||||
/>
|
||||
);
|
||||
expect(html).toContain("INV-€-001");
|
||||
@@ -44,8 +44,8 @@ describe("InvoiceSentEmail", () => {
|
||||
amountFormatted="99,00 €"
|
||||
issueDate="17.05.2026"
|
||||
dueDate="17.06.2026"
|
||||
actionUrl="https://invoice.stripe.com/i/abc"
|
||||
subject="Rechnung RE-2026-0001 von ToolCTRL"
|
||||
actionUrl="https://billing.hivegrid.test/invoices/abc"
|
||||
subject="Rechnung RE-2026-0001 von HiveGrid"
|
||||
eyebrow="Rechnung"
|
||||
titleText="Hallo, Ada!"
|
||||
intro="Deine Rechnung RE-2026-0001 über 99,00 € ist jetzt verfügbar."
|
||||
|
||||
+2
-2
@@ -41,7 +41,7 @@ describe("SubscriptionSuccessEmail", () => {
|
||||
amountFormatted="29,00 €"
|
||||
nextBillingDate="01.06.2026"
|
||||
actionUrl="https://app.example.com/billing"
|
||||
subject="Dein ToolCTRL-Abo ist aktiv"
|
||||
subject="Dein HiveGrid-Abo ist aktiv"
|
||||
eyebrow="Abo"
|
||||
title="Danke, Ada!"
|
||||
intro="Dein Pro-Abo ist jetzt aktiv. Willkommen!"
|
||||
@@ -51,7 +51,7 @@ describe("SubscriptionSuccessEmail", () => {
|
||||
/>
|
||||
);
|
||||
|
||||
expect(html).toContain("Dein ToolCTRL-Abo ist aktiv");
|
||||
expect(html).toContain("Dein HiveGrid-Abo ist aktiv");
|
||||
expect(html).toContain("Dashboard öffnen");
|
||||
expect(html).toContain("Tarif:");
|
||||
expect(html).toContain("Nächste Abrechnung:");
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ import { InfoBox } from "../_layout/InfoBox.js";
|
||||
import type { MailBrand } from "../_layout/theme.js";
|
||||
|
||||
/**
|
||||
* SubscriptionFailedEmail — sent after a Stripe `invoice.payment_failed`
|
||||
* SubscriptionFailedEmail — sent after a failed subscription invoice
|
||||
* webhook. Surfaces the failure reason and a direct CTA to the
|
||||
* billing portal so the customer can fix the card before dunning.
|
||||
*/
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ import { InfoBox } from "../_layout/InfoBox.js";
|
||||
import type { MailBrand } from "../_layout/theme.js";
|
||||
|
||||
/**
|
||||
* SubscriptionSuccessEmail — sent after Stripe checkout completion.
|
||||
* SubscriptionSuccessEmail — sent after checkout completion.
|
||||
* Surfaces the active plan and next-billing date so customers can
|
||||
* verify they were charged correctly without opening the billing
|
||||
* portal.
|
||||
|
||||
+7
-7
@@ -1,16 +1,16 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`InvitationEmail > renders default snapshot > html 1`] = `"<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>Grace invited you to ToolCTRL</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;font-size:16px;line-height:1.5"><div style="display:none;font-size:1px;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden">Grace invited you to ToolCTRL</div><div style="width:100%;max-width:560px;margin:0 auto;padding:24px 16px"><div style="background-color:#ffffff;border:1px solid #e2e8f0;border-radius:20px;padding:32px"><div style="padding-bottom:16px;text-align:left"><strong style="color:#0f172a;font-size:18px">ToolCTRL</strong></div><div style="color:#475569;font-size:13px;font-weight:700;letter-spacing:0.08em;text-transform:uppercase;margin-bottom:8px">Invitation</div><h1 style="margin:8px 0 16px;font-size:28px;line-height:1.2;color:#0f172a;font-weight:700">Hello, Ada!</h1><p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#0f172a">Grace with Example Org has invited you to use ToolCTRL to collaborate with them.</p><a href="https://app.example.com/invite/abc" style="display:inline-block;background-color:#2563eb;color:#ffffff;padding:12px 22px;border-radius:999px;font-weight:700;font-size:15px;text-decoration:none" target="_blank" rel="noopener noreferrer">Join Example Org</a><p style="margin:24px 0 0;font-size:14px;line-height:1.6;color:#0f172a">Thanks,<br/>-<br/>ToolCTRL Support</p><div style="margin-top:24px;padding-top:16px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e2e8f0;color:#475569"><div><a href="https://tool-ctrl.de/privacy" style="text-decoration:underline;color:#2563eb">Privacy</a><span style="margin:0 6px">·</span><a href="https://tool-ctrl.de/terms" style="text-decoration:underline;color:#2563eb">Terms</a><span style="margin:0 6px">·</span><a href="https://tool-ctrl.de/imprint" style="text-decoration:underline;color:#2563eb">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:info@tool-ctrl.de" style="text-decoration:underline;color:#2563eb">info@tool-ctrl.de</a>.</div></div></div></div></body></html>"`;
|
||||
exports[`InvitationEmail > renders default snapshot > html 1`] = `"<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>Grace invited you to HiveGrid</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;font-size:16px;line-height:1.5"><div style="display:none;font-size:1px;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden">Grace invited you to HiveGrid</div><div style="width:100%;max-width:560px;margin:0 auto;padding:24px 16px"><div style="background-color:#ffffff;border:1px solid #e2e8f0;border-radius:20px;padding:32px"><div style="padding-bottom:16px;text-align:left"><strong style="color:#0f172a;font-size:18px">HiveGrid</strong></div><div style="color:#475569;font-size:13px;font-weight:700;letter-spacing:0.08em;text-transform:uppercase;margin-bottom:8px">Invitation</div><h1 style="margin:8px 0 16px;font-size:28px;line-height:1.2;color:#0f172a;font-weight:700">Hello, Ada!</h1><p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#0f172a">Grace with Example Org has invited you to use HiveGrid to collaborate with them.</p><a href="https://app.example.com/invite/abc" style="display:inline-block;background-color:#2563eb;color:#ffffff;padding:12px 22px;border-radius:999px;font-weight:700;font-size:15px;text-decoration:none" target="_blank" rel="noopener noreferrer">Join Example Org</a><p style="margin:24px 0 0;font-size:14px;line-height:1.6;color:#0f172a">Thanks,<br/>-<br/>HiveGrid Support</p><div style="margin-top:24px;padding-top:16px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e2e8f0;color:#475569"><div><a href="https://hivegrid.de/datenschutz" style="text-decoration:underline;color:#2563eb">Privacy</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/agb" style="text-decoration:underline;color:#2563eb">Terms</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/impressum" style="text-decoration:underline;color:#2563eb">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:support@hivegrid.de" style="text-decoration:underline;color:#2563eb">support@hivegrid.de</a>.</div></div></div></div></body></html>"`;
|
||||
|
||||
exports[`InvitationEmail > renders default snapshot > text 1`] = `
|
||||
"Grace invited you to ToolCTRL
|
||||
ToolCTRL
|
||||
"Grace invited you to HiveGrid
|
||||
HiveGrid
|
||||
Invitation
|
||||
Hello, Ada!
|
||||
Grace with Example Org has invited you to use ToolCTRL to collaborate with them.
|
||||
Grace with Example Org has invited you to use HiveGrid to collaborate with them.
|
||||
Join Example Org (https://app.example.com/invite/abc)Thanks,
|
||||
-
|
||||
ToolCTRL Support
|
||||
Privacy (https://tool-ctrl.de/privacy)·Terms (https://tool-ctrl.de/terms)·Imprint (https://tool-ctrl.de/imprint)
|
||||
Questions? Email us at info@tool-ctrl.de (mailto:info@tool-ctrl.de)."
|
||||
HiveGrid Support
|
||||
Privacy (https://hivegrid.de/datenschutz)·Terms (https://hivegrid.de/agb)·Imprint (https://hivegrid.de/impressum)
|
||||
Questions? Email us at support@hivegrid.de (mailto:support@hivegrid.de)."
|
||||
`;
|
||||
+12
-12
@@ -1,35 +1,35 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`InvoiceSentEmail > renders default snapshot with due date > html 1`] = `"<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>Invoice INV-2026-0001 from ToolCTRL</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;font-size:16px;line-height:1.5"><div style="display:none;font-size:1px;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden">Invoice INV-2026-0001 from ToolCTRL</div><div style="width:100%;max-width:560px;margin:0 auto;padding:24px 16px"><div style="background-color:#ffffff;border:1px solid #e2e8f0;border-radius:20px;padding:32px"><div style="padding-bottom:16px;text-align:left"><strong style="color:#0f172a;font-size:18px">ToolCTRL</strong></div><div style="color:#475569;font-size:13px;font-weight:700;letter-spacing:0.08em;text-transform:uppercase;margin-bottom:8px">Invoice</div><h1 style="margin:8px 0 16px;font-size:28px;line-height:1.2;color:#0f172a;font-weight:700">Hello, Ada!</h1><p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#0f172a">Your invoice INV-2026-0001 for €99.00 is now available.</p><a href="https://invoice.stripe.com/i/abc" style="display:inline-block;background-color:#2563eb;color:#ffffff;padding:12px 22px;border-radius:999px;font-weight:700;font-size:15px;text-decoration:none" target="_blank" rel="noopener noreferrer">View invoice PDF</a><div style="margin-top:20px;padding:14px 16px;border-radius:10px;font-size:14px;line-height:1.55;background-color:#f1f5f9;color:#0f172a;border:1px solid #e2e8f0"><strong>Invoice number:</strong> INV-2026-0001<br/><strong>Amount:</strong> €99.00<br/><strong>Issued:</strong> 2026-05-17<br/><strong>Due:</strong> 2026-06-17</div><p style="margin:24px 0 0;font-size:14px;line-height:1.6;color:#0f172a">Thanks,<br/>-<br/>ToolCTRL Support</p><div style="margin-top:24px;padding-top:16px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e2e8f0;color:#475569"><div><a href="https://tool-ctrl.de/privacy" style="text-decoration:underline;color:#2563eb">Privacy</a><span style="margin:0 6px">·</span><a href="https://tool-ctrl.de/terms" style="text-decoration:underline;color:#2563eb">Terms</a><span style="margin:0 6px">·</span><a href="https://tool-ctrl.de/imprint" style="text-decoration:underline;color:#2563eb">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:info@tool-ctrl.de" style="text-decoration:underline;color:#2563eb">info@tool-ctrl.de</a>.</div></div></div></div></body></html>"`;
|
||||
exports[`InvoiceSentEmail > renders default snapshot with due date > html 1`] = `"<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>Invoice INV-2026-0001 from HiveGrid</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;font-size:16px;line-height:1.5"><div style="display:none;font-size:1px;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden">Invoice INV-2026-0001 from HiveGrid</div><div style="width:100%;max-width:560px;margin:0 auto;padding:24px 16px"><div style="background-color:#ffffff;border:1px solid #e2e8f0;border-radius:20px;padding:32px"><div style="padding-bottom:16px;text-align:left"><strong style="color:#0f172a;font-size:18px">HiveGrid</strong></div><div style="color:#475569;font-size:13px;font-weight:700;letter-spacing:0.08em;text-transform:uppercase;margin-bottom:8px">Invoice</div><h1 style="margin:8px 0 16px;font-size:28px;line-height:1.2;color:#0f172a;font-weight:700">Hello, Ada!</h1><p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#0f172a">Your invoice INV-2026-0001 for €99.00 is now available.</p><a href="https://billing.hivegrid.test/invoices/abc" style="display:inline-block;background-color:#2563eb;color:#ffffff;padding:12px 22px;border-radius:999px;font-weight:700;font-size:15px;text-decoration:none" target="_blank" rel="noopener noreferrer">View invoice PDF</a><div style="margin-top:20px;padding:14px 16px;border-radius:10px;font-size:14px;line-height:1.55;background-color:#f1f5f9;color:#0f172a;border:1px solid #e2e8f0"><strong>Invoice number:</strong> INV-2026-0001<br/><strong>Amount:</strong> €99.00<br/><strong>Issued:</strong> 2026-05-17<br/><strong>Due:</strong> 2026-06-17</div><p style="margin:24px 0 0;font-size:14px;line-height:1.6;color:#0f172a">Thanks,<br/>-<br/>HiveGrid Support</p><div style="margin-top:24px;padding-top:16px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e2e8f0;color:#475569"><div><a href="https://hivegrid.de/datenschutz" style="text-decoration:underline;color:#2563eb">Privacy</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/agb" style="text-decoration:underline;color:#2563eb">Terms</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/impressum" style="text-decoration:underline;color:#2563eb">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:support@hivegrid.de" style="text-decoration:underline;color:#2563eb">support@hivegrid.de</a>.</div></div></div></div></body></html>"`;
|
||||
|
||||
exports[`InvoiceSentEmail > renders default snapshot with due date > text 1`] = `
|
||||
"Invoice INV-2026-0001 from ToolCTRL
|
||||
ToolCTRL
|
||||
"Invoice INV-2026-0001 from HiveGrid
|
||||
HiveGrid
|
||||
Invoice
|
||||
Hello, Ada!
|
||||
Your invoice INV-2026-0001 for €99.00 is now available.
|
||||
View invoice PDF (https://invoice.stripe.com/i/abc)Invoice number: INV-2026-0001
|
||||
View invoice PDF (https://billing.hivegrid.test/invoices/abc)Invoice number: INV-2026-0001
|
||||
Amount: €99.00
|
||||
Issued: 2026-05-17
|
||||
Due: 2026-06-17
|
||||
Thanks,
|
||||
-
|
||||
ToolCTRL Support
|
||||
Privacy (https://tool-ctrl.de/privacy)·Terms (https://tool-ctrl.de/terms)·Imprint (https://tool-ctrl.de/imprint)
|
||||
Questions? Email us at info@tool-ctrl.de (mailto:info@tool-ctrl.de)."
|
||||
HiveGrid Support
|
||||
Privacy (https://hivegrid.de/datenschutz)·Terms (https://hivegrid.de/agb)·Imprint (https://hivegrid.de/impressum)
|
||||
Questions? Email us at support@hivegrid.de (mailto:support@hivegrid.de)."
|
||||
`;
|
||||
|
||||
exports[`TenantNotificationEmail > renders default snapshot with action > html 1`] = `"<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>New comment on Ticket #42</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;font-size:16px;line-height:1.5"><div style="display:none;font-size:1px;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden">New comment on Ticket #42</div><div style="width:100%;max-width:560px;margin:0 auto;padding:24px 16px"><div style="background-color:#ffffff;border:1px solid #e2e8f0;border-radius:20px;padding:32px"><div style="padding-bottom:16px;text-align:left"><strong style="color:#0f172a;font-size:18px">ToolCTRL</strong></div><div style="color:#475569;font-size:13px;font-weight:700;letter-spacing:0.08em;text-transform:uppercase;margin-bottom:8px">Notification</div><h1 style="margin:8px 0 16px;font-size:28px;line-height:1.2;color:#0f172a;font-weight:700">Hello, Ada!</h1><p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#0f172a">Grace mentioned you in a comment on Ticket #42.</p><a href="https://app.example.com/tickets/42" style="display:inline-block;background-color:#2563eb;color:#ffffff;padding:12px 22px;border-radius:999px;font-weight:700;font-size:15px;text-decoration:none" target="_blank" rel="noopener noreferrer">View ticket</a><p style="margin:24px 0 0;font-size:14px;line-height:1.6;color:#0f172a">Thanks,<br/>-<br/>ToolCTRL Support</p><div style="margin-top:24px;padding-top:16px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e2e8f0;color:#475569"><div><a href="https://tool-ctrl.de/privacy" style="text-decoration:underline;color:#2563eb">Privacy</a><span style="margin:0 6px">·</span><a href="https://tool-ctrl.de/terms" style="text-decoration:underline;color:#2563eb">Terms</a><span style="margin:0 6px">·</span><a href="https://tool-ctrl.de/imprint" style="text-decoration:underline;color:#2563eb">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:info@tool-ctrl.de" style="text-decoration:underline;color:#2563eb">info@tool-ctrl.de</a>.</div></div></div></div></body></html>"`;
|
||||
exports[`TenantNotificationEmail > renders default snapshot with action > html 1`] = `"<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>New comment on Ticket #42</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;font-size:16px;line-height:1.5"><div style="display:none;font-size:1px;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden">New comment on Ticket #42</div><div style="width:100%;max-width:560px;margin:0 auto;padding:24px 16px"><div style="background-color:#ffffff;border:1px solid #e2e8f0;border-radius:20px;padding:32px"><div style="padding-bottom:16px;text-align:left"><strong style="color:#0f172a;font-size:18px">HiveGrid</strong></div><div style="color:#475569;font-size:13px;font-weight:700;letter-spacing:0.08em;text-transform:uppercase;margin-bottom:8px">Notification</div><h1 style="margin:8px 0 16px;font-size:28px;line-height:1.2;color:#0f172a;font-weight:700">Hello, Ada!</h1><p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#0f172a">Grace mentioned you in a comment on Ticket #42.</p><a href="https://app.example.com/tickets/42" style="display:inline-block;background-color:#2563eb;color:#ffffff;padding:12px 22px;border-radius:999px;font-weight:700;font-size:15px;text-decoration:none" target="_blank" rel="noopener noreferrer">View ticket</a><p style="margin:24px 0 0;font-size:14px;line-height:1.6;color:#0f172a">Thanks,<br/>-<br/>HiveGrid Support</p><div style="margin-top:24px;padding-top:16px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e2e8f0;color:#475569"><div><a href="https://hivegrid.de/datenschutz" style="text-decoration:underline;color:#2563eb">Privacy</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/agb" style="text-decoration:underline;color:#2563eb">Terms</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/impressum" style="text-decoration:underline;color:#2563eb">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:support@hivegrid.de" style="text-decoration:underline;color:#2563eb">support@hivegrid.de</a>.</div></div></div></div></body></html>"`;
|
||||
|
||||
exports[`TenantNotificationEmail > renders default snapshot with action > text 1`] = `
|
||||
"New comment on Ticket #42
|
||||
ToolCTRL
|
||||
HiveGrid
|
||||
Notification
|
||||
Hello, Ada!
|
||||
Grace mentioned you in a comment on Ticket #42.
|
||||
View ticket (https://app.example.com/tickets/42)Thanks,
|
||||
-
|
||||
ToolCTRL Support
|
||||
Privacy (https://tool-ctrl.de/privacy)·Terms (https://tool-ctrl.de/terms)·Imprint (https://tool-ctrl.de/imprint)
|
||||
Questions? Email us at info@tool-ctrl.de (mailto:info@tool-ctrl.de)."
|
||||
HiveGrid Support
|
||||
Privacy (https://hivegrid.de/datenschutz)·Terms (https://hivegrid.de/agb)·Imprint (https://hivegrid.de/impressum)
|
||||
Questions? Email us at support@hivegrid.de (mailto:support@hivegrid.de)."
|
||||
`;
|
||||
+7
-7
@@ -1,18 +1,18 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`MagicLinkEmail > renders default snapshot > html 1`] = `"<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>Your sign-in link for ToolCTRL</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;font-size:16px;line-height:1.5"><div style="display:none;font-size:1px;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden">Click to sign in to ToolCTRL</div><div style="width:100%;max-width:560px;margin:0 auto;padding:24px 16px"><div style="background-color:#ffffff;border:1px solid #e2e8f0;border-radius:20px;padding:32px"><div style="padding-bottom:16px;text-align:left"><strong style="color:#0f172a;font-size:18px">ToolCTRL</strong></div><div style="color:#475569;font-size:13px;font-weight:700;letter-spacing:0.08em;text-transform:uppercase;margin-bottom:8px">Magic link</div><h1 style="margin:8px 0 16px;font-size:28px;line-height:1.2;color:#0f172a;font-weight:700">Hello, Ada!</h1><p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#0f172a">Click the button below to sign in to your ToolCTRL account. No password required.</p><a href="https://app.example.com/magic/abc" style="display:inline-block;background-color:#2563eb;color:#ffffff;padding:12px 22px;border-radius:999px;font-weight:700;font-size:15px;text-decoration:none" target="_blank" rel="noopener noreferrer">Sign in</a><p style="margin:24px 0 0;font-size:14px;line-height:1.6;color:#475569">If you didn't request this email, you can safely ignore it.</p><div style="margin-top:20px;padding:14px 16px;border-radius:10px;font-size:14px;line-height:1.55;background-color:#fef3c7;color:#92400e;border:1px solid #fde68a">This link expires in 15 minutes and can only be used once.</div><p style="margin:24px 0 0;font-size:14px;line-height:1.6;color:#0f172a">Thanks,<br/>-<br/>ToolCTRL Support</p><div style="margin-top:24px;padding-top:16px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e2e8f0;color:#475569"><div><a href="https://tool-ctrl.de/privacy" style="text-decoration:underline;color:#2563eb">Privacy</a><span style="margin:0 6px">·</span><a href="https://tool-ctrl.de/terms" style="text-decoration:underline;color:#2563eb">Terms</a><span style="margin:0 6px">·</span><a href="https://tool-ctrl.de/imprint" style="text-decoration:underline;color:#2563eb">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:info@tool-ctrl.de" style="text-decoration:underline;color:#2563eb">info@tool-ctrl.de</a>.</div></div></div></div></body></html>"`;
|
||||
exports[`MagicLinkEmail > renders default snapshot > html 1`] = `"<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>Your sign-in link for HiveGrid</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;font-size:16px;line-height:1.5"><div style="display:none;font-size:1px;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden">Click to sign in to HiveGrid</div><div style="width:100%;max-width:560px;margin:0 auto;padding:24px 16px"><div style="background-color:#ffffff;border:1px solid #e2e8f0;border-radius:20px;padding:32px"><div style="padding-bottom:16px;text-align:left"><strong style="color:#0f172a;font-size:18px">HiveGrid</strong></div><div style="color:#475569;font-size:13px;font-weight:700;letter-spacing:0.08em;text-transform:uppercase;margin-bottom:8px">Magic link</div><h1 style="margin:8px 0 16px;font-size:28px;line-height:1.2;color:#0f172a;font-weight:700">Hello, Ada!</h1><p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#0f172a">Click the button below to sign in to your HiveGrid account. No password required.</p><a href="https://app.example.com/magic/abc" style="display:inline-block;background-color:#2563eb;color:#ffffff;padding:12px 22px;border-radius:999px;font-weight:700;font-size:15px;text-decoration:none" target="_blank" rel="noopener noreferrer">Sign in</a><p style="margin:24px 0 0;font-size:14px;line-height:1.6;color:#475569">If you didn't request this email, you can safely ignore it.</p><div style="margin-top:20px;padding:14px 16px;border-radius:10px;font-size:14px;line-height:1.55;background-color:#fef3c7;color:#92400e;border:1px solid #fde68a">This link expires in 15 minutes and can only be used once.</div><p style="margin:24px 0 0;font-size:14px;line-height:1.6;color:#0f172a">Thanks,<br/>-<br/>HiveGrid Support</p><div style="margin-top:24px;padding-top:16px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e2e8f0;color:#475569"><div><a href="https://hivegrid.de/datenschutz" style="text-decoration:underline;color:#2563eb">Privacy</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/agb" style="text-decoration:underline;color:#2563eb">Terms</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/impressum" style="text-decoration:underline;color:#2563eb">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:support@hivegrid.de" style="text-decoration:underline;color:#2563eb">support@hivegrid.de</a>.</div></div></div></div></body></html>"`;
|
||||
|
||||
exports[`MagicLinkEmail > renders default snapshot > text 1`] = `
|
||||
"Click to sign in to ToolCTRL
|
||||
ToolCTRL
|
||||
"Click to sign in to HiveGrid
|
||||
HiveGrid
|
||||
Magic link
|
||||
Hello, Ada!
|
||||
Click the button below to sign in to your ToolCTRL account. No password required.
|
||||
Click the button below to sign in to your HiveGrid account. No password required.
|
||||
Sign in (https://app.example.com/magic/abc)If you didn't request this email, you can safely ignore it.
|
||||
This link expires in 15 minutes and can only be used once.
|
||||
Thanks,
|
||||
-
|
||||
ToolCTRL Support
|
||||
Privacy (https://tool-ctrl.de/privacy)·Terms (https://tool-ctrl.de/terms)·Imprint (https://tool-ctrl.de/imprint)
|
||||
Questions? Email us at info@tool-ctrl.de (mailto:info@tool-ctrl.de)."
|
||||
HiveGrid Support
|
||||
Privacy (https://hivegrid.de/datenschutz)·Terms (https://hivegrid.de/agb)·Imprint (https://hivegrid.de/impressum)
|
||||
Questions? Email us at support@hivegrid.de (mailto:support@hivegrid.de)."
|
||||
`;
|
||||
+7
-7
@@ -1,17 +1,17 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`PasswordResetEmail > renders default snapshot > html 1`] = `"<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>Set up a new password for ToolCTRL</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;font-size:16px;line-height:1.5"><div style="display:none;font-size:1px;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden">Set up a new password for ToolCTRL</div><div style="width:100%;max-width:560px;margin:0 auto;padding:24px 16px"><div style="background-color:#ffffff;border:1px solid #e2e8f0;border-radius:20px;padding:32px"><div style="padding-bottom:16px;text-align:left"><strong style="color:#0f172a;font-size:18px">ToolCTRL</strong></div><div style="color:#475569;font-size:13px;font-weight:700;letter-spacing:0.08em;text-transform:uppercase;margin-bottom:8px">Password reset</div><h1 style="margin:8px 0 16px;font-size:28px;line-height:1.2;color:#0f172a;font-weight:700">Hello, Ada!</h1><p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#0f172a">You recently requested to reset your password for your ToolCTRL account.</p><a href="https://app.example.com/reset?t=abc" style="display:inline-block;background-color:#2563eb;color:#ffffff;padding:12px 22px;border-radius:999px;font-weight:700;font-size:15px;text-decoration:none" target="_blank" rel="noopener noreferrer">Reset password</a><p style="margin:24px 0 0;font-size:14px;line-height:1.6;color:#475569">If you did not request a password reset, please ignore this email or contact support if you have questions.</p><p style="margin:24px 0 0;font-size:14px;line-height:1.6;color:#0f172a">Thanks,<br/>-<br/>ToolCTRL Support</p><div style="margin-top:24px;padding-top:16px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e2e8f0;color:#475569"><div><a href="https://tool-ctrl.de/privacy" style="text-decoration:underline;color:#2563eb">Privacy</a><span style="margin:0 6px">·</span><a href="https://tool-ctrl.de/terms" style="text-decoration:underline;color:#2563eb">Terms</a><span style="margin:0 6px">·</span><a href="https://tool-ctrl.de/imprint" style="text-decoration:underline;color:#2563eb">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:info@tool-ctrl.de" style="text-decoration:underline;color:#2563eb">info@tool-ctrl.de</a>.</div></div></div></div></body></html>"`;
|
||||
exports[`PasswordResetEmail > renders default snapshot > html 1`] = `"<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>Set up a new password for HiveGrid</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;font-size:16px;line-height:1.5"><div style="display:none;font-size:1px;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden">Set up a new password for HiveGrid</div><div style="width:100%;max-width:560px;margin:0 auto;padding:24px 16px"><div style="background-color:#ffffff;border:1px solid #e2e8f0;border-radius:20px;padding:32px"><div style="padding-bottom:16px;text-align:left"><strong style="color:#0f172a;font-size:18px">HiveGrid</strong></div><div style="color:#475569;font-size:13px;font-weight:700;letter-spacing:0.08em;text-transform:uppercase;margin-bottom:8px">Password reset</div><h1 style="margin:8px 0 16px;font-size:28px;line-height:1.2;color:#0f172a;font-weight:700">Hello, Ada!</h1><p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#0f172a">You recently requested to reset your password for your HiveGrid account.</p><a href="https://app.example.com/reset?t=abc" style="display:inline-block;background-color:#2563eb;color:#ffffff;padding:12px 22px;border-radius:999px;font-weight:700;font-size:15px;text-decoration:none" target="_blank" rel="noopener noreferrer">Reset password</a><p style="margin:24px 0 0;font-size:14px;line-height:1.6;color:#475569">If you did not request a password reset, please ignore this email or contact support if you have questions.</p><p style="margin:24px 0 0;font-size:14px;line-height:1.6;color:#0f172a">Thanks,<br/>-<br/>HiveGrid Support</p><div style="margin-top:24px;padding-top:16px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e2e8f0;color:#475569"><div><a href="https://hivegrid.de/datenschutz" style="text-decoration:underline;color:#2563eb">Privacy</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/agb" style="text-decoration:underline;color:#2563eb">Terms</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/impressum" style="text-decoration:underline;color:#2563eb">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:support@hivegrid.de" style="text-decoration:underline;color:#2563eb">support@hivegrid.de</a>.</div></div></div></div></body></html>"`;
|
||||
|
||||
exports[`PasswordResetEmail > renders default snapshot > text 1`] = `
|
||||
"Set up a new password for ToolCTRL
|
||||
ToolCTRL
|
||||
"Set up a new password for HiveGrid
|
||||
HiveGrid
|
||||
Password reset
|
||||
Hello, Ada!
|
||||
You recently requested to reset your password for your ToolCTRL account.
|
||||
You recently requested to reset your password for your HiveGrid account.
|
||||
Reset password (https://app.example.com/reset?t=abc)If you did not request a password reset, please ignore this email or contact support if you have questions.
|
||||
Thanks,
|
||||
-
|
||||
ToolCTRL Support
|
||||
Privacy (https://tool-ctrl.de/privacy)·Terms (https://tool-ctrl.de/terms)·Imprint (https://tool-ctrl.de/imprint)
|
||||
Questions? Email us at info@tool-ctrl.de (mailto:info@tool-ctrl.de)."
|
||||
HiveGrid Support
|
||||
Privacy (https://hivegrid.de/datenschutz)·Terms (https://hivegrid.de/agb)·Imprint (https://hivegrid.de/impressum)
|
||||
Questions? Email us at support@hivegrid.de (mailto:support@hivegrid.de)."
|
||||
`;
|
||||
+12
-12
@@ -1,10 +1,10 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`SubscriptionFailedEmail > renders default snapshot with reason + retry > html 1`] = `"<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>Action required: payment failed for ToolCTRL</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;font-size:16px;line-height:1.5"><div style="display:none;font-size:1px;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden">Action required: payment failed for ToolCTRL</div><div style="width:100%;max-width:560px;margin:0 auto;padding:24px 16px"><div style="background-color:#ffffff;border:1px solid #e2e8f0;border-radius:20px;padding:32px"><div style="padding-bottom:16px;text-align:left"><strong style="color:#0f172a;font-size:18px">ToolCTRL</strong></div><div style="color:#475569;font-size:13px;font-weight:700;letter-spacing:0.08em;text-transform:uppercase;margin-bottom:8px">Payment failed</div><h1 style="margin:8px 0 16px;font-size:28px;line-height:1.2;color:#0f172a;font-weight:700">Hi Ada,</h1><p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#0f172a">We were unable to charge your card for the Pro subscription. Please update your payment method to avoid service interruption.</p><a href="https://app.example.com/billing" style="display:inline-block;background-color:#2563eb;color:#ffffff;padding:12px 22px;border-radius:999px;font-weight:700;font-size:15px;text-decoration:none" target="_blank" rel="noopener noreferrer">Update payment method</a><div style="margin-top:20px;padding:14px 16px;border-radius:10px;font-size:14px;line-height:1.55;background-color:#fef3c7;color:#92400e;border:1px solid #fde68a"><strong>Plan:</strong> Pro<br/><strong>Amount:</strong> $29.00<br/><strong>Reason:</strong> Card declined<br/><strong>Next retry:</strong> 2026-05-20</div><p style="margin:24px 0 0;font-size:14px;line-height:1.6;color:#0f172a">Thanks,<br/>-<br/>ToolCTRL Support</p><div style="margin-top:24px;padding-top:16px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e2e8f0;color:#475569"><div><a href="https://tool-ctrl.de/privacy" style="text-decoration:underline;color:#2563eb">Privacy</a><span style="margin:0 6px">·</span><a href="https://tool-ctrl.de/terms" style="text-decoration:underline;color:#2563eb">Terms</a><span style="margin:0 6px">·</span><a href="https://tool-ctrl.de/imprint" style="text-decoration:underline;color:#2563eb">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:info@tool-ctrl.de" style="text-decoration:underline;color:#2563eb">info@tool-ctrl.de</a>.</div></div></div></div></body></html>"`;
|
||||
exports[`SubscriptionFailedEmail > renders default snapshot with reason + retry > html 1`] = `"<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>Action required: payment failed for HiveGrid</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;font-size:16px;line-height:1.5"><div style="display:none;font-size:1px;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden">Action required: payment failed for HiveGrid</div><div style="width:100%;max-width:560px;margin:0 auto;padding:24px 16px"><div style="background-color:#ffffff;border:1px solid #e2e8f0;border-radius:20px;padding:32px"><div style="padding-bottom:16px;text-align:left"><strong style="color:#0f172a;font-size:18px">HiveGrid</strong></div><div style="color:#475569;font-size:13px;font-weight:700;letter-spacing:0.08em;text-transform:uppercase;margin-bottom:8px">Payment failed</div><h1 style="margin:8px 0 16px;font-size:28px;line-height:1.2;color:#0f172a;font-weight:700">Hi Ada,</h1><p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#0f172a">We were unable to charge your card for the Pro subscription. Please update your payment method to avoid service interruption.</p><a href="https://app.example.com/billing" style="display:inline-block;background-color:#2563eb;color:#ffffff;padding:12px 22px;border-radius:999px;font-weight:700;font-size:15px;text-decoration:none" target="_blank" rel="noopener noreferrer">Update payment method</a><div style="margin-top:20px;padding:14px 16px;border-radius:10px;font-size:14px;line-height:1.55;background-color:#fef3c7;color:#92400e;border:1px solid #fde68a"><strong>Plan:</strong> Pro<br/><strong>Amount:</strong> $29.00<br/><strong>Reason:</strong> Card declined<br/><strong>Next retry:</strong> 2026-05-20</div><p style="margin:24px 0 0;font-size:14px;line-height:1.6;color:#0f172a">Thanks,<br/>-<br/>HiveGrid Support</p><div style="margin-top:24px;padding-top:16px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e2e8f0;color:#475569"><div><a href="https://hivegrid.de/datenschutz" style="text-decoration:underline;color:#2563eb">Privacy</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/agb" style="text-decoration:underline;color:#2563eb">Terms</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/impressum" style="text-decoration:underline;color:#2563eb">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:support@hivegrid.de" style="text-decoration:underline;color:#2563eb">support@hivegrid.de</a>.</div></div></div></div></body></html>"`;
|
||||
|
||||
exports[`SubscriptionFailedEmail > renders default snapshot with reason + retry > text 1`] = `
|
||||
"Action required: payment failed for ToolCTRL
|
||||
ToolCTRL
|
||||
"Action required: payment failed for HiveGrid
|
||||
HiveGrid
|
||||
Payment failed
|
||||
Hi Ada,
|
||||
We were unable to charge your card for the Pro subscription. Please update your payment method to avoid service interruption.
|
||||
@@ -14,16 +14,16 @@ Reason: Card declined
|
||||
Next retry: 2026-05-20
|
||||
Thanks,
|
||||
-
|
||||
ToolCTRL Support
|
||||
Privacy (https://tool-ctrl.de/privacy)·Terms (https://tool-ctrl.de/terms)·Imprint (https://tool-ctrl.de/imprint)
|
||||
Questions? Email us at info@tool-ctrl.de (mailto:info@tool-ctrl.de)."
|
||||
HiveGrid Support
|
||||
Privacy (https://hivegrid.de/datenschutz)·Terms (https://hivegrid.de/agb)·Imprint (https://hivegrid.de/impressum)
|
||||
Questions? Email us at support@hivegrid.de (mailto:support@hivegrid.de)."
|
||||
`;
|
||||
|
||||
exports[`SubscriptionSuccessEmail > renders default snapshot with next-billing > html 1`] = `"<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>Your ToolCTRL subscription is active</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;font-size:16px;line-height:1.5"><div style="display:none;font-size:1px;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden">Your ToolCTRL subscription is active</div><div style="width:100%;max-width:560px;margin:0 auto;padding:24px 16px"><div style="background-color:#ffffff;border:1px solid #e2e8f0;border-radius:20px;padding:32px"><div style="padding-bottom:16px;text-align:left"><strong style="color:#0f172a;font-size:18px">ToolCTRL</strong></div><div style="color:#475569;font-size:13px;font-weight:700;letter-spacing:0.08em;text-transform:uppercase;margin-bottom:8px">Subscription</div><h1 style="margin:8px 0 16px;font-size:28px;line-height:1.2;color:#0f172a;font-weight:700">Thanks, Ada!</h1><p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#0f172a">Your Pro subscription is now active. Welcome aboard!</p><a href="https://app.example.com/billing" style="display:inline-block;background-color:#2563eb;color:#ffffff;padding:12px 22px;border-radius:999px;font-weight:700;font-size:15px;text-decoration:none" target="_blank" rel="noopener noreferrer">Open your dashboard</a><div style="margin-top:20px;padding:14px 16px;border-radius:10px;font-size:14px;line-height:1.55;background-color:#f1f5f9;color:#0f172a;border:1px solid #e2e8f0"><strong>Plan:</strong> Pro<br/><strong>Amount:</strong> $29.00<br/><strong>Next billing:</strong> 2026-06-01</div><p style="margin:24px 0 0;font-size:14px;line-height:1.6;color:#0f172a">Thanks,<br/>-<br/>ToolCTRL Support</p><div style="margin-top:24px;padding-top:16px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e2e8f0;color:#475569"><div><a href="https://tool-ctrl.de/privacy" style="text-decoration:underline;color:#2563eb">Privacy</a><span style="margin:0 6px">·</span><a href="https://tool-ctrl.de/terms" style="text-decoration:underline;color:#2563eb">Terms</a><span style="margin:0 6px">·</span><a href="https://tool-ctrl.de/imprint" style="text-decoration:underline;color:#2563eb">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:info@tool-ctrl.de" style="text-decoration:underline;color:#2563eb">info@tool-ctrl.de</a>.</div></div></div></div></body></html>"`;
|
||||
exports[`SubscriptionSuccessEmail > renders default snapshot with next-billing > html 1`] = `"<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>Your HiveGrid subscription is active</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;font-size:16px;line-height:1.5"><div style="display:none;font-size:1px;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden">Your HiveGrid subscription is active</div><div style="width:100%;max-width:560px;margin:0 auto;padding:24px 16px"><div style="background-color:#ffffff;border:1px solid #e2e8f0;border-radius:20px;padding:32px"><div style="padding-bottom:16px;text-align:left"><strong style="color:#0f172a;font-size:18px">HiveGrid</strong></div><div style="color:#475569;font-size:13px;font-weight:700;letter-spacing:0.08em;text-transform:uppercase;margin-bottom:8px">Subscription</div><h1 style="margin:8px 0 16px;font-size:28px;line-height:1.2;color:#0f172a;font-weight:700">Thanks, Ada!</h1><p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#0f172a">Your Pro subscription is now active. Welcome aboard!</p><a href="https://app.example.com/billing" style="display:inline-block;background-color:#2563eb;color:#ffffff;padding:12px 22px;border-radius:999px;font-weight:700;font-size:15px;text-decoration:none" target="_blank" rel="noopener noreferrer">Open your dashboard</a><div style="margin-top:20px;padding:14px 16px;border-radius:10px;font-size:14px;line-height:1.55;background-color:#f1f5f9;color:#0f172a;border:1px solid #e2e8f0"><strong>Plan:</strong> Pro<br/><strong>Amount:</strong> $29.00<br/><strong>Next billing:</strong> 2026-06-01</div><p style="margin:24px 0 0;font-size:14px;line-height:1.6;color:#0f172a">Thanks,<br/>-<br/>HiveGrid Support</p><div style="margin-top:24px;padding-top:16px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e2e8f0;color:#475569"><div><a href="https://hivegrid.de/datenschutz" style="text-decoration:underline;color:#2563eb">Privacy</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/agb" style="text-decoration:underline;color:#2563eb">Terms</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/impressum" style="text-decoration:underline;color:#2563eb">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:support@hivegrid.de" style="text-decoration:underline;color:#2563eb">support@hivegrid.de</a>.</div></div></div></div></body></html>"`;
|
||||
|
||||
exports[`SubscriptionSuccessEmail > renders default snapshot with next-billing > text 1`] = `
|
||||
"Your ToolCTRL subscription is active
|
||||
ToolCTRL
|
||||
"Your HiveGrid subscription is active
|
||||
HiveGrid
|
||||
Subscription
|
||||
Thanks, Ada!
|
||||
Your Pro subscription is now active. Welcome aboard!
|
||||
@@ -32,7 +32,7 @@ Amount: $29.00
|
||||
Next billing: 2026-06-01
|
||||
Thanks,
|
||||
-
|
||||
ToolCTRL Support
|
||||
Privacy (https://tool-ctrl.de/privacy)·Terms (https://tool-ctrl.de/terms)·Imprint (https://tool-ctrl.de/imprint)
|
||||
Questions? Email us at info@tool-ctrl.de (mailto:info@tool-ctrl.de)."
|
||||
HiveGrid Support
|
||||
Privacy (https://hivegrid.de/datenschutz)·Terms (https://hivegrid.de/agb)·Imprint (https://hivegrid.de/impressum)
|
||||
Questions? Email us at support@hivegrid.de (mailto:support@hivegrid.de)."
|
||||
`;
|
||||
+7
-7
@@ -1,16 +1,16 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`WelcomeEmail > renders default-brand named welcome (snapshot) > html 1`] = `"<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>Welcome to ToolCTRL, Ada!</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;font-size:16px;line-height:1.5"><div style="display:none;font-size:1px;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden">Welcome to ToolCTRL, Ada!</div><div style="width:100%;max-width:560px;margin:0 auto;padding:24px 16px"><div style="background-color:#ffffff;border:1px solid #e2e8f0;border-radius:20px;padding:32px"><div style="padding-bottom:16px;text-align:left"><strong style="color:#0f172a;font-size:18px">ToolCTRL</strong></div><div style="color:#475569;font-size:13px;font-weight:700;letter-spacing:0.08em;text-transform:uppercase;margin-bottom:8px">Welcome</div><h1 style="margin:8px 0 16px;font-size:28px;line-height:1.2;color:#0f172a;font-weight:700">Welcome, Ada!</h1><p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#0f172a">Thanks for trying ToolCTRL.</p><a href="https://app.example.com/login" style="display:inline-block;background-color:#2563eb;color:#ffffff;padding:12px 22px;border-radius:999px;font-weight:700;font-size:15px;text-decoration:none" target="_blank" rel="noopener noreferrer">Click here to log in</a><p style="margin:24px 0 0;font-size:14px;line-height:1.6;color:#0f172a">Thanks,<br/>-<br/>ToolCTRL Support</p><div style="margin-top:24px;padding-top:16px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e2e8f0;color:#475569"><div><a href="https://tool-ctrl.de/privacy" style="text-decoration:underline;color:#2563eb">Privacy</a><span style="margin:0 6px">·</span><a href="https://tool-ctrl.de/terms" style="text-decoration:underline;color:#2563eb">Terms</a><span style="margin:0 6px">·</span><a href="https://tool-ctrl.de/imprint" style="text-decoration:underline;color:#2563eb">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:info@tool-ctrl.de" style="text-decoration:underline;color:#2563eb">info@tool-ctrl.de</a>.</div></div></div></div></body></html>"`;
|
||||
exports[`WelcomeEmail > renders default-brand named welcome (snapshot) > html 1`] = `"<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>Welcome to HiveGrid, Ada!</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;font-size:16px;line-height:1.5"><div style="display:none;font-size:1px;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden">Welcome to HiveGrid, Ada!</div><div style="width:100%;max-width:560px;margin:0 auto;padding:24px 16px"><div style="background-color:#ffffff;border:1px solid #e2e8f0;border-radius:20px;padding:32px"><div style="padding-bottom:16px;text-align:left"><strong style="color:#0f172a;font-size:18px">HiveGrid</strong></div><div style="color:#475569;font-size:13px;font-weight:700;letter-spacing:0.08em;text-transform:uppercase;margin-bottom:8px">Welcome</div><h1 style="margin:8px 0 16px;font-size:28px;line-height:1.2;color:#0f172a;font-weight:700">Welcome, Ada!</h1><p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#0f172a">Thanks for trying HiveGrid.</p><a href="https://app.example.com/login" style="display:inline-block;background-color:#2563eb;color:#ffffff;padding:12px 22px;border-radius:999px;font-weight:700;font-size:15px;text-decoration:none" target="_blank" rel="noopener noreferrer">Click here to log in</a><p style="margin:24px 0 0;font-size:14px;line-height:1.6;color:#0f172a">Thanks,<br/>-<br/>HiveGrid Support</p><div style="margin-top:24px;padding-top:16px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e2e8f0;color:#475569"><div><a href="https://hivegrid.de/datenschutz" style="text-decoration:underline;color:#2563eb">Privacy</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/agb" style="text-decoration:underline;color:#2563eb">Terms</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/impressum" style="text-decoration:underline;color:#2563eb">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:support@hivegrid.de" style="text-decoration:underline;color:#2563eb">support@hivegrid.de</a>.</div></div></div></div></body></html>"`;
|
||||
|
||||
exports[`WelcomeEmail > renders default-brand named welcome (snapshot) > text 1`] = `
|
||||
"Welcome to ToolCTRL, Ada!
|
||||
ToolCTRL
|
||||
"Welcome to HiveGrid, Ada!
|
||||
HiveGrid
|
||||
Welcome
|
||||
Welcome, Ada!
|
||||
Thanks for trying ToolCTRL.
|
||||
Thanks for trying HiveGrid.
|
||||
Click here to log in (https://app.example.com/login)Thanks,
|
||||
-
|
||||
ToolCTRL Support
|
||||
Privacy (https://tool-ctrl.de/privacy)·Terms (https://tool-ctrl.de/terms)·Imprint (https://tool-ctrl.de/imprint)
|
||||
Questions? Email us at info@tool-ctrl.de (mailto:info@tool-ctrl.de)."
|
||||
HiveGrid Support
|
||||
Privacy (https://hivegrid.de/datenschutz)·Terms (https://hivegrid.de/agb)·Imprint (https://hivegrid.de/impressum)
|
||||
Questions? Email us at support@hivegrid.de (mailto:support@hivegrid.de)."
|
||||
`;
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { renderReactEmail } from "../render-helpers.js";
|
||||
import { defaultMailBrand } from "../_layout/theme.js";
|
||||
import { TenantNotificationEmail } from "./TenantNotification.js";
|
||||
|
||||
describe("TenantNotificationEmail default action label", () => {
|
||||
test("uses the built-in 'Open' label when an actionUrl is present but no label override is given", () => {
|
||||
const { html } = renderReactEmail(
|
||||
<TenantNotificationEmail
|
||||
brand={defaultMailBrand}
|
||||
title="New comment"
|
||||
body="Grace mentioned you."
|
||||
actionUrl="https://app.example.com/tickets/42"
|
||||
/>
|
||||
);
|
||||
|
||||
expect(html).toContain('href="https://app.example.com/tickets/42"');
|
||||
expect(html).toContain(">Open<");
|
||||
// The support fallback label must not appear when an action URL exists.
|
||||
expect(html).not.toContain("Contact support");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user