feat(email-renderer): render countdown images across email targets
This commit is contained in:
1 parent
4df4173dfb
commit
d1f42e0566
4 files changed
+47
-4
No files matched your search
@@ -56,6 +56,20 @@ const document: BlockDocument = {
|
||||
};
|
||||
|
||||
describe("email renderer", () => {
|
||||
test("countdown URLs are derived for HTML AMP and MJML without mutating the document", async () => {
|
||||
const draft = structuredClone(document);
|
||||
draft.root.slots.content[0]!.slots.content = [{id:"timer",type:"content.countdown",version:1,props:{label:"Offer ends",deadline:"2026-10-01T00:00:00Z",fallback:"Offer ended"},styles:{},slots:{}}];
|
||||
const before = JSON.stringify(draft);
|
||||
const result = await renderEmail(draft, {amp:true,mjml:true,countdownImageUrl:"https://email.example.com/api/countdown"});
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) return;
|
||||
const image = "https://email.example.com/api/countdown?deadline=1790812800000";
|
||||
expect(result.value.parts.html.content).toContain(image);
|
||||
expect(result.value.parts.amp?.content).toContain(image);
|
||||
expect(result.value.exports?.mjml).toContain(image);
|
||||
expect(JSON.stringify(draft)).toBe(before);
|
||||
expect((await renderEmail(draft, {countdownImageUrl:"javascript:alert(1)"})).ok).toBe(false);
|
||||
});
|
||||
test("content inherits the selected brand font instead of overriding it", async () => {
|
||||
const branded = structuredClone(document);
|
||||
branded.root.props.fontFamily = "Georgia, serif";
|
||||
|
||||
Reference in new issue
Block a user