import { describe, expect, it } from 'vitest'; import { agreementHtml } from '../src/pdf/agreementHtml.js'; const application = { status: 'DRAFT', agreement_date: '2026-09-30', full_name: 'Asha ', age: 42, address: '12 Camp Road', registration_no: 'MMC-999', medical_council: 'Goa', pan: 'ABCDE1234F', gstin: '27ABCDE1234F1Z5', bank_name: 'Example Bank', account_holder: 'Asha Holder', account_number: '998877665544', ifsc: 'SBIN0001234', }; describe('agreement HTML', () => { it('merges every field, escapes values, and watermarks a draft', () => { const html = agreementHtml({ application, physicianSignature: { type: 'TYPED', typedName: 'Asha ' }, draft: true, }); expect(html).toContain('is executed on this'); expect(html).not.toContain('is is executed'); expect(html).toContain('

CONSULTATION AGREEMENT

'); expect(html).toContain('

BETWEEN

'); expect(html).toContain('

… PARTY OF THE FIRST PART

'); expect(html).toContain('

1. PURPOSE

'); expect(html).toContain( 'WHEREAS, Chest Research And Training Private Limited', ); expect(html).toContain('Extended-Dose Pack versus Regular Pack'); expect(html).toContain('AND WHEREAS, the said study'); expect(html).not.toContain('1.1 CREST'); expect(html).toContain('.filled { font-weight: 700; text-decoration: underline;'); expect(html).toContain('this 30 day of September 2026'); expect(html).toContain('Asha <Rao>'); expect(html).not.toContain('Asha '); expect(html).toContain('aged 42 years'); expect(html).toContain('12 Camp Road'); expect(html).toContain('MMC-999'); expect(html).toContain('Goa Medical Council'); expect(html).toContain('ABCDE1234F'); expect(html).toContain('27ABCDE1234F1Z5'); expect(html).toContain('Example Bank'); expect(html).toContain('Asha Holder'); expect(html).toContain('998877665544'); expect(html).toContain('SBIN0001234'); expect(html).toContain('class="typed-signature filled"'); expect(html).toContain('Pending approval'); expect(html).toContain('DRAFT - NOT SIGNED'); }); it('shows the CREST signatory only after approval', () => { const html = agreementHtml({ application: { ...application, status: 'APPROVED' }, signatory: { name: 'Dr Sudeep Salvi', designation: 'Medical Director', signatureDataUrl: 'data:image/png;base64,AAAA', }, draft: false, }); expect(html).toContain('Dr Sudeep Salvi'); expect(html).toContain('Medical Director'); expect(html).toContain('data:image/png;base64,AAAA'); expect(html).toContain('class="signature-row"'); expect(html).toContain('alt="CREST"'); expect(html).not.toContain('Pending approval'); expect(html).not.toContain('DRAFT - NOT SIGNED'); }); });