Website register-interest form now offers the 3 residence types as a multi-select; the choice + preferred-contact flow into the CRM inquiry payload, the inbox detail, and the residential emails. - inquiry inbox detail surfaces residence type(s), preferred contact, type-of-interest, comments (full data capture) - residential-inquiry emails: client confirmation names the chosen villa(s); sales alert converted to the canonical detail-line format (uniform with berth/contact) + residence type(s)/preferred contact + plain-text part - website-intake-fields parses residence_types[] + method_of_contact - contact_form alerts split to their own recipient key (contact_notification_recipients) - Residential Interests section: new residence_type field (schema + migration 0099, validators, inline select on the detail) - contact-form-alert email refactor shipped (interest-alert style) Tests: website-intake-fields, residential-inquiry templates, contact-form-alert, residential-interest validators. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L2qc3xZTfif7N4Wq3QDa8X
40 lines
1.6 KiB
TypeScript
40 lines
1.6 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { contactFormSalesAlert } from '@/lib/email/templates/contact-form-alert';
|
|
|
|
describe('contactFormSalesAlert', () => {
|
|
it('renders a branded HTML alert with all submitted details + a follow-up link', async () => {
|
|
const { subject, html, text } = await contactFormSalesAlert({
|
|
fullName: 'Jane Doe',
|
|
email: 'jane@example.com',
|
|
interestType: 'Owner, Crew',
|
|
comments: 'Interested in a berth for a 40m yacht.',
|
|
crmDeepLink: 'https://crm.portnimara.com/inquiries/abc',
|
|
portName: 'Port Nimara',
|
|
});
|
|
|
|
expect(subject).toContain('Jane Doe');
|
|
// Interest-registration style: friendly intro + detail lines + CRM follow-up link.
|
|
expect(html).toContain('A new contact-form enquiry has come in');
|
|
expect(html).toContain('Jane Doe');
|
|
expect(html).toContain('jane@example.com');
|
|
expect(html).toContain('Owner, Crew');
|
|
expect(html).toContain('Interested in a berth for a 40m yacht.');
|
|
expect(html).toContain('to follow up');
|
|
// Plain-text part mirrors the interest alert.
|
|
expect(text).toContain('A new contact-form enquiry');
|
|
expect(text).toContain('Comments: Interested in a berth for a 40m yacht.');
|
|
});
|
|
|
|
it('falls back gracefully when interest + comments are absent', async () => {
|
|
const { html, text } = await contactFormSalesAlert({
|
|
fullName: 'Bob Smith',
|
|
email: 'bob@example.com',
|
|
portName: 'Port Nimara',
|
|
});
|
|
expect(html).toContain('(none provided)');
|
|
expect(text).toContain('Comments: (none provided)');
|
|
expect(html).not.toContain('Interest:');
|
|
});
|
|
});
|