/**
* Phase 7 §14.7 critical mitigation: body markdown XSS sanitization.
*
* Every code path that turns rep-authored markdown into the email's
* `html` body is required to go through `renderEmailBody()`. These tests
* are the canary — if any future change to the renderer lets a known XSS
* payload through, the test breaks before the change ships.
*/
import { describe, expect, it } from 'vitest';
import {
EMAIL_BODY_MAX_BYTES,
expandMergeTokens,
extractTokens,
findUnresolvedTokens,
renderEmailBody,
} from '@/lib/utils/markdown-email';
describe('renderEmailBody — XSS payload coverage', () => {
it('escapes there');
expect(html).not.toContain(')');
expect(html).not.toContain(' {
const html = renderEmailBody('[example](https://example.com)');
expect(html).toContain(' {
const html = renderEmailBody('[reach me](mailto:hi@example.com)');
expect(html).toContain(' tags', () => {
const html = renderEmailBody('');
expect(html).not.toContain('