Files
landing-builder/lib/exporter/sections.escape.regression.test.ts
T
2025-11-14 20:19:50 +09:00

34 lines
1.3 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import { exportPage } from '@/lib/exporter/html'
import { pageSchema, type Page } from '@/lib/schema/page'
function makePage(): Page {
return pageSchema.parse({
title: 'Escape Regression',
locale: 'en',
theme: { primaryColor: '#0ea5e9', fontFamily: 'Inter' },
sections: [
{ type: 'features', props: { items: ['F<&>"', 'Safe'] } },
{ type: 'faq', props: { items: [{ q: 'Q<&>"', a: 'A<&>"' }] } },
],
form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } },
seo: { title: 'SEO', description: 'Desc' },
})
}
describe('Exporter - HTML escape regression (Features/FAQ)', () => {
it('escapes HTML special characters in features items', () => {
const out = exportPage(makePage())
const html = out.html
// feature item should contain escaped characters &lt; &amp; &gt; &quot;
expect(html).toContain('<li class="feature-item">F&lt;&amp;&gt;&quot;</li>')
})
it('escapes HTML special characters in faq q/a', () => {
const out = exportPage(makePage())
const html = out.html
expect(html).toContain('<h3 class="faq-q">Q&lt;&amp;&gt;&quot;</h3>')
expect(html).toContain('<p class="faq-a">A&lt;&amp;&gt;&quot;</p>')
})
})