fix: link approval emails to sign-in
This commit is contained in:
1 parent
60ef5ddab9
commit
c1bd620d91
4 files changed
+38
-3
No files matched your search
@@ -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"',
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
});
|
||||||
@@ -120,7 +120,7 @@ export const emailService = {
|
|||||||
to: toEmail,
|
to: toEmail,
|
||||||
subject,
|
subject,
|
||||||
text: textBody,
|
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` }),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -33,6 +33,8 @@ test("sends an approval notice without leaking SMTP credentials", async () => {
|
|||||||
to: "editorial@example.com",
|
to: "editorial@example.com",
|
||||||
subject: "Ihr Zugang zum Redaktionsportal ist freigegeben",
|
subject: "Ihr Zugang zum Redaktionsportal ist freigegeben",
|
||||||
text: expect.stringContaining("Neue Redaktion"),
|
text: expect.stringContaining("Neue Redaktion"),
|
||||||
html: expect.stringContaining("Account freigegeben"),
|
html: expect.stringContaining(
|
||||||
|
'href="http://localhost:3000/anmelden"',
|
||||||
|
),
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
@@ -115,7 +115,7 @@ export function createMailer({ from, transport }: { from: string; transport: Mai
|
|||||||
async sendApprovalNotice({ to, editorialName }) {
|
async sendApprovalNotice({ to, editorialName }) {
|
||||||
const subject = "Ihr Zugang zum Redaktionsportal ist freigegeben";
|
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 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({
|
await send({
|
||||||
to,
|
to,
|
||||||
subject,
|
subject,
|
||||||
|
|||||||
Reference in new issue
Block a user