import { mkdtempSync, rmSync } from 'node:fs'; import { tmpdir } from 'node:os'; import path from 'node:path'; import { afterEach, describe, expect, it } from 'vitest'; import { moveSignup, updateShift } from '../src/admin/store.js'; import { createApp } from '../src/app.js'; import { bootstrapAdmin } from '../src/auth/bootstrap.js'; import { loadConfig } from '../src/config.js'; import { openAppDatabase } from '../src/db.js'; import { deliverDueMail } from '../src/mail/deliver.js'; import type { Mailer } from '../src/mail/types.js'; import { issueReminderOffToken } from '../src/reminders.js'; import { queueDueReminders } from '../src/reminders.js'; import { reserveSignup, type ReserveInput } from '../src/signup.js'; import { devEnv } from './env.js'; const NOW = '2026-10-14T18:00:00.000Z'; const EARLY = '2026-10-01T15:00:00.000Z'; const INSIDE_START = '2026-10-16T00:00:00.000Z'; const INSIDE_END = '2026-10-16T03:00:00.000Z'; const INSIDE_NEAR = '2026-10-15T22:00:00.000Z'; const SOON = '2026-10-14T18:30:00.000Z'; const SOON_END = '2026-10-14T20:00:00.000Z'; const LATER_START = '2026-10-15T14:00:00.000Z'; const LATER_END = '2026-10-15T17:00:00.000Z'; const FAR_START = '2026-10-20T14:00:00.000Z'; const FAR_END = '2026-10-20T17:00:00.000Z'; const SECRET = 'dev-only-change-me-not-for-production-use'; const ORIGIN = 'http://127.0.0.1:3000'; const MAIL = { baseUrl: ORIGIN, 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('reminder mail', () => { it('queues the 48 hour reminder, sends it once, and records provider acceptance', async () => { const db = await openDb(); const shiftId = insertShift(db, LATER_START, LATER_END); reserveSignup(db, reservation(shiftId, { name: 'Pat