import { describe, expect, it } from 'vitest'; import { signingStatusNotificationEmail } from '@/lib/email/templates/signing-status-notification'; describe('signingStatusNotificationEmail', () => { it('renders a per-signer "has signed" alert with progress + CRM link', async () => { const { subject, html, text } = await signingStatusNotificationEmail({ event: 'signed', documentLabel: 'Expression of Interest', clientName: 'Jane Doe', portName: 'Port Nimara', crmUrl: 'https://crm.portnimara.com/port-nimara/documents/abc', signerName: 'Jane Doe', signerRole: 'client', signedCount: 1, totalCount: 3, }); // Subject names who signed + the deal so sales can triage at a glance. expect(subject).toContain('Jane Doe'); expect(subject).toContain('signed'); // Body states the signing event, the document, and progress. expect(html).toContain('Jane Doe'); expect(html).toContain('has signed'); expect(html).toContain('Expression of Interest'); expect(html).toContain('1 of 3'); // Internal recipients get a deep link into the CRM, not a signing link. expect(html).toContain('https://crm.portnimara.com/port-nimara/documents/abc'); expect(text).toContain('Jane Doe'); expect(text).toContain('1 of 3'); }); it('renders a completion alert when all parties have signed', async () => { const { subject, html, text } = await signingStatusNotificationEmail({ event: 'completed', documentLabel: 'Sales Contract', clientName: 'Acme Holdings', portName: 'Port Nimara', crmUrl: 'https://crm.portnimara.com/port-nimara/documents/xyz', }); expect(subject).toContain('Acme Holdings'); expect(subject.toLowerCase()).toContain('fully signed'); expect(html).toContain('all parties'); expect(html).toContain('Sales Contract'); expect(html).toContain('Acme Holdings'); expect(html).toContain('https://crm.portnimara.com/port-nimara/documents/xyz'); expect(text).toContain('Acme Holdings'); }); });