fix(email): inherit button brand colors across render targets
Quality / quality (ubuntu-latest) (push) Failing after 22s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
Clintchiz committed 2026-09-05 15:51:43 +05:30
1 parent e1ea6e2977
commit 7afd60e812
4 files changed
+44 -10

No files matched your search

@@ -0,0 +1,26 @@
import { expect, test } from "bun:test";
import type { BlockDocument } from "@wrnexus/blocks";
import { renderEmail, validateMjml } from "../src/index.ts";
test("button background inherits brand color with explicit semantic overrides across formats", async () => {
for (const override of [undefined, "#aabbcc"]) {
const document: BlockDocument = {
schemaVersion: 1, kind: "email", meta: { subject: "Brand", lang: "en" }, theme: { tokens: {} },
root: { id: "root", type: "layout.email-document", version: 1, props: { linkColor: "#125634" }, styles: {}, slots: {
content: [{ id: "button", type: "content.button", version: 1, props: { label: "Act", href: "https://example.com" }, styles: override ? { backgroundColor: { base: override } } : {}, slots: {} }],
} },
};
document.root.slots.content = [{ id: "section", type: "layout.section", version: 1, props: {}, styles: {}, slots: { content: document.root.slots.content } }];
const before = structuredClone(document);
const rendered = await renderEmail(document, { amp: true, mjml: true, ampValidationTimeoutMs: 10000 });
expect(rendered.ok).toBe(true);
if (!rendered.ok) return;
const color = override ?? "#125634";
expect(rendered.value.parts.html.content).toContain(`bgcolor="${color}"`);
expect(rendered.value.parts.amp?.validation.valid).toBe(true);
expect(rendered.value.parts.amp?.content).toContain(`background-color:${color}`);
expect(rendered.value.exports?.mjml).toContain(`background-color="${color}"`);
expect(await validateMjml(rendered.value.exports!.mjml!)).toEqual([]);
expect(document).toEqual(before);
}
});