Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion web/lib/email/templates/base.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ export function BaseEmail({ preview, children, baseUrl }: BaseEmailProps) {
<Head />
<Preview>{preview}</Preview>
<Body style={body}>
<Container style={container}>
<Container width="600" style={container}>
<Section style={header}>
<Img src={logoUrl} width="48" height="48" alt="Techulus Cloud" />
</Section>
Expand All@@ -47,7 +47,9 @@ const container = {
margin: "0 auto",
padding: "12px 0 32px",
marginBottom: "64px",
width: "100%",
maxWidth: "600px",
tableLayout: "fixed" as const,
};

const header = {
Expand All@@ -56,6 +58,9 @@ const header = {

const content = {
padding: "16px 24px",
overflowWrap: "anywhere" as const,
wordBreak: "break-word" as const,
wordWrap: "break-word" as const,
};

const footer = {
Expand Down
38 changes: 38 additions & 0 deletions web/tests/email-templates.test.tsx
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
import { render } from "@react-email/render";
import { describe, expect, it } from "vitest";
import { Alert } from "@/lib/email/templates/alert";
import { MemberInvitation } from "@/lib/email/templates/member-invitation";

const longContent = "x".repeat(2_000);

const templates = {
alert: Alert({
bannerText: "BUILD FAILED",
heading: "Build Failure Alert",
description: "The build failed.",
details: [{ label: "Error", value: longContent }],
}),
invitation: MemberInvitation({
inviterName: longContent,
role: "member",
inviteUrl: `https://cloud.example.com/invite/${longContent}`,
}),
};

describe("email templates", () => {
it.each(Object.entries(templates))(
"constrains and wraps long %s content",
async (_, template) => {
const html = await render(template);

expect(html).toContain(longContent);
expect(html).toContain('width="600"');
expect(html).toContain("width:100%");
expect(html).toContain("max-width:600px");
expect(html).toContain("table-layout:fixed");
expect(html).toContain("overflow-wrap:anywhere");
expect(html).toContain("word-break:break-word");
expect(html).toContain("word-wrap:break-word");
},
);
});
Loading