Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -30,11 +30,19 @@ export {
buildBrand,
withBrandDefaults,
defaultMailBrand,
hiveGridMailLinks,
mailBrandFromTokens,
} from "./templates-react/render.js";
export type {
ReactTransactionalTemplateName,
ReactTemplatePropsMap,
RenderedReactEmail,
MailBrand,
MailFooterCopy,
MailLanguage,
SystemMessageDetail,
SystemMessageEmailProps,
} from "./templates-react/render.js";
export { InvalidActionUrlError, assertSafeUrl } from "./templates-react/_layout/Button.js";
export { renderSystemMessageEmail, resolveSystemMailChrome } from "./templates-react/system-mail.js";
export type { RenderSystemMessageInput } from "./templates-react/system-mail.js";
@@ -142,12 +142,8 @@ describe("MailjetProvider attachment mapping", () => {
});
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" },
]);
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 () => {
@@ -162,9 +158,7 @@ describe("MailjetProvider attachment mapping", () => {
],
});
const types = (sentPayload(fetchMock).Messages[0]!.Attachments as Array<{ ContentType: string }>).map(
(a) => a.ContentType
);
const types = (sentPayload(fetchMock).Messages[0]!.Attachments as Array<{ ContentType: string }>).map((a) => a.ContentType);
expect(types).toEqual(["application/octet-stream", "application/octet-stream"]);
});
});
@@ -187,9 +181,7 @@ describe("MailjetProvider response parsing edge cases", () => {
});
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 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");
@@ -14,7 +14,11 @@ function jsonResponse(body: unknown, init: ResponseInit = {}) {
}
function successBody(messageUuid = "uuid-123") {
return { Messages: [{ Status: "success", To: [{ Email: "to@example.com", MessageID: 456, MessageUUID: messageUuid, MessageHref: "https://api.mailjet.com/v3/message/456" }] }] };
return {
Messages: [
{ Status: "success", To: [{ Email: "to@example.com", MessageID: 456, MessageUUID: messageUuid, MessageHref: "https://api.mailjet.com/v3/message/456" }] },
],
};
}
function captureError(fn: () => unknown): unknown {
@@ -115,6 +119,41 @@ describe("MailjetProvider", () => {
});
});
test("serializes disabled tracking settings to Mailjet v3.1 flags", async () => {
const fetchMock = vi.fn(async () => jsonResponse(successBody(), { status: 200 }));
const provider = new MailjetProvider({
apiKey: "api_key",
secretKey: "secret_key",
fromEmail: "sender@example.com",
fetch: fetchMock as unknown as typeof fetch,
});
await provider.send({
to: ["user@example.com"],
subject: "Portal setup",
text: "Complete your setup",
settings: { trackClicks: false, trackOpens: false },
});
expect(fetchMock).toHaveBeenCalledWith(
"https://api.mailjet.com/v3.1/send",
expect.objectContaining({
body: JSON.stringify({
Messages: [
{
From: { Email: "sender@example.com" },
To: [{ Email: "user@example.com" }],
Subject: "Portal setup",
TextPart: "Complete your setup",
TrackOpens: "disabled",
TrackClicks: "disabled",
},
],
}),
})
);
});
test("creates providers only from explicit Mailjet fixture env", async () => {
const fetchMock = vi.fn(async () => jsonResponse(successBody("msg_fixture"), { status: 200 }));
const provider = createMailjetProviderFromEnv({
@@ -164,6 +203,36 @@ describe("MailjetProvider", () => {
);
});
test("preserves 64-character CustomIDs and deterministically compacts longer signup keys", async () => {
const fetchMock = vi.fn(async (_input: Parameters<typeof fetch>[0], _init?: Parameters<typeof fetch>[1]) =>
jsonResponse(successBody("msg_compacted"), { status: 200 })
);
const provider = new MailjetProvider({
apiKey: "api_key",
secretKey: "secret_key",
fromEmail: "sender@example.com",
fetch: fetchMock as unknown as typeof fetch,
});
const acceptedBoundary = "a".repeat(64);
const signupKey = `mail:signup-welcome:tenant_1:${"b".repeat(64)}`;
const distinctSignupKey = `${signupKey.slice(0, -1)}c`;
for (const idempotencyKey of [acceptedBoundary, signupKey, signupKey, distinctSignupKey]) {
await provider.send({ to: ["user@example.com"], subject: "Welcome", text: "Hello", idempotencyKey });
}
const customIds = fetchMock.mock.calls.map(([_, init]) => {
const payload = JSON.parse(String(init?.body)) as { Messages: Array<{ CustomID: string }> };
return payload.Messages[0]?.CustomID;
});
expect(customIds[0]).toBe(acceptedBoundary);
expect(customIds[1]).toMatch(/^hivegrid-id:[a-f0-9]{52}$/);
expect(customIds[1]).toBe(customIds[2]);
expect(customIds[1]).not.toBe(customIds[3]);
expect(customIds.every((customId) => customId !== undefined && customId.length <= 64)).toBe(true);
expect(JSON.stringify(fetchMock.mock.calls)).not.toContain(signupKey);
});
test("adds the SandboxMode flag when sandbox is enabled", async () => {
const fetchMock = vi.fn(async () => jsonResponse(successBody(), { status: 200 }));
const provider = new MailjetProvider({
@@ -1,8 +1,12 @@
import { createHash } from "node:crypto";
import { MailProviderError, type MailAddress, type MailAddressInput, type MailProvider, type SendMailInput, type SendMailResult } from "./types.js";
export const mailjetApiBaseUrl = "https://api.mailjet.com";
const DEFAULT_MAILJET_TIMEOUT_MS = 10_000;
const DEFAULT_RESPONSE_BODY_LIMIT_BYTES = 4_096;
const MAILJET_CUSTOM_ID_MAX_LENGTH = 64;
const MAILJET_CUSTOM_ID_HASH_PREFIX = "hivegrid-id:";
type Fetch = typeof fetch;
@@ -131,7 +135,7 @@ export class MailjetProvider implements MailProvider {
},
body: JSON.stringify(payload),
},
this.timeoutMs,
this.timeoutMs
);
} catch (error) {
this.emitMetric("failed");
@@ -292,7 +296,7 @@ function normalizeAttachments(attachments: SendMailInput["attachments"]): { atta
ContentType: guessContentType(attachment.filename),
Filename: attachment.filename,
Base64Content: attachment.content,
ContentID: attachment.disposition === "inline" ? attachment.id ?? attachment.filename : undefined,
ContentID: attachment.disposition === "inline" ? (attachment.id ?? attachment.filename) : undefined,
});
if (attachment.disposition === "inline") {
@@ -345,8 +349,16 @@ function normalizeCustomId(idempotencyKey: string | undefined): string | undefin
if (!idempotencyKey) {
return undefined;
}
// Mailjet caps CustomID at 100 characters.
return idempotencyKey.slice(0, 100);
if (idempotencyKey.length <= MAILJET_CUSTOM_ID_MAX_LENGTH) {
return idempotencyKey;
}
// Mailjet rejects CustomID values longer than 64 characters. Preserve short
// operational IDs verbatim and compact longer replay keys without truncation
// collisions so signup retries keep the same provider correlation value.
const digestLength = MAILJET_CUSTOM_ID_MAX_LENGTH - MAILJET_CUSTOM_ID_HASH_PREFIX.length;
const digest = createHash("sha256").update(idempotencyKey, "utf8").digest("hex").slice(0, digestLength);
return `${MAILJET_CUSTOM_ID_HASH_PREFIX}${digest}`;
}
type MailjetResponseMessage = {
@@ -34,11 +34,7 @@ describe("QueuedMailProvider sendAt normalization", () => {
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)
);
expect(queue.add).toHaveBeenCalledWith("send-transactional-email", expect.objectContaining({ sendAt: epochSeconds }), expect.any(Object));
});
test("converts a Date sendAt to floored unix seconds", async () => {
@@ -53,10 +49,6 @@ describe("QueuedMailProvider sendAt normalization", () => {
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)
);
expect(queue.add).toHaveBeenCalledWith("send-transactional-email", expect.objectContaining({ sendAt: 1_778_580_001 }), expect.any(Object));
});
});
@@ -139,7 +139,7 @@ describe("QueuedMailProvider", () => {
expect.objectContaining({
metadata: { idempotencyKey: "notification-delivery:delivery_1" },
}),
expect.objectContaining({ jobId: "notification-delivery:delivery_1" })
expect.objectContaining({ jobId: "notification-delivery%3Adelivery_1" })
);
});
@@ -1,6 +1,6 @@
import type { CSSProperties, ReactNode } from "react";
import { Header } from "./Header.js";
import { Footer } from "./Footer.js";
import { Footer, type MailFooterCopy, type MailLanguage } from "./Footer.js";
import type { MailBrand } from "./theme.js";
/**
@@ -13,6 +13,8 @@ export interface BaseLayoutProps {
readonly title: string;
readonly previewText?: string;
readonly unsubscribeUrl?: string;
readonly language?: MailLanguage;
readonly footerCopy?: MailFooterCopy;
readonly children: ReactNode;
}
@@ -30,16 +32,27 @@ const containerStyle: CSSProperties = {
width: "100%",
maxWidth: "560px",
margin: "0 auto",
padding: "24px 16px",
padding: "32px 14px",
};
const cardStyle = (brand: MailBrand): CSSProperties => ({
backgroundColor: brand.surfaceColor,
border: `1px solid ${brand.borderColor}`,
borderRadius: "20px",
padding: "32px",
borderRadius: "22px",
boxShadow: "0 16px 48px rgba(35, 31, 32, 0.08)",
overflow: "hidden",
});
const accentStyle = (brand: MailBrand): CSSProperties => ({
backgroundColor: brand.primaryColor,
height: "7px",
lineHeight: "7px",
});
const contentStyle: CSSProperties = {
padding: "34px 34px 30px",
};
const previewStyle: CSSProperties = {
display: "none",
fontSize: "1px",
@@ -50,9 +63,9 @@ const previewStyle: CSSProperties = {
overflow: "hidden",
} as CSSProperties;
export function BaseLayout({ brand, title, previewText, unsubscribeUrl, children }: BaseLayoutProps) {
export function BaseLayout({ brand, title, previewText, unsubscribeUrl, language = "en", footerCopy, children }: BaseLayoutProps) {
return (
<html lang="en">
<html lang={language}>
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
@@ -62,9 +75,12 @@ export function BaseLayout({ brand, title, previewText, unsubscribeUrl, children
{previewText ? <div style={previewStyle}>{previewText}</div> : null}
<div style={containerStyle}>
<div style={cardStyle(brand)}>
<Header brand={brand} />
{children}
<Footer brand={brand} unsubscribeUrl={unsubscribeUrl} />
<div style={accentStyle(brand)}>&nbsp;</div>
<div style={contentStyle}>
<Header brand={brand} />
{children}
<Footer brand={brand} unsubscribeUrl={unsubscribeUrl} copy={footerCopy} />
</div>
</div>
</div>
</body>
@@ -39,15 +39,17 @@ export function Button({ href, brand, children }: ButtonProps) {
display: "inline-block",
backgroundColor: brand.primaryColor,
color: brand.primaryTextColor,
padding: "12px 22px",
borderRadius: "999px",
padding: "13px 20px",
border: `1px solid ${brand.primaryColor}`,
borderRadius: "10px",
fontWeight: 700,
fontSize: "15px",
fontSize: "16px",
lineHeight: "1.25",
textDecoration: "none",
};
return (
<a href={href} style={style} target="_blank" rel="noopener noreferrer">
{children}
{children} <span aria-hidden="true">→</span>
</a>
);
}
@@ -11,10 +11,10 @@ export interface EyebrowProps {
}
const style = (brand: MailBrand): CSSProperties => ({
color: brand.mutedTextColor,
fontSize: "13px",
color: brand.linkColor,
fontSize: "12px",
fontWeight: 700,
letterSpacing: "0.08em",
letterSpacing: "0.1em",
textTransform: "uppercase",
marginBottom: "8px",
});
@@ -1,4 +1,5 @@
import type { CSSProperties } from "react";
import type { SupportedLocale } from "@hivegrid/i18n";
import type { MailBrand } from "./theme.js";
/**
@@ -8,11 +9,38 @@ import type { MailBrand } from "./theme.js";
export interface FooterProps {
readonly brand: MailBrand;
readonly unsubscribeUrl?: string;
readonly copy?: MailFooterCopy;
}
export type MailLanguage = SupportedLocale;
export interface MailFooterCopy {
readonly privacyLabel: string;
readonly termsLabel: string;
readonly imprintLabel: string;
readonly unsubscribeLabel: string;
readonly supportBefore: string;
readonly supportLinkLabel: string;
readonly supportAfter: string;
readonly signoffClosing?: string;
readonly signoffTeam?: string;
}
export const defaultMailFooterCopy: MailFooterCopy = {
privacyLabel: "Privacy",
termsLabel: "Terms",
imprintLabel: "Imprint",
unsubscribeLabel: "Unsubscribe",
supportBefore: "Questions? Email us at",
supportLinkLabel: "",
supportAfter: ".",
signoffClosing: "Kind regards,",
signoffTeam: "Your HiveGrid team",
};
const wrapperStyle: CSSProperties = {
marginTop: "24px",
paddingTop: "16px",
marginTop: "32px",
paddingTop: "20px",
borderTop: "1px solid",
fontSize: "12px",
lineHeight: "1.5",
@@ -23,44 +51,44 @@ const linkStyle = (color: string): CSSProperties => ({
color,
});
export function Footer({ brand, unsubscribeUrl }: FooterProps) {
export function Footer({ brand, unsubscribeUrl, copy = defaultMailFooterCopy }: FooterProps) {
return (
<div style={{ ...wrapperStyle, borderTopColor: brand.borderColor, color: brand.mutedTextColor }}>
<div style={{ color: brand.textColor, fontSize: "13px", fontWeight: 700, marginBottom: "10px" }}>HiveGrid</div>
<div>
{brand.privacyUrl ? (
<a href={brand.privacyUrl} style={linkStyle(brand.linkColor)}>
Privacy
{copy.privacyLabel}
</a>
) : null}
{brand.privacyUrl && brand.termsUrl ? <span style={{ margin: "0 6px" }}>·</span> : null}
{brand.termsUrl ? (
<a href={brand.termsUrl} style={linkStyle(brand.linkColor)}>
Terms
{copy.termsLabel}
</a>
) : null}
{(brand.privacyUrl || brand.termsUrl) && brand.imprintUrl ? (
<span style={{ margin: "0 6px" }}>·</span>
) : null}
{(brand.privacyUrl || brand.termsUrl) && brand.imprintUrl ? <span style={{ margin: "0 6px" }}>·</span> : null}
{brand.imprintUrl ? (
<a href={brand.imprintUrl} style={linkStyle(brand.linkColor)}>
Imprint
{copy.imprintLabel}
</a>
) : null}
</div>
{unsubscribeUrl ? (
<div style={{ marginTop: "8px" }}>
<a href={unsubscribeUrl} style={linkStyle(brand.linkColor)}>
Unsubscribe
{copy.unsubscribeLabel}
</a>
</div>
) : null}
<div style={{ marginTop: "8px" }}>
Questions? Email us at{" "}
{copy.supportBefore}{" "}
<a href={`mailto:${brand.supportEmail}`} style={linkStyle(brand.linkColor)}>
{brand.supportEmail}
{copy.supportLinkLabel || brand.supportEmail}
</a>
.
{copy.supportAfter}
</div>
<div style={{ marginTop: "10px" }}>© HiveGrid</div>
</div>
);
}
@@ -10,33 +10,35 @@ export interface HeaderProps {
}
const headerStyle: CSSProperties = {
paddingBottom: "16px",
paddingBottom: "24px",
textAlign: "left",
};
const logoStyle: CSSProperties = {
display: "block",
border: 0,
borderRadius: "12px",
};
export function Header({ brand }: HeaderProps) {
if (brand.logoUrl) {
return (
<div style={headerStyle}>
<img
src={brand.logoUrl}
alt={brand.productName}
width={48}
height={48}
style={logoStyle}
/>
</div>
);
}
return (
<div style={headerStyle}>
<strong style={{ color: brand.textColor, fontSize: "18px" }}>{brand.productName}</strong>
<a href={brand.siteUrl} style={{ color: brand.textColor, textDecoration: "none" }} target="_blank" rel="noopener noreferrer">
<span style={{ display: "inline-block", verticalAlign: "middle" }}>
{brand.logoUrl ? <img src={brand.logoUrl} alt="HiveGrid" width={42} height={36} style={logoStyle} /> : null}
</span>
<strong
style={{
color: brand.textColor,
display: "inline-block",
fontSize: "22px",
letterSpacing: "-0.03em",
marginLeft: brand.logoUrl ? "10px" : 0,
verticalAlign: "middle",
}}
>
HiveGrid
</strong>
</a>
</div>
);
}
@@ -12,9 +12,9 @@ export interface InfoBoxProps {
}
const baseStyle: CSSProperties = {
marginTop: "20px",
padding: "14px 16px",
borderRadius: "10px",
marginTop: "24px",
padding: "16px 18px",
borderRadius: "12px",
fontSize: "14px",
lineHeight: "1.55",
};
@@ -22,7 +22,7 @@ const baseStyle: CSSProperties = {
export function InfoBox({ brand, tone = "info", children }: InfoBoxProps) {
const style: CSSProperties =
tone === "warning"
? { ...baseStyle, backgroundColor: "#fef3c7", color: "#92400e", border: "1px solid #fde68a" }
: { ...baseStyle, backgroundColor: "#f1f5f9", color: brand.textColor, border: `1px solid ${brand.borderColor}` };
? { ...baseStyle, backgroundColor: "#fff8df", color: "#5f4300", border: "1px solid #f0d684" }
: { ...baseStyle, backgroundColor: "#f8f6f2", color: brand.textColor, border: `1px solid ${brand.borderColor}` };
return <div style={style}>{children}</div>;
}
@@ -1,14 +1,17 @@
// 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, &#x27;Segoe UI&#x27;, Roboto, &#x27;Helvetica Neue&#x27;, 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 > keeps platform identity while applying safe color overrides 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://hivegrid.de/hivegrid-logo.png"/><title>Hi</title></head><body style="margin:0;padding:0;background-color:#f7f5f1;color:#231f20;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, &#x27;Segoe UI&#x27;, Roboto, &#x27;Helvetica Neue&#x27;, 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:32px 14px"><div style="background-color:#ffffff;border:1px solid #e7e1d8;border-radius:22px;box-shadow:0 16px 48px rgba(35, 31, 32, 0.08);overflow:hidden"><div style="background-color:#123456;height:7px;line-height:7px"> </div><div style="padding:34px 34px 30px"><div style="padding-bottom:24px;text-align:left"><a href="https://hivegrid.de" style="color:#231f20;text-decoration:none" target="_blank" rel="noopener noreferrer"><span style="display:inline-block;vertical-align:middle"><img src="https://hivegrid.de/hivegrid-logo.png" alt="HiveGrid" width="42" height="36" style="display:block;border:0"/></span><strong style="color:#231f20;display:inline-block;font-size:22px;letter-spacing:-0.03em;margin-left:10px;vertical-align:middle">HiveGrid</strong></a></div><p>Body</p><div style="margin-top:32px;padding-top:20px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e7e1d8;color:#655f59"><div style="color:#231f20;font-size:13px;font-weight:700;margin-bottom:10px">HiveGrid</div><div><a href="https://hivegrid.de/datenschutz" style="text-decoration:underline;color:#735400">Privacy</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/agb" style="text-decoration:underline;color:#735400">Terms</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/impressum" style="text-decoration:underline;color:#735400">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:support@hivegrid.de" style="text-decoration:underline;color:#735400">support@hivegrid.de</a>.</div><div style="margin-top:10px">© HiveGrid</div></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, &#x27;Segoe UI&#x27;, Roboto, &#x27;Helvetica Neue&#x27;, 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 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://hivegrid.de/hivegrid-logo.png"/><title>Hello</title></head><body style="margin:0;padding:0;background-color:#f7f5f1;color:#231f20;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, &#x27;Segoe UI&#x27;, Roboto, &#x27;Helvetica Neue&#x27;, 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:32px 14px"><div style="background-color:#ffffff;border:1px solid #e7e1d8;border-radius:22px;box-shadow:0 16px 48px rgba(35, 31, 32, 0.08);overflow:hidden"><div style="background-color:#f1b729;height:7px;line-height:7px"> </div><div style="padding:34px 34px 30px"><div style="padding-bottom:24px;text-align:left"><a href="https://hivegrid.de" style="color:#231f20;text-decoration:none" target="_blank" rel="noopener noreferrer"><span style="display:inline-block;vertical-align:middle"><img src="https://hivegrid.de/hivegrid-logo.png" alt="HiveGrid" width="42" height="36" style="display:block;border:0"/></span><strong style="color:#231f20;display:inline-block;font-size:22px;letter-spacing:-0.03em;margin-left:10px;vertical-align:middle">HiveGrid</strong></a></div><div style="color:#735400;font-size:12px;font-weight:700;letter-spacing:0.1em;text-transform:uppercase;margin-bottom:8px">Eyebrow</div><h1>Title</h1><div style="margin-top:32px;padding-top:20px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e7e1d8;color:#655f59"><div style="color:#231f20;font-size:13px;font-weight:700;margin-bottom:10px">HiveGrid</div><div><a href="https://hivegrid.de/datenschutz" style="text-decoration:underline;color:#735400">Privacy</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/agb" style="text-decoration:underline;color:#735400">Terms</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/impressum" style="text-decoration:underline;color:#735400">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:support@hivegrid.de" style="text-decoration:underline;color:#735400">support@hivegrid.de</a>.</div><div style="margin-top:10px">© HiveGrid</div></div></div></div></div></body></html>"`;
exports[`BaseLayout > renders default-brand snapshot 2`] = `
"A preview
HiveGrid
 
HiveGrid (https://hivegrid.de)
Eyebrow
Title
HiveGrid
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)."
Questions? Email us at support@hivegrid.de (mailto:support@hivegrid.de).
© HiveGrid"
`;
@@ -4,4 +4,4 @@ export { Footer, type FooterProps } from "./Footer.js";
export { Button, InvalidActionUrlError, assertSafeUrl, type ButtonProps } from "./Button.js";
export { InfoBox, type InfoBoxProps } from "./InfoBox.js";
export { Eyebrow, type EyebrowProps } from "./Eyebrow.js";
export { defaultMailBrand, withBrandDefaults, type MailBrand } from "./theme.js";
export { defaultMailBrand, hiveGridMailLinks, mailBrandFromTokens, withBrandDefaults, type MailBrand } from "./theme.js";
@@ -4,31 +4,28 @@ 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", () => {
describe("Footer platform-link contract", () => {
test("keeps every platform legal link when overrides try to remove them", () => {
const brand = withBrandDefaults({ privacyUrl: undefined, termsUrl: undefined, imprintUrl: undefined });
const { html } = renderReactEmail(
<Footer brand={brand} unsubscribeUrl="https://app.example.com/unsubscribe?token=abc" />
);
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(">Privacy<");
expect(html).toContain(">Terms<");
expect(html).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", () => {
test("keeps terms and imprint when a partial override tries to remove them", () => {
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(">·<");
expect(html).toContain(">Terms<");
expect(html).toContain(">Imprint<");
expect(html).toContain(">·<");
// No unsubscribe link when none was supplied.
expect(html).not.toContain(">Unsubscribe<");
});
@@ -18,7 +18,7 @@ describe("BaseLayout", () => {
expect(result.text).toMatchSnapshot();
});
test("applies tenant brand overrides (logo + primary color)", () => {
test("keeps platform identity while applying safe color overrides", () => {
const brand = withBrandDefaults({
productName: "Acme",
logoUrl: "https://cdn.acme.test/logo.png",
@@ -30,10 +30,38 @@ describe("BaseLayout", () => {
<p>Body</p>
</BaseLayout>
);
expect(result.html).toContain("https://cdn.acme.test/logo.png");
expect(result.html).toContain("Acme");
expect(result.html).toContain("https://hivegrid.de/hivegrid-logo.png");
expect(result.html).not.toContain("https://cdn.acme.test/logo.png");
expect(result.html).toMatchSnapshot();
});
test("renders localized document language, footer, and unsubscribe label", () => {
const { html, text } = renderReactEmail(
<BaseLayout
brand={defaultMailBrand}
title="Willkommen"
language="de"
unsubscribeUrl="https://app.example.com/abmelden"
footerCopy={{
privacyLabel: "Datenschutz",
termsLabel: "AGB",
imprintLabel: "Impressum",
unsubscribeLabel: "Abmelden",
supportBefore: "Bei Fragen kannst du uns gerne",
supportLinkLabel: "eine E-Mail schreiben",
supportAfter: ".",
}}
>
<p>Hallo!</p>
</BaseLayout>
);
expect(html).toContain('<html lang="de">');
expect(html).toContain(">Datenschutz<");
expect(html).toContain(">Abmelden<");
expect(html).toContain(">eine E-Mail schreiben<");
expect(text).toContain("Abmelden (https://app.example.com/abmelden)");
});
});
describe("Button safety", () => {
@@ -55,25 +83,20 @@ describe("Button safety", () => {
expect(html).toContain('href="mailto:hi@example.com"');
});
test.each(["javascript:alert(1)", "http://insecure.test", "data:text/html,<script>", "not a url"])(
"rejects unsafe href %s",
(href) => {
expect(() =>
renderReactEmail(
<Button brand={defaultMailBrand} href={href}>
X
</Button>
)
).toThrow(InvalidActionUrlError);
}
);
test.each(["javascript:alert(1)", "http://insecure.test", "data:text/html,<script>", "not a url"])("rejects unsafe href %s", (href) => {
expect(() =>
renderReactEmail(
<Button brand={defaultMailBrand} href={href}>
X
</Button>
)
).toThrow(InvalidActionUrlError);
});
});
describe("InfoBox", () => {
test("renders info tone", () => {
const { html } = renderReactEmail(
<InfoBox brand={defaultMailBrand}>Note</InfoBox>
);
const { html } = renderReactEmail(<InfoBox brand={defaultMailBrand}>Note</InfoBox>);
expect(html).toContain("Note");
});
@@ -84,7 +107,7 @@ describe("InfoBox", () => {
</InfoBox>
);
expect(html).toContain("Heads up");
expect(html).toMatch(/#fef3c7/i);
expect(html).toMatch(/#fff8df/i);
});
});
@@ -1,3 +1,5 @@
import type { BrandTokens } from "@hivegrid/brand";
/**
* Default brand-theme tokens for React-Email transactional templates.
*
@@ -8,6 +10,7 @@
*/
export interface MailBrand {
readonly productName: string;
readonly siteUrl: string;
readonly logoUrl?: string;
readonly primaryColor: string;
readonly primaryTextColor: string;
@@ -26,26 +29,58 @@ export interface MailBrand {
readonly tenantName?: string;
}
export const defaultMailBrand: MailBrand = {
productName: "HiveGrid",
primaryColor: "#2563eb",
primaryTextColor: "#ffffff",
textColor: "#0f172a",
mutedTextColor: "#475569",
backgroundColor: "#f4f5f7",
surfaceColor: "#ffffff",
borderColor: "#e2e8f0",
linkColor: "#2563eb",
fontFamily:
"ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif",
supportEmail: "support@hivegrid.de",
supportFromName: "HiveGrid Support",
export const hiveGridMailLinks = {
siteUrl: "https://hivegrid.de",
logoUrl: "https://hivegrid.de/hivegrid-logo.png",
privacyUrl: "https://hivegrid.de/datenschutz",
termsUrl: "https://hivegrid.de/agb",
imprintUrl: "https://hivegrid.de/impressum",
} as const;
export const defaultMailBrand: MailBrand = {
productName: "HiveGrid",
siteUrl: hiveGridMailLinks.siteUrl,
logoUrl: hiveGridMailLinks.logoUrl,
primaryColor: "#f1b729",
primaryTextColor: "#231f20",
textColor: "#231f20",
mutedTextColor: "#655f59",
backgroundColor: "#f7f5f1",
surfaceColor: "#ffffff",
borderColor: "#e7e1d8",
linkColor: "#735400",
fontFamily: "ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif",
supportEmail: "support@hivegrid.de",
supportFromName: "HiveGrid-Team",
privacyUrl: hiveGridMailLinks.privacyUrl,
termsUrl: hiveGridMailLinks.termsUrl,
imprintUrl: hiveGridMailLinks.imprintUrl,
} as const;
export function withBrandDefaults(override?: Partial<MailBrand>): MailBrand {
if (!override) return defaultMailBrand;
return { ...defaultMailBrand, ...override };
return {
...defaultMailBrand,
...override,
siteUrl: hiveGridMailLinks.siteUrl,
logoUrl: hiveGridMailLinks.logoUrl,
privacyUrl: hiveGridMailLinks.privacyUrl,
termsUrl: hiveGridMailLinks.termsUrl,
imprintUrl: hiveGridMailLinks.imprintUrl,
};
}
export function mailBrandFromTokens(tokens: BrandTokens): MailBrand {
return withBrandDefaults({
productName: tokens.productName,
primaryColor: tokens.mail.colors.primary,
primaryTextColor: tokens.mail.colors.primaryText,
textColor: tokens.mail.colors.text,
mutedTextColor: tokens.mail.colors.mutedText,
backgroundColor: tokens.mail.colors.background,
surfaceColor: tokens.mail.colors.surface,
borderColor: tokens.mail.colors.border,
linkColor: tokens.mail.colors.link,
supportEmail: tokens.support.email,
supportFromName: tokens.support.fromName,
});
}
@@ -4,9 +4,7 @@ import { htmlToPlainText } from "./render-helpers.js";
describe("htmlToPlainText", () => {
test("preserves anchor labels with hrefs for text-mode email clients", () => {
const text = htmlToPlainText(
'<p>Hello Ada,</p><p><a href="https://app.example.com/invite"><strong>Join workspace</strong></a></p>'
);
const text = htmlToPlainText('<p>Hello Ada,</p><p><a href="https://app.example.com/invite"><strong>Join workspace</strong></a></p>');
expect(text).toBe("Hello Ada,\nJoin workspace (https://app.example.com/invite)");
});
@@ -1,14 +1,35 @@
import { describe, expect, test } from "vitest";
import {
reactTransactionalTemplateNames,
renderTransactionalEmail,
withBrandDefaults,
} from "./render.js";
import { createBrandTokens } from "@hivegrid/brand";
import { buildBrand, reactTransactionalTemplateNames, renderTransactionalEmail, withBrandDefaults } from "./render.js";
const brand = withBrandDefaults();
describe("renderTransactionalEmail", () => {
test("exposes all 8 template names", () => {
test("maps nested brand tokens and locks the HiveGrid platform identity", () => {
const mapped = buildBrand(
createBrandTokens({
productName: "Tenant Portal",
siteUrl: "https://tenant.example.test",
legal: {
privacyUrl: "https://tenant.example.test/privacy",
termsUrl: "https://tenant.example.test/terms",
imprintUrl: "https://tenant.example.test/imprint",
},
assets: { logoUrl: "https://tenant.example.test/logo.png" },
mail: { colors: { primary: "#123456" } },
})
);
expect(mapped.productName).toBe("Tenant Portal");
expect(mapped.primaryColor).toBe("#123456");
expect(mapped.logoUrl).toBe("https://hivegrid.de/hivegrid-logo.png");
expect(mapped.siteUrl).toBe("https://hivegrid.de");
expect(mapped.privacyUrl).toBe("https://hivegrid.de/datenschutz");
expect(mapped.termsUrl).toBe("https://hivegrid.de/agb");
expect(mapped.imprintUrl).toBe("https://hivegrid.de/impressum");
});
test("exposes all 9 template names", () => {
const names = reactTransactionalTemplateNames();
expect(names).toEqual([
"welcome",
@@ -18,6 +39,7 @@ describe("renderTransactionalEmail", () => {
"subscription-success",
"subscription-failed",
"invoice-sent",
"system-message",
"tenant-notification",
]);
});
@@ -43,10 +65,27 @@ describe("renderTransactionalEmail", () => {
expect(result.text).toContain("Join Example Org");
});
test("renders a structured system message in HTML and plaintext", () => {
const result = renderTransactionalEmail("system-message", {
brand,
subject: "Appointment confirmed",
eyebrow: "Appointment",
title: "We look forward to seeing you",
intro: "Your appointment is confirmed.",
actionUrl: "https://app.example.com/bookings/42",
actionLabel: "View appointment",
details: [{ label: "Date", value: "17 June 2026, 10:00" }],
});
expect(result.html).toContain("https://hivegrid.de/hivegrid-logo.png");
expect(result.html).toContain("View appointment");
expect(result.text).toContain("Date");
expect(result.text).toContain("17 June 2026, 10:00");
});
test("throws on unknown template", () => {
expect(() =>
renderTransactionalEmail("unknown" as Parameters<typeof renderTransactionalEmail>[0], {} as never)
).toThrow(/Unknown React transactional template/);
expect(() => renderTransactionalEmail("unknown" as Parameters<typeof renderTransactionalEmail>[0], {} as never)).toThrow(
/Unknown React transactional template/
);
});
test("returns html with <!DOCTYPE html> prefix for SSR mode", () => {
@@ -18,16 +18,13 @@ import { WelcomeEmail, type WelcomeEmailProps } from "./transactional/Welcome.js
import { MagicLinkEmail, type MagicLinkEmailProps } from "./transactional/MagicLink.js";
import { PasswordResetEmail, type PasswordResetEmailProps } from "./transactional/PasswordReset.js";
import { InvitationEmail, type InvitationEmailProps } from "./transactional/Invitation.js";
import {
SubscriptionSuccessEmail,
type SubscriptionSuccessEmailProps,
} from "./transactional/SubscriptionSuccess.js";
import {
SubscriptionFailedEmail,
type SubscriptionFailedEmailProps,
} from "./transactional/SubscriptionFailed.js";
import { SubscriptionSuccessEmail, type SubscriptionSuccessEmailProps } from "./transactional/SubscriptionSuccess.js";
import { SubscriptionFailedEmail, type SubscriptionFailedEmailProps } from "./transactional/SubscriptionFailed.js";
import { InvoiceSentEmail, type InvoiceSentEmailProps } from "./transactional/InvoiceSent.js";
import { TenantNotificationEmail, type TenantNotificationEmailProps } from "./transactional/TenantNotification.js";
import { SystemMessageEmail, type SystemMessageEmailProps } from "./transactional/SystemMessage.js";
import type { BrandTokens } from "@hivegrid/brand";
import { mailBrandFromTokens } from "./_layout/theme.js";
export type ReactTransactionalTemplateName =
| "welcome"
@@ -37,6 +34,7 @@ export type ReactTransactionalTemplateName =
| "subscription-success"
| "subscription-failed"
| "invoice-sent"
| "system-message"
| "tenant-notification";
export type ReactTemplatePropsMap = {
@@ -47,6 +45,7 @@ export type ReactTemplatePropsMap = {
"subscription-success": SubscriptionSuccessEmailProps;
"subscription-failed": SubscriptionFailedEmailProps;
"invoice-sent": InvoiceSentEmailProps;
"system-message": SystemMessageEmailProps;
"tenant-notification": TenantNotificationEmailProps;
};
@@ -65,21 +64,16 @@ const COMPONENTS: { [K in ReactTransactionalTemplateName]: (props: ReactTemplate
"subscription-success": SubscriptionSuccessEmail,
"subscription-failed": SubscriptionFailedEmail,
"invoice-sent": InvoiceSentEmail,
"system-message": SystemMessageEmail,
"tenant-notification": TenantNotificationEmail,
};
export function renderTransactionalEmail<K extends ReactTransactionalTemplateName>(
template: K,
props: ReactTemplatePropsMap[K]
): RenderedReactEmail {
export function renderTransactionalEmail<K extends ReactTransactionalTemplateName>(template: K, props: ReactTemplatePropsMap[K]): RenderedReactEmail {
const component = COMPONENTS[template] as (p: AnyTemplateProps) => ReactElement;
if (!component) {
throw new Error(`Unknown React transactional template: ${template}`);
}
const element = createElement<AnyTemplateProps>(
component as (p: AnyTemplateProps) => ReactElement,
props as AnyTemplateProps
);
const element = createElement<AnyTemplateProps>(component as (p: AnyTemplateProps) => ReactElement, props as AnyTemplateProps);
return renderReactEmail(element);
}
@@ -87,9 +81,16 @@ export function reactTransactionalTemplateNames(): readonly ReactTransactionalTe
return Object.keys(COMPONENTS) as ReactTransactionalTemplateName[];
}
export function buildBrand(override?: Partial<MailBrand>): MailBrand {
return withBrandDefaults(override);
function isBrandTokens(value: Partial<MailBrand> | BrandTokens): value is BrandTokens {
return "mail" in value && "assets" in value && "legal" in value;
}
export { withBrandDefaults, defaultMailBrand } from "./_layout/theme.js";
export function buildBrand(override?: Partial<MailBrand> | BrandTokens): MailBrand {
if (!override) return withBrandDefaults();
return isBrandTokens(override) ? mailBrandFromTokens(override) : withBrandDefaults(override);
}
export { withBrandDefaults, defaultMailBrand, hiveGridMailLinks, mailBrandFromTokens } from "./_layout/theme.js";
export type { MailBrand } from "./_layout/theme.js";
export type { MailFooterCopy, MailLanguage } from "./_layout/Footer.js";
export type { SystemMessageDetail, SystemMessageEmailProps } from "./transactional/SystemMessage.js";
@@ -0,0 +1,39 @@
import { describe, expect, test } from "vitest";
import { renderSystemMessageEmail, resolveSystemMailChrome } from "./system-mail.js";
describe("system mail renderer", () => {
test("renders the locked HiveGrid identity and complete plain text", () => {
const rendered = renderSystemMessageEmail({
locale: "de",
subject: "Dein Termin ist bestätigt",
previewText: "Alle Details zu deinem Termin",
eyebrow: "Terminbestätigung",
title: "Wir sehen uns am Dienstag",
intro: "Dein Termin wurde erfolgreich eingetragen.",
actionUrl: "https://app.hivegrid.de/termine/booking-1",
actionLabel: "Termin öffnen",
details: [{ label: "Beginn", value: "Dienstag, 10:30 Uhr" }],
notice: "Du kannst diesen Termin bis 24 Stunden vorher ändern.",
});
expect(rendered.html).toContain("https://hivegrid.de/hivegrid-logo.png");
expect(rendered.html).toContain("https://hivegrid.de/agb");
expect(rendered.html).toContain("https://hivegrid.de/datenschutz");
expect(rendered.html).toContain("https://hivegrid.de/impressum");
expect(rendered.html).toContain("Wir sehen uns am Dienstag");
expect(rendered.text).toContain("Beginn");
expect(rendered.text).toContain("Dienstag, 10:30 Uhr");
expect(rendered.text).toContain("https://app.hivegrid.de/termine/booking-1");
expect(rendered.text).toContain("Dein HiveGrid-Team");
});
test("normalizes every supported locale and keeps the formal German sign-off", () => {
expect(resolveSystemMailChrome("pl-PL").language).toBe("pl");
expect(resolveSystemMailChrome("ru-RU").language).toBe("ru");
expect(resolveSystemMailChrome("uk-UA").language).toBe("uk");
expect(resolveSystemMailChrome("hu-HU").language).toBe("hu");
expect(resolveSystemMailChrome("de-formal").footerCopy.signoffTeam).toBe("Ihr HiveGrid-Team");
expect(resolveSystemMailChrome("unsupported").language).toBe("de");
});
});
@@ -0,0 +1,108 @@
import type { BrandTokens } from "@hivegrid/brand";
import { defaultLocale, normalizeLocaleCandidate } from "@hivegrid/i18n";
import type { MailFooterCopy, MailLanguage } from "./_layout/Footer.js";
import type { MailBrand } from "./_layout/theme.js";
import { buildBrand, renderTransactionalEmail, type RenderedReactEmail } from "./render.js";
import type { SystemMessageEmailProps } from "./transactional/SystemMessage.js";
const localizedFooterCopy = {
de: {
privacyLabel: "Datenschutz",
termsLabel: "AGB",
imprintLabel: "Impressum",
unsubscribeLabel: "Abmelden",
supportBefore: "Du hast Fragen? Dann",
supportLinkLabel: "schreib uns gerne",
supportAfter: ".",
signoffClosing: "Viele Grüße",
signoffTeam: "Dein HiveGrid-Team",
},
en: {
privacyLabel: "Privacy",
termsLabel: "Terms",
imprintLabel: "Imprint",
unsubscribeLabel: "Unsubscribe",
supportBefore: "Questions? Feel free to",
supportLinkLabel: "email us",
supportAfter: ".",
signoffClosing: "Kind regards,",
signoffTeam: "Your HiveGrid team",
},
pl: {
privacyLabel: "Polityka prywatności",
termsLabel: "Regulamin",
imprintLabel: "Nota prawna",
unsubscribeLabel: "Zrezygnuj z subskrypcji",
supportBefore: "Masz pytania?",
supportLinkLabel: "Napisz do nas",
supportAfter: ".",
signoffClosing: "Pozdrawiamy,",
signoffTeam: "Zespół HiveGrid",
},
ru: {
privacyLabel: "Конфиденциальность",
termsLabel: "Условия",
imprintLabel: "Правовая информация",
unsubscribeLabel: "Отписаться",
supportBefore: "Есть вопросы?",
supportLinkLabel: "Напишите нам",
supportAfter: ".",
signoffClosing: "С наилучшими пожеланиями,",
signoffTeam: "Команда HiveGrid",
},
uk: {
privacyLabel: "Конфіденційність",
termsLabel: "Умови",
imprintLabel: "Правова інформація",
unsubscribeLabel: "Відписатися",
supportBefore: "Є запитання?",
supportLinkLabel: "Напишіть нам",
supportAfter: ".",
signoffClosing: "З найкращими побажаннями,",
signoffTeam: "Команда HiveGrid",
},
hu: {
privacyLabel: "Adatvédelem",
termsLabel: "ÁSZF",
imprintLabel: "Impresszum",
unsubscribeLabel: "Leiratkozás",
supportBefore: "Kérdésed van?",
supportLinkLabel: "Írj nekünk",
supportAfter: ".",
signoffClosing: "Üdvözlettel,",
signoffTeam: "A HiveGrid csapata",
},
} as const satisfies Record<MailLanguage, MailFooterCopy>;
export function resolveSystemMailChrome(locale?: string | null): {
readonly language: MailLanguage;
readonly footerCopy: MailFooterCopy;
} {
const language = normalizeLocaleCandidate(locale) ?? defaultLocale;
const base = localizedFooterCopy[language];
const formalGerman = locale?.trim().toLowerCase().startsWith("de-formal");
return {
language,
footerCopy: formalGerman ? { ...base, signoffTeam: "Ihr HiveGrid-Team" } : base,
};
}
export type RenderSystemMessageInput = Omit<SystemMessageEmailProps, "brand" | "language" | "footerCopy"> & {
readonly brand?: Partial<MailBrand> | BrandTokens;
readonly locale?: string | null;
};
/**
* Canonical renderer for fixed runtime messages which do not have a dedicated
* React template. It gives worker and web call-sites the same platform chrome,
* legal links, safe CTA validation and complete plain-text alternative.
*/
export function renderSystemMessageEmail(input: RenderSystemMessageInput): RenderedReactEmail {
const { brand, locale, ...copy } = input;
return renderTransactionalEmail("system-message", {
...copy,
brand: buildBrand(brand),
...resolveSystemMailChrome(locale),
});
}
@@ -18,7 +18,7 @@ describe("InvitationEmail", () => {
expect(result.text).toMatchSnapshot("text");
});
test("uses tenant brand for invite (logo + color)", () => {
test("uses tenant copy and color while keeping the HiveGrid platform logo", () => {
const brand = withBrandDefaults({
productName: "Acme",
logoUrl: "https://cdn.acme.test/logo.png",
@@ -26,17 +26,13 @@ describe("InvitationEmail", () => {
tenantName: "Acme Inc",
});
const { html } = renderReactEmail(
<InvitationEmail
brand={brand}
senderName="Grace"
senderOrganization="Acme Inc"
actionUrl="https://app.acme.test/invite/abc"
/>
<InvitationEmail brand={brand} senderName="Grace" senderOrganization="Acme Inc" actionUrl="https://app.acme.test/invite/abc" />
);
expect(html).toContain("Grace invited you to Acme");
expect(html).toContain("Join Acme Inc");
expect(html).toContain("#ff5500");
expect(html).toContain("https://cdn.acme.test/logo.png");
expect(html).toContain("https://hivegrid.de/hivegrid-logo.png");
expect(html).not.toContain("https://cdn.acme.test/logo.png");
});
test("escapes user-supplied sender/org names", () => {
@@ -1,4 +1,4 @@
import { TransactionalScaffold } from "./shared.js";
import { TransactionalScaffold, type TransactionalChromeProps } from "./shared.js";
import type { MailBrand } from "../_layout/theme.js";
/**
@@ -6,7 +6,7 @@ import type { MailBrand } from "../_layout/theme.js";
* Uses tenant brand overrides (logo/primary-color) so the invite
* reflects the inviting org, not the platform default.
*/
export interface InvitationEmailProps {
export interface InvitationEmailProps extends TransactionalChromeProps {
readonly brand: MailBrand;
readonly recipientName?: string;
readonly senderName: string;
@@ -34,6 +34,8 @@ export function InvitationEmail({
actionLabel,
unsubscribeUrl,
signoffThanks,
language,
footerCopy,
}: InvitationEmailProps) {
const resolvedSubject = subject ?? `${senderName} invited you to ${brand.productName}`;
const resolvedTitle = title ?? (recipientName ? `Hello, ${recipientName}!` : "Hello!");
@@ -49,6 +51,8 @@ export function InvitationEmail({
actionLabel={actionLabel ?? `Join ${senderOrganization}`}
unsubscribeUrl={unsubscribeUrl}
signoffThanks={signoffThanks}
language={language}
footerCopy={footerCopy}
/>
);
}
@@ -1,4 +1,4 @@
import { TransactionalScaffold } from "./shared.js";
import { TransactionalScaffold, type TransactionalChromeProps } from "./shared.js";
import { InfoBox } from "../_layout/InfoBox.js";
import type { MailBrand } from "../_layout/theme.js";
@@ -7,7 +7,7 @@ import type { MailBrand } from "../_layout/theme.js";
* has been issued. CTA points to the hosted-invoice URL so the user
* can download the PDF without authenticating.
*/
export interface InvoiceSentEmailProps {
export interface InvoiceSentEmailProps extends TransactionalChromeProps {
readonly brand: MailBrand;
readonly recipientName?: string;
readonly invoiceNumber: string;
@@ -46,6 +46,8 @@ export function InvoiceSentEmail({
actionLabel,
fieldLabels,
signoffThanks,
language,
footerCopy,
}: InvoiceSentEmailProps) {
const resolvedSubject = subject ?? `Invoice ${invoiceNumber} from ${brand.productName}`;
const resolvedTitle = titleText ?? (recipientName ? `Hello, ${recipientName}!` : "Your invoice is ready");
@@ -61,6 +63,8 @@ export function InvoiceSentEmail({
actionLabel={actionLabel ?? "View invoice PDF"}
unsubscribeUrl={unsubscribeUrl}
signoffThanks={signoffThanks}
language={language}
footerCopy={footerCopy}
>
<InfoBox brand={brand}>
<strong>{fieldLabels?.invoiceNumber ?? "Invoice number:"}</strong> {invoiceNumber}
@@ -79,13 +79,7 @@ describe("TenantNotificationEmail", () => {
});
test("falls back to support mailto when actionUrl missing", () => {
const { html } = renderReactEmail(
<TenantNotificationEmail
brand={defaultMailBrand}
title="Weekly digest"
body="You have 3 unread notifications."
/>
);
const { html } = renderReactEmail(<TenantNotificationEmail brand={defaultMailBrand} title="Weekly digest" body="You have 3 unread notifications." />);
expect(html).toContain(`mailto:${defaultMailBrand.supportEmail}`);
expect(html).toContain("Contact support");
});
@@ -113,13 +107,7 @@ describe("TenantNotificationEmail", () => {
});
test("escapes html-like content in body", () => {
const { html } = renderReactEmail(
<TenantNotificationEmail
brand={defaultMailBrand}
title="Heads up"
body="<script>alert(1)</script> and <b>bold</b>"
/>
);
const { html } = renderReactEmail(<TenantNotificationEmail brand={defaultMailBrand} title="Heads up" body="<script>alert(1)</script> and <b>bold</b>" />);
expect(html).not.toContain("<script>alert(1)</script>");
expect(html).toContain("&lt;script&gt;");
});
@@ -6,23 +6,17 @@ import { MagicLinkEmail } from "./MagicLink.js";
describe("MagicLinkEmail", () => {
test("renders default snapshot", () => {
const result = renderReactEmail(
<MagicLinkEmail brand={defaultMailBrand} recipientName="Ada" actionUrl="https://app.example.com/magic/abc" />
);
const result = renderReactEmail(<MagicLinkEmail brand={defaultMailBrand} recipientName="Ada" actionUrl="https://app.example.com/magic/abc" />);
expect(result.html).toMatchSnapshot("html");
expect(result.text).toMatchSnapshot("text");
});
test("emits expiry InfoBox copy", () => {
const { html } = renderReactEmail(
<MagicLinkEmail brand={defaultMailBrand} actionUrl="https://app.example.com/magic/abc" expiresInMinutes={10} />
);
const { html } = renderReactEmail(<MagicLinkEmail brand={defaultMailBrand} actionUrl="https://app.example.com/magic/abc" expiresInMinutes={10} />);
expect(html).toContain("expires in 10 minutes");
});
test("rejects javascript: action URL", () => {
expect(() =>
renderReactEmail(<MagicLinkEmail brand={defaultMailBrand} actionUrl="javascript:alert(1)" />)
).toThrow(InvalidActionUrlError);
expect(() => renderReactEmail(<MagicLinkEmail brand={defaultMailBrand} actionUrl="javascript:alert(1)" />)).toThrow(InvalidActionUrlError);
});
});
@@ -1,4 +1,4 @@
import { TransactionalScaffold } from "./shared.js";
import { TransactionalScaffold, type TransactionalChromeProps } from "./shared.js";
import { InfoBox } from "../_layout/InfoBox.js";
import type { MailBrand } from "../_layout/theme.js";
@@ -6,7 +6,7 @@ import type { MailBrand } from "../_layout/theme.js";
* MagicLink email — passwordless sign-in flow.
* Includes a short expiry-warning InfoBox plus the standard CTA.
*/
export interface MagicLinkEmailProps {
export interface MagicLinkEmailProps extends TransactionalChromeProps {
readonly brand: MailBrand;
readonly recipientName?: string;
readonly actionUrl: string;
@@ -38,6 +38,8 @@ export function MagicLinkEmail({
expiresText,
unsubscribeUrl,
signoffThanks,
language,
footerCopy,
}: MagicLinkEmailProps) {
const resolvedSubject = subject ?? `Your sign-in link for ${brand.productName}`;
const resolvedTitle = title ?? (recipientName ? `Hello, ${recipientName}!` : "Hello!");
@@ -54,6 +56,8 @@ export function MagicLinkEmail({
outro={outro ?? "If you didn't request this email, you can safely ignore it."}
unsubscribeUrl={unsubscribeUrl}
signoffThanks={signoffThanks}
language={language}
footerCopy={footerCopy}
>
<InfoBox brand={brand} tone="warning">
{expiresText ?? `This link expires in ${expiresInMinutes} minutes and can only be used once.`}
@@ -6,23 +6,19 @@ import { PasswordResetEmail } from "./PasswordReset.js";
describe("PasswordResetEmail", () => {
test("renders default snapshot", () => {
const result = renderReactEmail(
<PasswordResetEmail brand={defaultMailBrand} recipientName="Ada" actionUrl="https://app.example.com/reset?t=abc" />
);
const result = renderReactEmail(<PasswordResetEmail brand={defaultMailBrand} recipientName="Ada" actionUrl="https://app.example.com/reset?t=abc" />);
expect(result.html).toMatchSnapshot("html");
expect(result.text).toMatchSnapshot("text");
});
test("includes the ignore-if-not-requested outro", () => {
const { html } = renderReactEmail(
<PasswordResetEmail brand={defaultMailBrand} actionUrl="https://app.example.com/reset?t=abc" />
);
const { html } = renderReactEmail(<PasswordResetEmail brand={defaultMailBrand} actionUrl="https://app.example.com/reset?t=abc" />);
expect(html).toContain("If you did not request a password reset");
});
test("rejects http://", () => {
expect(() =>
renderReactEmail(<PasswordResetEmail brand={defaultMailBrand} actionUrl="http://insecure.example.com/reset" />)
).toThrow(InvalidActionUrlError);
expect(() => renderReactEmail(<PasswordResetEmail brand={defaultMailBrand} actionUrl="http://insecure.example.com/reset" />)).toThrow(
InvalidActionUrlError
);
});
});
@@ -1,4 +1,4 @@
import { TransactionalScaffold } from "./shared.js";
import { TransactionalScaffold, type TransactionalChromeProps } from "./shared.js";
import type { MailBrand } from "../_layout/theme.js";
/**
@@ -6,7 +6,7 @@ import type { MailBrand } from "../_layout/theme.js";
* The outro reminds the recipient to ignore the message if they did
* not request a reset.
*/
export interface PasswordResetEmailProps {
export interface PasswordResetEmailProps extends TransactionalChromeProps {
readonly brand: MailBrand;
readonly recipientName?: string;
readonly actionUrl: string;
@@ -32,6 +32,8 @@ export function PasswordResetEmail({
outro,
unsubscribeUrl,
signoffThanks,
language,
footerCopy,
}: PasswordResetEmailProps) {
const resolvedSubject = subject ?? `Set up a new password for ${brand.productName}`;
const resolvedTitle = title ?? (recipientName ? `Hello, ${recipientName}!` : "Hello!");
@@ -48,6 +50,8 @@ export function PasswordResetEmail({
outro={outro ?? "If you did not request a password reset, please ignore this email or contact support if you have questions."}
unsubscribeUrl={unsubscribeUrl}
signoffThanks={signoffThanks}
language={language}
footerCopy={footerCopy}
/>
);
}
@@ -22,12 +22,7 @@ describe("SubscriptionSuccessEmail", () => {
test("omits next-billing row when undefined", () => {
const { html } = renderReactEmail(
<SubscriptionSuccessEmail
brand={defaultMailBrand}
planName="Pro"
amountFormatted="$29.00"
actionUrl="https://app.example.com/billing"
/>
<SubscriptionSuccessEmail brand={defaultMailBrand} planName="Pro" amountFormatted="$29.00" actionUrl="https://app.example.com/billing" />
);
expect(html).not.toContain("Next billing:");
});
@@ -78,14 +73,9 @@ describe("SubscriptionFailedEmail", () => {
test("uses warning-tone InfoBox", () => {
const { html } = renderReactEmail(
<SubscriptionFailedEmail
brand={defaultMailBrand}
planName="Pro"
amountFormatted="$29.00"
actionUrl="https://app.example.com/billing"
/>
<SubscriptionFailedEmail brand={defaultMailBrand} planName="Pro" amountFormatted="$29.00" actionUrl="https://app.example.com/billing" />
);
expect(html).toMatch(/#fef3c7/i);
expect(html).toMatch(/#fff8df/i);
});
test("accepts localized failure copy overrides", () => {
@@ -1,4 +1,4 @@
import { TransactionalScaffold } from "./shared.js";
import { TransactionalScaffold, type TransactionalChromeProps } from "./shared.js";
import { InfoBox } from "../_layout/InfoBox.js";
import type { MailBrand } from "../_layout/theme.js";
@@ -7,7 +7,7 @@ import type { MailBrand } from "../_layout/theme.js";
* webhook. Surfaces the failure reason and a direct CTA to the
* billing portal so the customer can fix the card before dunning.
*/
export interface SubscriptionFailedEmailProps {
export interface SubscriptionFailedEmailProps extends TransactionalChromeProps {
readonly brand: MailBrand;
readonly recipientName?: string;
readonly planName: string;
@@ -46,6 +46,8 @@ export function SubscriptionFailedEmail({
actionLabel,
fieldLabels,
signoffThanks,
language,
footerCopy,
}: SubscriptionFailedEmailProps) {
const resolvedSubject = subject ?? `Action required: payment failed for ${brand.productName}`;
const resolvedTitle = title ?? (recipientName ? `Hi ${recipientName},` : "We couldn't charge your card");
@@ -62,6 +64,8 @@ export function SubscriptionFailedEmail({
actionLabel={actionLabel ?? "Update payment method"}
unsubscribeUrl={unsubscribeUrl}
signoffThanks={signoffThanks}
language={language}
footerCopy={footerCopy}
>
<InfoBox brand={brand} tone="warning">
<strong>{fieldLabels?.plan ?? "Plan:"}</strong> {planName}
@@ -1,4 +1,4 @@
import { TransactionalScaffold } from "./shared.js";
import { TransactionalScaffold, type TransactionalChromeProps } from "./shared.js";
import { InfoBox } from "../_layout/InfoBox.js";
import type { MailBrand } from "../_layout/theme.js";
@@ -8,7 +8,7 @@ import type { MailBrand } from "../_layout/theme.js";
* verify they were charged correctly without opening the billing
* portal.
*/
export interface SubscriptionSuccessEmailProps {
export interface SubscriptionSuccessEmailProps extends TransactionalChromeProps {
readonly brand: MailBrand;
readonly recipientName?: string;
readonly planName: string;
@@ -44,6 +44,8 @@ export function SubscriptionSuccessEmail({
actionLabel,
fieldLabels,
signoffThanks,
language,
footerCopy,
}: SubscriptionSuccessEmailProps) {
const resolvedSubject = subject ?? `Your ${brand.productName} subscription is active`;
const resolvedTitle = title ?? (recipientName ? `Thanks, ${recipientName}!` : "Thanks for subscribing!");
@@ -59,6 +61,8 @@ export function SubscriptionSuccessEmail({
actionLabel={actionLabel ?? "Open your dashboard"}
unsubscribeUrl={unsubscribeUrl}
signoffThanks={signoffThanks}
language={language}
footerCopy={footerCopy}
>
<InfoBox brand={brand}>
<strong>{fieldLabels?.plan ?? "Plan:"}</strong> {planName}
@@ -0,0 +1,104 @@
import type { CSSProperties } from "react";
import { InfoBox } from "../_layout/InfoBox.js";
import type { MailBrand } from "../_layout/theme.js";
import { TransactionalScaffold, type TransactionalChromeProps } from "./shared.js";
export type SystemMessageDetail = {
readonly label: string;
readonly value: string;
};
export interface SystemMessageEmailProps extends TransactionalChromeProps {
readonly brand: MailBrand;
readonly subject: string;
readonly previewText?: string;
readonly eyebrow: string;
readonly title: string;
readonly intro: string;
readonly actionUrl?: string;
readonly actionLabel?: string;
readonly details?: readonly SystemMessageDetail[];
readonly notice?: string;
readonly noticeTone?: "info" | "warning";
readonly outro?: string;
readonly unsubscribeUrl?: string;
readonly signoffThanks?: string;
}
const detailTableStyle: CSSProperties = {
borderCollapse: "separate",
borderSpacing: "0 8px",
marginTop: "20px",
width: "100%",
};
const labelStyle: CSSProperties = {
color: "#655f59",
fontSize: "13px",
padding: "11px 14px 3px",
};
const valueStyle: CSSProperties = {
color: "#231f20",
fontSize: "15px",
fontWeight: 700,
padding: "3px 14px 11px",
};
export function SystemMessageEmail({
brand,
subject,
previewText,
eyebrow,
title,
intro,
actionUrl,
actionLabel,
details,
notice,
noticeTone,
outro,
unsubscribeUrl,
signoffThanks,
language,
footerCopy,
}: SystemMessageEmailProps) {
return (
<TransactionalScaffold
brand={brand}
subject={subject}
previewText={previewText}
eyebrow={eyebrow}
title={title}
intro={intro}
actionUrl={actionUrl}
actionLabel={actionLabel}
outro={outro}
unsubscribeUrl={unsubscribeUrl}
signoffThanks={signoffThanks}
language={language}
footerCopy={footerCopy}
>
{details?.length ? (
<table style={detailTableStyle} role="presentation">
<tbody>
{details.map((detail) => (
<tr key={`${detail.label}:${detail.value}`}>
<td style={{ backgroundColor: "#f8f6f2", border: `1px solid ${brand.borderColor}`, borderRadius: "10px", padding: 0 }}>
<div style={labelStyle}>{detail.label}</div>
<div style={valueStyle}>{detail.value}</div>
</td>
</tr>
))}
</tbody>
</table>
) : null}
{notice ? (
<InfoBox brand={brand} tone={noticeTone}>
{notice}
</InfoBox>
) : null}
</TransactionalScaffold>
);
}
@@ -1,4 +1,4 @@
import { TransactionalScaffold } from "./shared.js";
import { TransactionalScaffold, type TransactionalChromeProps } from "./shared.js";
import type { MailBrand } from "../_layout/theme.js";
/**
@@ -7,7 +7,7 @@ import type { MailBrand } from "../_layout/theme.js";
* plain text (React's default escaping handles XSS); raw HTML is
* intentionally not supported.
*/
export interface TenantNotificationEmailProps {
export interface TenantNotificationEmailProps extends TransactionalChromeProps {
readonly brand: MailBrand;
readonly recipientName?: string;
readonly title: string;
@@ -35,6 +35,8 @@ export function TenantNotificationEmail({
defaultActionLabel,
supportActionLabel,
signoffThanks,
language,
footerCopy,
}: TenantNotificationEmailProps) {
const subject = title;
const resolvedHeadline = headline ?? (recipientName ? `Hello, ${recipientName}!` : title);
@@ -54,6 +56,8 @@ export function TenantNotificationEmail({
actionLabel={resolvedActionLabel}
unsubscribeUrl={unsubscribeUrl}
signoffThanks={signoffThanks}
language={language}
footerCopy={footerCopy}
/>
);
}
@@ -6,29 +6,24 @@ import { WelcomeEmail } from "./Welcome.js";
describe("WelcomeEmail", () => {
test("renders default-brand named welcome (snapshot)", () => {
const result = renderReactEmail(
<WelcomeEmail brand={defaultMailBrand} recipientName="Ada" actionUrl="https://app.example.com/login" />
);
const result = renderReactEmail(<WelcomeEmail brand={defaultMailBrand} recipientName="Ada" actionUrl="https://app.example.com/login" />);
expect(result.html).toMatchSnapshot("html");
expect(result.text).toMatchSnapshot("text");
});
test("falls back to anonymous greeting when name missing", () => {
const { html } = renderReactEmail(
<WelcomeEmail brand={defaultMailBrand} actionUrl="https://app.example.com/login" />
);
const { html } = renderReactEmail(<WelcomeEmail brand={defaultMailBrand} actionUrl="https://app.example.com/login" />);
expect(html).toContain("Welcome!");
expect(html).not.toContain("Welcome, ");
});
test("applies tenant brand overrides", () => {
test("applies safe tenant copy and color overrides without replacing the HiveGrid logo", () => {
const brand = withBrandDefaults({ productName: "Acme", primaryColor: "#123456", logoUrl: "https://cdn.acme.test/l.png" });
const { html } = renderReactEmail(
<WelcomeEmail brand={brand} recipientName="Ada" actionUrl="https://app.acme.test/login" />
);
const { html } = renderReactEmail(<WelcomeEmail brand={brand} recipientName="Ada" actionUrl="https://app.acme.test/login" />);
expect(html).toContain("Welcome to Acme, Ada!");
expect(html).toContain("#123456");
expect(html).toContain("https://cdn.acme.test/l.png");
expect(html).toContain("https://hivegrid.de/hivegrid-logo.png");
expect(html).not.toContain("https://cdn.acme.test/l.png");
});
test("escapes user content via React (XSS-safe)", () => {
@@ -40,8 +35,6 @@ describe("WelcomeEmail", () => {
});
test("rejects insecure action URLs", () => {
expect(() =>
renderReactEmail(<WelcomeEmail brand={defaultMailBrand} actionUrl="javascript:alert(1)" />)
).toThrow(InvalidActionUrlError);
expect(() => renderReactEmail(<WelcomeEmail brand={defaultMailBrand} actionUrl="javascript:alert(1)" />)).toThrow(InvalidActionUrlError);
});
});
@@ -1,12 +1,13 @@
import { TransactionalScaffold } from "./shared.js";
import { TransactionalScaffold, type TransactionalChromeProps } from "./shared.js";
import type { MailBrand } from "../_layout/theme.js";
/**
* Welcome transactional email — sent after account activation. Also
* Welcome transactional email — sent after account creation. The caller's
* copy must keep plan, payment and activation state explicit. It also
* doubles as the post-checkout "account-setup" variant via overridable
* subject/title/intro/actionLabel props (see EmailTemplates wrapper).
*/
export interface WelcomeEmailProps {
export interface WelcomeEmailProps extends TransactionalChromeProps {
readonly brand: MailBrand;
readonly recipientName?: string;
readonly actionUrl: string;
@@ -30,9 +31,10 @@ export function WelcomeEmail({
actionLabel,
unsubscribeUrl,
signoffThanks,
language,
footerCopy,
}: WelcomeEmailProps) {
const resolvedSubject =
subject ?? (recipientName ? `Welcome to ${brand.productName}, ${recipientName}!` : `Welcome to ${brand.productName}!`);
const resolvedSubject = subject ?? (recipientName ? `Welcome to ${brand.productName}, ${recipientName}!` : `Welcome to ${brand.productName}!`);
const resolvedTitle = title ?? (recipientName ? `Welcome, ${recipientName}!` : "Welcome!");
const resolvedIntro = intro ?? `Thanks for trying ${brand.productName}.`;
return (
@@ -46,6 +48,8 @@ export function WelcomeEmail({
actionLabel={actionLabel ?? "Click here to log in"}
unsubscribeUrl={unsubscribeUrl}
signoffThanks={signoffThanks}
language={language}
footerCopy={footerCopy}
/>
);
}
@@ -1,16 +1,18 @@
// 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 HiveGrid</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, &#x27;Segoe UI&#x27;, Roboto, &#x27;Helvetica Neue&#x27;, 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 > html 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://hivegrid.de/hivegrid-logo.png"/><title>Grace invited you to HiveGrid</title></head><body style="margin:0;padding:0;background-color:#f7f5f1;color:#231f20;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, &#x27;Segoe UI&#x27;, Roboto, &#x27;Helvetica Neue&#x27;, 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:32px 14px"><div style="background-color:#ffffff;border:1px solid #e7e1d8;border-radius:22px;box-shadow:0 16px 48px rgba(35, 31, 32, 0.08);overflow:hidden"><div style="background-color:#f1b729;height:7px;line-height:7px"> </div><div style="padding:34px 34px 30px"><div style="padding-bottom:24px;text-align:left"><a href="https://hivegrid.de" style="color:#231f20;text-decoration:none" target="_blank" rel="noopener noreferrer"><span style="display:inline-block;vertical-align:middle"><img src="https://hivegrid.de/hivegrid-logo.png" alt="HiveGrid" width="42" height="36" style="display:block;border:0"/></span><strong style="color:#231f20;display:inline-block;font-size:22px;letter-spacing:-0.03em;margin-left:10px;vertical-align:middle">HiveGrid</strong></a></div><div style="color:#735400;font-size:12px;font-weight:700;letter-spacing:0.1em;text-transform:uppercase;margin-bottom:8px">Invitation</div><h1 style="margin:8px 0 18px;font-size:30px;line-height:1.16;color:#231f20;font-weight:700">Hello, Ada!</h1><p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#231f20">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:#f1b729;color:#231f20;padding:13px 20px;border:1px solid #f1b729;border-radius:10px;font-weight:700;font-size:16px;line-height:1.25;text-decoration:none" target="_blank" rel="noopener noreferrer">Join Example Org <span aria-hidden="true">→</span></a><p style="margin:24px 0 0;font-size:14px;line-height:1.6;color:#231f20">Kind regards,<br/><strong>HiveGrid-Team</strong></p><div style="margin-top:32px;padding-top:20px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e7e1d8;color:#655f59"><div style="color:#231f20;font-size:13px;font-weight:700;margin-bottom:10px">HiveGrid</div><div><a href="https://hivegrid.de/datenschutz" style="text-decoration:underline;color:#735400">Privacy</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/agb" style="text-decoration:underline;color:#735400">Terms</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/impressum" style="text-decoration:underline;color:#735400">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:support@hivegrid.de" style="text-decoration:underline;color:#735400">support@hivegrid.de</a>.</div><div style="margin-top:10px">© HiveGrid</div></div></div></div></div></body></html>"`;
exports[`InvitationEmail > renders default snapshot > text 1`] = `
"Grace invited you to HiveGrid
HiveGrid
 
HiveGrid (https://hivegrid.de)
Invitation
Hello, Ada!
Grace with Example Org has invited you to use HiveGrid to collaborate with them.
Join Example Org (https://app.example.com/invite/abc)Thanks,
-
HiveGrid Support
Join Example Org → (https://app.example.com/invite/abc)Kind regards,
HiveGrid-Team
HiveGrid
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)."
Questions? Email us at support@hivegrid.de (mailto:support@hivegrid.de).
© HiveGrid"
`;
@@ -1,35 +1,39 @@
// 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 HiveGrid</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, &#x27;Segoe UI&#x27;, Roboto, &#x27;Helvetica Neue&#x27;, 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 > html 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://hivegrid.de/hivegrid-logo.png"/><title>Invoice INV-2026-0001 from HiveGrid</title></head><body style="margin:0;padding:0;background-color:#f7f5f1;color:#231f20;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, &#x27;Segoe UI&#x27;, Roboto, &#x27;Helvetica Neue&#x27;, 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:32px 14px"><div style="background-color:#ffffff;border:1px solid #e7e1d8;border-radius:22px;box-shadow:0 16px 48px rgba(35, 31, 32, 0.08);overflow:hidden"><div style="background-color:#f1b729;height:7px;line-height:7px"> </div><div style="padding:34px 34px 30px"><div style="padding-bottom:24px;text-align:left"><a href="https://hivegrid.de" style="color:#231f20;text-decoration:none" target="_blank" rel="noopener noreferrer"><span style="display:inline-block;vertical-align:middle"><img src="https://hivegrid.de/hivegrid-logo.png" alt="HiveGrid" width="42" height="36" style="display:block;border:0"/></span><strong style="color:#231f20;display:inline-block;font-size:22px;letter-spacing:-0.03em;margin-left:10px;vertical-align:middle">HiveGrid</strong></a></div><div style="color:#735400;font-size:12px;font-weight:700;letter-spacing:0.1em;text-transform:uppercase;margin-bottom:8px">Invoice</div><h1 style="margin:8px 0 18px;font-size:30px;line-height:1.16;color:#231f20;font-weight:700">Hello, Ada!</h1><p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#231f20">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:#f1b729;color:#231f20;padding:13px 20px;border:1px solid #f1b729;border-radius:10px;font-weight:700;font-size:16px;line-height:1.25;text-decoration:none" target="_blank" rel="noopener noreferrer">View invoice PDF <span aria-hidden="true">→</span></a><div style="margin-top:24px;padding:16px 18px;border-radius:12px;font-size:14px;line-height:1.55;background-color:#f8f6f2;color:#231f20;border:1px solid #e7e1d8"><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:#231f20">Kind regards,<br/><strong>HiveGrid-Team</strong></p><div style="margin-top:32px;padding-top:20px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e7e1d8;color:#655f59"><div style="color:#231f20;font-size:13px;font-weight:700;margin-bottom:10px">HiveGrid</div><div><a href="https://hivegrid.de/datenschutz" style="text-decoration:underline;color:#735400">Privacy</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/agb" style="text-decoration:underline;color:#735400">Terms</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/impressum" style="text-decoration:underline;color:#735400">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:support@hivegrid.de" style="text-decoration:underline;color:#735400">support@hivegrid.de</a>.</div><div style="margin-top:10px">© HiveGrid</div></div></div></div></div></body></html>"`;
exports[`InvoiceSentEmail > renders default snapshot with due date > text 1`] = `
"Invoice INV-2026-0001 from HiveGrid
HiveGrid
 
HiveGrid (https://hivegrid.de)
Invoice
Hello, Ada!
Your invoice INV-2026-0001 for €99.00 is now available.
View invoice PDF (https://billing.hivegrid.test/invoices/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,
-
HiveGrid Support
Kind regards,
HiveGrid-Team
HiveGrid
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)."
Questions? Email us at support@hivegrid.de (mailto:support@hivegrid.de).
© HiveGrid"
`;
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, &#x27;Segoe UI&#x27;, Roboto, &#x27;Helvetica Neue&#x27;, 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 > html 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://hivegrid.de/hivegrid-logo.png"/><title>New comment on Ticket #42</title></head><body style="margin:0;padding:0;background-color:#f7f5f1;color:#231f20;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, &#x27;Segoe UI&#x27;, Roboto, &#x27;Helvetica Neue&#x27;, 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:32px 14px"><div style="background-color:#ffffff;border:1px solid #e7e1d8;border-radius:22px;box-shadow:0 16px 48px rgba(35, 31, 32, 0.08);overflow:hidden"><div style="background-color:#f1b729;height:7px;line-height:7px"> </div><div style="padding:34px 34px 30px"><div style="padding-bottom:24px;text-align:left"><a href="https://hivegrid.de" style="color:#231f20;text-decoration:none" target="_blank" rel="noopener noreferrer"><span style="display:inline-block;vertical-align:middle"><img src="https://hivegrid.de/hivegrid-logo.png" alt="HiveGrid" width="42" height="36" style="display:block;border:0"/></span><strong style="color:#231f20;display:inline-block;font-size:22px;letter-spacing:-0.03em;margin-left:10px;vertical-align:middle">HiveGrid</strong></a></div><div style="color:#735400;font-size:12px;font-weight:700;letter-spacing:0.1em;text-transform:uppercase;margin-bottom:8px">Notification</div><h1 style="margin:8px 0 18px;font-size:30px;line-height:1.16;color:#231f20;font-weight:700">Hello, Ada!</h1><p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#231f20">Grace mentioned you in a comment on Ticket #42.</p><a href="https://app.example.com/tickets/42" style="display:inline-block;background-color:#f1b729;color:#231f20;padding:13px 20px;border:1px solid #f1b729;border-radius:10px;font-weight:700;font-size:16px;line-height:1.25;text-decoration:none" target="_blank" rel="noopener noreferrer">View ticket <span aria-hidden="true">→</span></a><p style="margin:24px 0 0;font-size:14px;line-height:1.6;color:#231f20">Kind regards,<br/><strong>HiveGrid-Team</strong></p><div style="margin-top:32px;padding-top:20px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e7e1d8;color:#655f59"><div style="color:#231f20;font-size:13px;font-weight:700;margin-bottom:10px">HiveGrid</div><div><a href="https://hivegrid.de/datenschutz" style="text-decoration:underline;color:#735400">Privacy</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/agb" style="text-decoration:underline;color:#735400">Terms</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/impressum" style="text-decoration:underline;color:#735400">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:support@hivegrid.de" style="text-decoration:underline;color:#735400">support@hivegrid.de</a>.</div><div style="margin-top:10px">© HiveGrid</div></div></div></div></div></body></html>"`;
exports[`TenantNotificationEmail > renders default snapshot with action > text 1`] = `
"New comment on Ticket #42
HiveGrid
 
HiveGrid (https://hivegrid.de)
Notification
Hello, Ada!
Grace mentioned you in a comment on Ticket #42.
View ticket (https://app.example.com/tickets/42)Thanks,
-
HiveGrid Support
View ticket → (https://app.example.com/tickets/42)Kind regards,
HiveGrid-Team
HiveGrid
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)."
Questions? Email us at support@hivegrid.de (mailto:support@hivegrid.de).
© HiveGrid"
`;
@@ -1,18 +1,20 @@
// 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 HiveGrid</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, &#x27;Segoe UI&#x27;, Roboto, &#x27;Helvetica Neue&#x27;, 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&#x27;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 > html 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://hivegrid.de/hivegrid-logo.png"/><title>Your sign-in link for HiveGrid</title></head><body style="margin:0;padding:0;background-color:#f7f5f1;color:#231f20;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, &#x27;Segoe UI&#x27;, Roboto, &#x27;Helvetica Neue&#x27;, 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:32px 14px"><div style="background-color:#ffffff;border:1px solid #e7e1d8;border-radius:22px;box-shadow:0 16px 48px rgba(35, 31, 32, 0.08);overflow:hidden"><div style="background-color:#f1b729;height:7px;line-height:7px"> </div><div style="padding:34px 34px 30px"><div style="padding-bottom:24px;text-align:left"><a href="https://hivegrid.de" style="color:#231f20;text-decoration:none" target="_blank" rel="noopener noreferrer"><span style="display:inline-block;vertical-align:middle"><img src="https://hivegrid.de/hivegrid-logo.png" alt="HiveGrid" width="42" height="36" style="display:block;border:0"/></span><strong style="color:#231f20;display:inline-block;font-size:22px;letter-spacing:-0.03em;margin-left:10px;vertical-align:middle">HiveGrid</strong></a></div><div style="color:#735400;font-size:12px;font-weight:700;letter-spacing:0.1em;text-transform:uppercase;margin-bottom:8px">Magic link</div><h1 style="margin:8px 0 18px;font-size:30px;line-height:1.16;color:#231f20;font-weight:700">Hello, Ada!</h1><p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#231f20">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:#f1b729;color:#231f20;padding:13px 20px;border:1px solid #f1b729;border-radius:10px;font-weight:700;font-size:16px;line-height:1.25;text-decoration:none" target="_blank" rel="noopener noreferrer">Sign in <span aria-hidden="true">→</span></a><p style="margin:30px 0 0;font-size:15px;line-height:1.6;color:#655f59">If you didn&#x27;t request this email, you can safely ignore it.</p><div style="margin-top:24px;padding:16px 18px;border-radius:12px;font-size:14px;line-height:1.55;background-color:#fff8df;color:#5f4300;border:1px solid #f0d684">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:#231f20">Kind regards,<br/><strong>HiveGrid-Team</strong></p><div style="margin-top:32px;padding-top:20px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e7e1d8;color:#655f59"><div style="color:#231f20;font-size:13px;font-weight:700;margin-bottom:10px">HiveGrid</div><div><a href="https://hivegrid.de/datenschutz" style="text-decoration:underline;color:#735400">Privacy</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/agb" style="text-decoration:underline;color:#735400">Terms</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/impressum" style="text-decoration:underline;color:#735400">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:support@hivegrid.de" style="text-decoration:underline;color:#735400">support@hivegrid.de</a>.</div><div style="margin-top:10px">© HiveGrid</div></div></div></div></div></body></html>"`;
exports[`MagicLinkEmail > renders default snapshot > text 1`] = `
"Click to sign in to HiveGrid
HiveGrid
 
HiveGrid (https://hivegrid.de)
Magic link
Hello, Ada!
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&#x27;t request this email, you can safely ignore it.
Sign in → (https://app.example.com/magic/abc)If you didn&#x27;t request this email, you can safely ignore it.
This link expires in 15 minutes and can only be used once.
Thanks,
-
HiveGrid Support
Kind regards,
HiveGrid-Team
HiveGrid
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)."
Questions? Email us at support@hivegrid.de (mailto:support@hivegrid.de).
© HiveGrid"
`;
@@ -1,17 +1,19 @@
// 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 HiveGrid</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, &#x27;Segoe UI&#x27;, Roboto, &#x27;Helvetica Neue&#x27;, 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 > html 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://hivegrid.de/hivegrid-logo.png"/><title>Set up a new password for HiveGrid</title></head><body style="margin:0;padding:0;background-color:#f7f5f1;color:#231f20;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, &#x27;Segoe UI&#x27;, Roboto, &#x27;Helvetica Neue&#x27;, 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:32px 14px"><div style="background-color:#ffffff;border:1px solid #e7e1d8;border-radius:22px;box-shadow:0 16px 48px rgba(35, 31, 32, 0.08);overflow:hidden"><div style="background-color:#f1b729;height:7px;line-height:7px"> </div><div style="padding:34px 34px 30px"><div style="padding-bottom:24px;text-align:left"><a href="https://hivegrid.de" style="color:#231f20;text-decoration:none" target="_blank" rel="noopener noreferrer"><span style="display:inline-block;vertical-align:middle"><img src="https://hivegrid.de/hivegrid-logo.png" alt="HiveGrid" width="42" height="36" style="display:block;border:0"/></span><strong style="color:#231f20;display:inline-block;font-size:22px;letter-spacing:-0.03em;margin-left:10px;vertical-align:middle">HiveGrid</strong></a></div><div style="color:#735400;font-size:12px;font-weight:700;letter-spacing:0.1em;text-transform:uppercase;margin-bottom:8px">Password reset</div><h1 style="margin:8px 0 18px;font-size:30px;line-height:1.16;color:#231f20;font-weight:700">Hello, Ada!</h1><p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#231f20">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:#f1b729;color:#231f20;padding:13px 20px;border:1px solid #f1b729;border-radius:10px;font-weight:700;font-size:16px;line-height:1.25;text-decoration:none" target="_blank" rel="noopener noreferrer">Reset password <span aria-hidden="true">→</span></a><p style="margin:30px 0 0;font-size:15px;line-height:1.6;color:#655f59">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:#231f20">Kind regards,<br/><strong>HiveGrid-Team</strong></p><div style="margin-top:32px;padding-top:20px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e7e1d8;color:#655f59"><div style="color:#231f20;font-size:13px;font-weight:700;margin-bottom:10px">HiveGrid</div><div><a href="https://hivegrid.de/datenschutz" style="text-decoration:underline;color:#735400">Privacy</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/agb" style="text-decoration:underline;color:#735400">Terms</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/impressum" style="text-decoration:underline;color:#735400">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:support@hivegrid.de" style="text-decoration:underline;color:#735400">support@hivegrid.de</a>.</div><div style="margin-top:10px">© HiveGrid</div></div></div></div></div></body></html>"`;
exports[`PasswordResetEmail > renders default snapshot > text 1`] = `
"Set up a new password for HiveGrid
HiveGrid
 
HiveGrid (https://hivegrid.de)
Password reset
Hello, Ada!
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,
-
HiveGrid Support
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.
Kind regards,
HiveGrid-Team
HiveGrid
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)."
Questions? Email us at support@hivegrid.de (mailto:support@hivegrid.de).
© HiveGrid"
`;
@@ -1,38 +1,42 @@
// 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 HiveGrid</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, &#x27;Segoe UI&#x27;, Roboto, &#x27;Helvetica Neue&#x27;, 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 > html 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://hivegrid.de/hivegrid-logo.png"/><title>Action required: payment failed for HiveGrid</title></head><body style="margin:0;padding:0;background-color:#f7f5f1;color:#231f20;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, &#x27;Segoe UI&#x27;, Roboto, &#x27;Helvetica Neue&#x27;, 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:32px 14px"><div style="background-color:#ffffff;border:1px solid #e7e1d8;border-radius:22px;box-shadow:0 16px 48px rgba(35, 31, 32, 0.08);overflow:hidden"><div style="background-color:#f1b729;height:7px;line-height:7px"> </div><div style="padding:34px 34px 30px"><div style="padding-bottom:24px;text-align:left"><a href="https://hivegrid.de" style="color:#231f20;text-decoration:none" target="_blank" rel="noopener noreferrer"><span style="display:inline-block;vertical-align:middle"><img src="https://hivegrid.de/hivegrid-logo.png" alt="HiveGrid" width="42" height="36" style="display:block;border:0"/></span><strong style="color:#231f20;display:inline-block;font-size:22px;letter-spacing:-0.03em;margin-left:10px;vertical-align:middle">HiveGrid</strong></a></div><div style="color:#735400;font-size:12px;font-weight:700;letter-spacing:0.1em;text-transform:uppercase;margin-bottom:8px">Payment failed</div><h1 style="margin:8px 0 18px;font-size:30px;line-height:1.16;color:#231f20;font-weight:700">Hi Ada,</h1><p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#231f20">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:#f1b729;color:#231f20;padding:13px 20px;border:1px solid #f1b729;border-radius:10px;font-weight:700;font-size:16px;line-height:1.25;text-decoration:none" target="_blank" rel="noopener noreferrer">Update payment method <span aria-hidden="true">→</span></a><div style="margin-top:24px;padding:16px 18px;border-radius:12px;font-size:14px;line-height:1.55;background-color:#fff8df;color:#5f4300;border:1px solid #f0d684"><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:#231f20">Kind regards,<br/><strong>HiveGrid-Team</strong></p><div style="margin-top:32px;padding-top:20px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e7e1d8;color:#655f59"><div style="color:#231f20;font-size:13px;font-weight:700;margin-bottom:10px">HiveGrid</div><div><a href="https://hivegrid.de/datenschutz" style="text-decoration:underline;color:#735400">Privacy</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/agb" style="text-decoration:underline;color:#735400">Terms</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/impressum" style="text-decoration:underline;color:#735400">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:support@hivegrid.de" style="text-decoration:underline;color:#735400">support@hivegrid.de</a>.</div><div style="margin-top:10px">© HiveGrid</div></div></div></div></div></body></html>"`;
exports[`SubscriptionFailedEmail > renders default snapshot with reason + retry > text 1`] = `
"Action required: payment failed for HiveGrid
HiveGrid
 
HiveGrid (https://hivegrid.de)
Payment failed
Hi Ada,
We were unable to charge your card for the Pro subscription. Please update your payment method to avoid service interruption.
Update payment method (https://app.example.com/billing)Plan: Pro
Update payment method → (https://app.example.com/billing)Plan: Pro
Amount: $29.00
Reason: Card declined
Next retry: 2026-05-20
Thanks,
-
HiveGrid Support
Kind regards,
HiveGrid-Team
HiveGrid
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)."
Questions? Email us at support@hivegrid.de (mailto:support@hivegrid.de).
© HiveGrid"
`;
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, &#x27;Segoe UI&#x27;, Roboto, &#x27;Helvetica Neue&#x27;, 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 > html 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://hivegrid.de/hivegrid-logo.png"/><title>Your HiveGrid subscription is active</title></head><body style="margin:0;padding:0;background-color:#f7f5f1;color:#231f20;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, &#x27;Segoe UI&#x27;, Roboto, &#x27;Helvetica Neue&#x27;, 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:32px 14px"><div style="background-color:#ffffff;border:1px solid #e7e1d8;border-radius:22px;box-shadow:0 16px 48px rgba(35, 31, 32, 0.08);overflow:hidden"><div style="background-color:#f1b729;height:7px;line-height:7px"> </div><div style="padding:34px 34px 30px"><div style="padding-bottom:24px;text-align:left"><a href="https://hivegrid.de" style="color:#231f20;text-decoration:none" target="_blank" rel="noopener noreferrer"><span style="display:inline-block;vertical-align:middle"><img src="https://hivegrid.de/hivegrid-logo.png" alt="HiveGrid" width="42" height="36" style="display:block;border:0"/></span><strong style="color:#231f20;display:inline-block;font-size:22px;letter-spacing:-0.03em;margin-left:10px;vertical-align:middle">HiveGrid</strong></a></div><div style="color:#735400;font-size:12px;font-weight:700;letter-spacing:0.1em;text-transform:uppercase;margin-bottom:8px">Subscription</div><h1 style="margin:8px 0 18px;font-size:30px;line-height:1.16;color:#231f20;font-weight:700">Thanks, Ada!</h1><p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#231f20">Your Pro subscription is now active. Welcome aboard!</p><a href="https://app.example.com/billing" style="display:inline-block;background-color:#f1b729;color:#231f20;padding:13px 20px;border:1px solid #f1b729;border-radius:10px;font-weight:700;font-size:16px;line-height:1.25;text-decoration:none" target="_blank" rel="noopener noreferrer">Open your dashboard <span aria-hidden="true">→</span></a><div style="margin-top:24px;padding:16px 18px;border-radius:12px;font-size:14px;line-height:1.55;background-color:#f8f6f2;color:#231f20;border:1px solid #e7e1d8"><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:#231f20">Kind regards,<br/><strong>HiveGrid-Team</strong></p><div style="margin-top:32px;padding-top:20px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e7e1d8;color:#655f59"><div style="color:#231f20;font-size:13px;font-weight:700;margin-bottom:10px">HiveGrid</div><div><a href="https://hivegrid.de/datenschutz" style="text-decoration:underline;color:#735400">Privacy</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/agb" style="text-decoration:underline;color:#735400">Terms</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/impressum" style="text-decoration:underline;color:#735400">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:support@hivegrid.de" style="text-decoration:underline;color:#735400">support@hivegrid.de</a>.</div><div style="margin-top:10px">© HiveGrid</div></div></div></div></div></body></html>"`;
exports[`SubscriptionSuccessEmail > renders default snapshot with next-billing > text 1`] = `
"Your HiveGrid subscription is active
HiveGrid
 
HiveGrid (https://hivegrid.de)
Subscription
Thanks, Ada!
Your Pro subscription is now active. Welcome aboard!
Open your dashboard (https://app.example.com/billing)Plan: Pro
Open your dashboard → (https://app.example.com/billing)Plan: Pro
Amount: $29.00
Next billing: 2026-06-01
Thanks,
-
HiveGrid Support
Kind regards,
HiveGrid-Team
HiveGrid
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)."
Questions? Email us at support@hivegrid.de (mailto:support@hivegrid.de).
© HiveGrid"
`;
@@ -1,16 +1,18 @@
// 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 HiveGrid, Ada!</title></head><body style="margin:0;padding:0;background-color:#f4f5f7;color:#0f172a;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, &#x27;Segoe UI&#x27;, Roboto, &#x27;Helvetica Neue&#x27;, 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) > html 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://hivegrid.de/hivegrid-logo.png"/><title>Welcome to HiveGrid, Ada!</title></head><body style="margin:0;padding:0;background-color:#f7f5f1;color:#231f20;font-family:ui-sans-serif, -apple-system, BlinkMacSystemFont, &#x27;Segoe UI&#x27;, Roboto, &#x27;Helvetica Neue&#x27;, 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:32px 14px"><div style="background-color:#ffffff;border:1px solid #e7e1d8;border-radius:22px;box-shadow:0 16px 48px rgba(35, 31, 32, 0.08);overflow:hidden"><div style="background-color:#f1b729;height:7px;line-height:7px"> </div><div style="padding:34px 34px 30px"><div style="padding-bottom:24px;text-align:left"><a href="https://hivegrid.de" style="color:#231f20;text-decoration:none" target="_blank" rel="noopener noreferrer"><span style="display:inline-block;vertical-align:middle"><img src="https://hivegrid.de/hivegrid-logo.png" alt="HiveGrid" width="42" height="36" style="display:block;border:0"/></span><strong style="color:#231f20;display:inline-block;font-size:22px;letter-spacing:-0.03em;margin-left:10px;vertical-align:middle">HiveGrid</strong></a></div><div style="color:#735400;font-size:12px;font-weight:700;letter-spacing:0.1em;text-transform:uppercase;margin-bottom:8px">Welcome</div><h1 style="margin:8px 0 18px;font-size:30px;line-height:1.16;color:#231f20;font-weight:700">Welcome, Ada!</h1><p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#231f20">Thanks for trying HiveGrid.</p><a href="https://app.example.com/login" style="display:inline-block;background-color:#f1b729;color:#231f20;padding:13px 20px;border:1px solid #f1b729;border-radius:10px;font-weight:700;font-size:16px;line-height:1.25;text-decoration:none" target="_blank" rel="noopener noreferrer">Click here to log in <span aria-hidden="true">→</span></a><p style="margin:24px 0 0;font-size:14px;line-height:1.6;color:#231f20">Kind regards,<br/><strong>HiveGrid-Team</strong></p><div style="margin-top:32px;padding-top:20px;border-top:1px solid;font-size:12px;line-height:1.5;border-top-color:#e7e1d8;color:#655f59"><div style="color:#231f20;font-size:13px;font-weight:700;margin-bottom:10px">HiveGrid</div><div><a href="https://hivegrid.de/datenschutz" style="text-decoration:underline;color:#735400">Privacy</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/agb" style="text-decoration:underline;color:#735400">Terms</a><span style="margin:0 6px">·</span><a href="https://hivegrid.de/impressum" style="text-decoration:underline;color:#735400">Imprint</a></div><div style="margin-top:8px">Questions? Email us at <a href="mailto:support@hivegrid.de" style="text-decoration:underline;color:#735400">support@hivegrid.de</a>.</div><div style="margin-top:10px">© HiveGrid</div></div></div></div></div></body></html>"`;
exports[`WelcomeEmail > renders default-brand named welcome (snapshot) > text 1`] = `
"Welcome to HiveGrid, Ada!
HiveGrid
 
HiveGrid (https://hivegrid.de)
Welcome
Welcome, Ada!
Thanks for trying HiveGrid.
Click here to log in (https://app.example.com/login)Thanks,
-
HiveGrid Support
Click here to log in → (https://app.example.com/login)Kind regards,
HiveGrid-Team
HiveGrid
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)."
Questions? Email us at support@hivegrid.de (mailto:support@hivegrid.de).
© HiveGrid"
`;
@@ -3,6 +3,12 @@ import { BaseLayout } from "../_layout/BaseLayout.js";
import { Button } from "../_layout/Button.js";
import { Eyebrow } from "../_layout/Eyebrow.js";
import type { MailBrand } from "../_layout/theme.js";
import type { MailFooterCopy, MailLanguage } from "../_layout/Footer.js";
export interface TransactionalChromeProps {
readonly language?: MailLanguage;
readonly footerCopy?: MailFooterCopy;
}
/**
* Shared visual scaffold for all transactional templates.
@@ -12,15 +18,15 @@ import type { MailBrand } from "../_layout/theme.js";
* Concentrating that into one component keeps per-template files small
* and ensures brand-theme application is uniform.
*/
export interface TransactionalScaffoldProps {
export interface TransactionalScaffoldProps extends TransactionalChromeProps {
readonly brand: MailBrand;
readonly subject: string;
readonly previewText?: string;
readonly eyebrow: string;
readonly title: string;
readonly intro: ReactNode;
readonly actionUrl: string;
readonly actionLabel: string;
readonly actionUrl?: string;
readonly actionLabel?: string;
readonly outro?: ReactNode;
readonly children?: ReactNode;
readonly unsubscribeUrl?: string;
@@ -28,9 +34,9 @@ export interface TransactionalScaffoldProps {
}
const titleStyle = (brand: MailBrand): CSSProperties => ({
margin: "8px 0 16px",
fontSize: "28px",
lineHeight: 1.2,
margin: "8px 0 18px",
fontSize: "30px",
lineHeight: 1.16,
color: brand.textColor,
fontWeight: 700,
});
@@ -43,8 +49,8 @@ const paragraphStyle = (brand: MailBrand): CSSProperties => ({
});
const outroStyle = (brand: MailBrand): CSSProperties => ({
margin: "24px 0 0",
fontSize: "14px",
margin: "30px 0 0",
fontSize: "15px",
lineHeight: 1.6,
color: brand.mutedTextColor,
});
@@ -69,21 +75,25 @@ export function TransactionalScaffold({
children,
unsubscribeUrl,
signoffThanks,
language,
footerCopy,
}: TransactionalScaffoldProps) {
return (
<BaseLayout brand={brand} title={subject} previewText={previewText ?? subject} unsubscribeUrl={unsubscribeUrl}>
<BaseLayout brand={brand} title={subject} previewText={previewText ?? subject} unsubscribeUrl={unsubscribeUrl} language={language} footerCopy={footerCopy}>
<Eyebrow brand={brand}>{eyebrow}</Eyebrow>
<h1 style={titleStyle(brand)}>{title}</h1>
<p style={paragraphStyle(brand)}>{intro}</p>
<Button brand={brand} href={actionUrl}>
{actionLabel}
</Button>
{actionUrl && actionLabel ? (
<Button brand={brand} href={actionUrl}>
{actionLabel}
</Button>
) : null}
{outro ? <p style={outroStyle(brand)}>{outro}</p> : null}
{children}
<p style={signoffStyle(brand)}>
{signoffThanks ?? "Thanks,"}
<br />-<br />
{brand.supportFromName}
{footerCopy?.signoffClosing ?? signoffThanks ?? "Kind regards,"}
<br />
<strong>{footerCopy?.signoffTeam ?? brand.supportFromName}</strong>
</p>
</BaseLayout>
);
@@ -6,16 +6,11 @@ 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"
/>
<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<");
expect(html).toContain(">Open <span");
// The support fallback label must not appear when an action URL exists.
expect(html).not.toContain("Contact support");
});