fix(email-renderer): preserve multiline text across email formats
Quality / quality (ubuntu-latest) (push) Failing after 0s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
Clintchiz committed 2026-09-05 13:09:06 +05:30
1 parent baee958c68
commit 612b3945ac
3 files changed
+20 -4

No files matched your search

@@ -57,6 +57,21 @@ const document: BlockDocument = {
};
describe("email renderer", () => {
test("text line breaks survive all formats without interpreting entered markup", async () => {
const draft = structuredClone(document);
const text = 'First line\r\nSecond line\n\n<script>alert("x")</script>\rLast line';
draft.root.slots.content[0]!.slots.content = [{id:"text",type:"content.text",version:1,props:{text},styles:{},slots:{}}];
const rendered = await renderEmail(draft,{amp:true,mjml:true});
expect(rendered.ok).toBe(true);
if (!rendered.ok) return;
for (const output of [rendered.value.parts.html.content,rendered.value.parts.amp?.content,rendered.value.exports?.mjml]) {
expect(output).toContain('First line<br />Second line<br /><br />&lt;script&gt;alert(&quot;x&quot;)&lt;/script&gt;<br />Last line');
expect(output).not.toContain('<script>alert');
}
expect(rendered.value.parts.text.content).toContain(text);
expect(rendered.value.parts.amp?.validation.valid).toBe(true);
expect(await validateMjml(rendered.value.exports!.mjml!)).toEqual([]);
});
test("AMP inherits the saved brand font, colors and body width", async () => {
const draft = structuredClone(document);
Object.assign(draft.root.props, {width:"720",fontFamily:"Georgia, serif",textColor:"#112233",linkColor:"#445566",background:"#eeeeee",contentBackground:"#fafafa"});