Connect the live modals to the drawn sent, expired, invalid-email, and send-failed screens, pin the phone footer above the keyboard, and send the light login email.
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { MAGIC_LINK_TTL_MINUTES } from "../../lib/privacyRetention";
|
|
import { buildMagicLinkMail } from "../../lib/server/magicLinkMail";
|
|
|
|
const VERIFY_URL =
|
|
"https://communityrule.info/api/auth/magic-link/verify?token=abc";
|
|
|
|
describe("buildMagicLinkMail", () => {
|
|
const mail = buildMagicLinkMail({
|
|
verifyUrl: VERIFY_URL,
|
|
origin: "https://communityrule.info",
|
|
});
|
|
|
|
it("uses the drawn subject, once-and-minutes line, and log in button", () => {
|
|
expect(mail.subject).toBe("Your login link for CommunityRule");
|
|
expect(mail.previewText).toBe(
|
|
`It works once, for ${MAGIC_LINK_TTL_MINUTES} minutes.`,
|
|
);
|
|
expect(mail.text).toContain("Log in to CommunityRule");
|
|
expect(mail.text).toContain(VERIFY_URL);
|
|
expect(mail.text).toContain(
|
|
`It works once, for ${MAGIC_LINK_TTL_MINUTES} minutes.`,
|
|
);
|
|
expect(mail.html).toContain("background:#000000");
|
|
expect(mail.html).toContain(">Log in</a>");
|
|
expect(mail.html).toContain(`href="${VERIFY_URL}"`);
|
|
expect(mail.html).toContain("/privacy");
|
|
expect(mail.html).toContain("/about");
|
|
});
|
|
|
|
it("does not invent a first name", () => {
|
|
expect(mail.html).not.toContain("Hi ");
|
|
expect(mail.text).not.toContain("Hi ");
|
|
});
|
|
});
|