import { createHash } from 'node:crypto'; import { mkdtempSync, rmSync } from 'node:fs'; import { tmpdir } from 'node:os'; import path from 'node:path'; import { SendEmailCommand } from '@aws-sdk/client-sesv2'; import { Temporal } from '@js-temporal/polyfill'; import { afterEach, describe, expect, it } from 'vitest'; import { createApp } from '../src/app.js'; import { loadConfig } from '../src/config.js'; import { openAppDatabase } from '../src/db.js'; import { issueFormToken } from '../src/form-token.js'; import { deliverDueMail } from '../src/mail/deliver.js'; import { createPostmarkMailer } from '../src/mail/postmark.js'; import { createSesMailer } from '../src/mail/ses.js'; import { renderConfirmation } from '../src/mail/templates.js'; import type { Mailer } from '../src/mail/types.js'; import { reserveSignup, type ReserveInput } from '../src/signup.js'; import { devEnv } from './env.js'; const NOW = '2026-10-14T18:00:00.000Z'; const MAIL = { baseUrl: 'http://127.0.0.1:3000', basePath: '', from: 'Hope Food Pantry ', replyTo: 'volunteer@example.invalid', }; const dirs: string[] = []; const databases: { close: () => void }[] = []; afterEach(() => { for (const database of databases.splice(0)) database.close(); for (const dir of dirs.splice(0)) rmSync(dir, { recursive: true, force: true }); }); describe('transactional mail', () => { it('escapes the person\'s name in HTML and keeps the subject on one line', () => { const rendered = renderConfirmation({ audience: 'volunteer', volunteerName: 'Pat