Apply button visuals to the clickable surface across email targets
Quality / quality (ubuntu-latest) (push) Failing after 11m40s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
Clintchiz committed 2026-09-05 21:31:06 +05:30
1 parent 45343760e0
commit 9f2b5bb5d9
4 files changed
+27 -6

No files matched your search

@@ -0,0 +1,16 @@
import { expect, test } from "bun:test";
import { buttonBlock, ampLayoutCss } from "../src/blocks.ts";
test("button visuals target the clickable surface rather than the full-width wrapper", async () => {
const node = {id:"cta",type:"content.button",version:1,props:{label:"Act",href:"https://example.com"},styles:{backgroundColor:{base:"#123456"},padding:{base:"8px 32px"},borderRadius:{base:"20px"}},slots:{}};
const context = {node,context:{},slots:{}} as never;
const html = String(await buttonBlock.renderers!.emailHtml!(context));
const wrapper = html.match(/<td data-block-id="cta"[^>]*>/)![0];
expect(wrapper).not.toContain("#123456");
expect(wrapper).not.toContain("20px");
expect(wrapper).not.toContain("32px");
expect(html).toContain('bgcolor="#123456"');
expect(html.match(/<a [^>]*>/)![0]).toContain("padding:8px 32px");
expect(ampLayoutCss(node)).toContain("padding:8px 32px");
expect(String(await buttonBlock.renderers!.mjml!(context))).toContain('inner-padding="8px 32px"');
});