Apply brand defaults to MJML survey and product buttons
Quality / quality (ubuntu-latest) (push) Failing after 1s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
Clintchiz committed 2026-09-05 17:56:46 +05:30
1 parent 07ed6b2596
commit b0fca36bca
5 files changed
+23 -3

No files matched your search

@@ -0,0 +1,16 @@
import { expect, test } from "bun:test";
import { createRequire } from "node:module";
import type { BlockDocument } from "@wrnexus/blocks";
import { renderEmail } from "../src/index.ts";
const compile = createRequire(import.meta.url)("mjml");
test("survey MJML button inherits brand color and preserves safe text fallback", async () => {
const document: BlockDocument = { schemaVersion: 1, kind: "email", meta: { subject: "Survey" }, theme: { tokens: {} }, root: { id: "root", type: "layout.email-document", version: 1, props: { width: "600", linkColor: "#a12345" }, styles: {}, slots: { content: [{ id: "survey", type: "content.survey", version: 1, props: { question: "How was your visit?", buttonLabel: "Answer & share", href: "https://example.com/survey" }, styles: {}, slots: {} }] } } };
const result = await renderEmail(document, { mjml: true });
if (!result.ok) throw new Error("Render failed");
expect(result.value.parts.text.content).toContain("How was your visit?\nAnswer & share: https://example.com/survey");
const compiled = await compile(result.value.exports!.mjml!, { validationLevel: "strict" });
expect(compiled.errors).toEqual([]);
expect(compiled.html).toContain("background:#a12345");
expect(compiled.html).toContain("Answer & share");
});