fix: link approval emails to sign-in

This commit is contained in:
Leon Tonhäuser committed 2026-08-11 16:30:51 +02:00
1 parent 60ef5ddab9
commit c1bd620d91
4 files changed
+38 -3

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
import { beforeEach, expect, test, vi } from "vitest";
const { sendMail } = vi.hoisted(() => ({
sendMail: vi.fn().mockResolvedValue({ messageId: "message-1" }),
}));
vi.mock("nodemailer", () => ({
default: {
createTransport: () => ({ sendMail }),
},
}));
import { emailService } from "./service";
beforeEach(() => {
sendMail.mockClear();
});
test("links new-album notifications to the existing sign-in page", async () => {
await emailService.sendNewAlbumNotification(
"redaktion@example.com",
"Spieltag 1",
);
expect(sendMail).toHaveBeenCalledWith(
expect.objectContaining({
to: "redaktion@example.com",
html: expect.stringContaining(
'href="http://localhost:3000/anmelden"',
),
}),
);
});
+1 -1
View File
@@ -120,7 +120,7 @@ export const emailService = {
to: toEmail,
subject,
text: textBody,
html: buildHtml(isMultiple ? "Neue Alben verfügbar" : "Neues Album verfügbar", htmlBody, { text: "Zum Portal", url: `${env.BETTER_AUTH_URL}/login` }),
html: buildHtml(isMultiple ? "Neue Alben verfügbar" : "Neues Album verfügbar", htmlBody, { text: "Zum Portal", url: `${env.BETTER_AUTH_URL}/anmelden` }),
});
},
};
+3 -1
View File
@@ -33,6 +33,8 @@ test("sends an approval notice without leaking SMTP credentials", async () => {
to: "editorial@example.com",
subject: "Ihr Zugang zum Redaktionsportal ist freigegeben",
text: expect.stringContaining("Neue Redaktion"),
html: expect.stringContaining("Account freigegeben"),
html: expect.stringContaining(
'href="http://localhost:3000/anmelden"',
),
}));
});
+1 -1
View File
@@ -115,7 +115,7 @@ export function createMailer({ from, transport }: { from: string; transport: Mai
async sendApprovalNotice({ to, editorialName }) {
const subject = "Ihr Zugang zum Redaktionsportal ist freigegeben";
const text = `Der Zugang für ${editorialName} wurde freigegeben. Sie können sich jetzt im Redaktionsportal anmelden.`;
const loginUrl = `${env.BETTER_AUTH_URL}/login`;
const loginUrl = `${env.BETTER_AUTH_URL}/anmelden`;
await send({
to,
subject,