fix(email-renderer): preserve AMP section and spacer layout
Quality / quality (ubuntu-latest) (push) Failing after 10m29s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
Clintchiz committed 2026-09-05 15:02:48 +05:30
1 parent 6b35f522b9
commit 5e30d6a7d0
4 files changed
+42 -5

No files matched your search

@@ -10,6 +10,26 @@ import {
type EmailRenderBundle,
} from "../src/index.ts";
import type { BlockDocument } from "@wrnexus/blocks";
import { ampLayoutClass, ampLayoutCss } from "../src/blocks.ts";
test("AMP section and spacer CSS retains configured layout values", async () => {
const draft = structuredClone(document);
const section = draft.root.slots.content[0]!;
section.props = { background: "#abcdef", padding: "12px 30px" };
const spacer = { id: 'spacer:one"', type: "content.spacer", version: 1, props: { height: "77" }, styles: {}, slots: {} };
section.slots.content = [spacer];
const result = await renderEmail(draft, { amp: true, mjml: true });
expect(result.ok).toBe(true);
if (!result.ok) return;
const amp = result.value.parts.amp;
expect(amp?.validation.valid).toBe(true);
expect(amp?.content).toContain(`.${ampLayoutClass(section)}{background:#abcdef;padding:12px 30px}`);
expect(amp?.content).toContain(`.${ampLayoutClass(spacer)}{height:77px;line-height:77px;font-size:1px}`);
expect(amp?.content).toContain(`class="${ampLayoutClass(spacer)}"`);
expect(result.value.parts.html.content).toContain("height:77px");
expect(result.value.exports?.mjml).toContain('height="77px"');
expect(ampLayoutCss({ ...section, props: { background: "red;}body{display:none", padding: "</style>" } })).not.toContain("display:none");
});
const document: BlockDocument = {
schemaVersion: 1,