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:');
  });
});
