import "../setup.ts"; import { assert, assertFalse, assertStringIncludes } from "@std/assert"; import { type DigestContent, renderDigestEmail } from "../../mail/digest.ts"; const links = { notifications: "https://g.test/notifications", followed: "https://g.test/~/followed", chat: "https://g.test/?chat=open", community: "https://g.test/community/monthly", settings: "https://g.test/users/ann/~/settings", unsubscribe: "https://g.test/unsubscribe?token=t", }; const dump = (title: string, over = {}) => ({ title, url: "https://g.test/dumps/x", poster: "bob", domain: "example.com", thumbnail: "https://g.test/api/dumps/x/thumbnail?v=1", votes: 1, comments: 0, mine: false, ...over, }); Deno.test("renderDigestEmail: the weekly digest escapes what users wrote and links to unsubscribe", () => { const content: DigestContent = { cadence: "weekly", from: new Date("2026-09-27T08:00:00Z"), to: new Date("2026-10-04T08:00:00Z"), reader: "ann", activity: { counts: { upvotes: 12, followers: 1 }, highlights: [{ kind: "comment", who: "bob", target: { title: "", url: "https://g.test/dumps/y" }, quote: "a bold claim", at: new Date("2026-09-30T10:00:00Z"), }], total: 13, }, network: { dumps: [dump("Net & work")], more: 2 }, top: [dump("Mine", { mine: true, votes: 4 })], community: null, links, }; const email = renderDigestEmail(content, { style: "smooth", scheme: "auto" }); assertStringIncludes(email.subject, "Your week on gerbeur, Sep 27"); assertFalse(email.html.includes("