feat(blocks): add typed personalization resolution
This commit is contained in:
1 parent
2428df6e78
commit
157eec7a78
9 files changed
+128
-12
No files matched your search
@@ -90,6 +90,20 @@ describe("email renderer", () => {
|
||||
expect(rendered.value.parts.html.content).not.toContain("position:fixed");
|
||||
});
|
||||
|
||||
test("resolves allowlisted personalization values and fallbacks", async () => {
|
||||
const personalized = structuredClone(document);
|
||||
personalized.root.slots.content[0]!.slots.content[0]!.props.text =
|
||||
"Hello {{recipientName|friend}}";
|
||||
const rendered = await renderEmail(personalized, { variables: { recipientName: "Ada" } });
|
||||
expect(rendered.ok && rendered.value.parts.html.content).toContain("Hello Ada");
|
||||
const fallback = await renderEmail(personalized);
|
||||
expect(fallback.ok && fallback.value.parts.text.content).toContain("Hello friend");
|
||||
const strict = await renderEmail(personalized, { requireVariables: true });
|
||||
expect(strict.ok).toBe(true);
|
||||
personalized.root.slots.content[0]!.slots.content[0]!.props.text = "Hello {{recipientName}}";
|
||||
expect((await renderEmail(personalized, { requireVariables: true })).ok).toBe(false);
|
||||
});
|
||||
|
||||
test("rejects unsafe MJML and imports supported content", () => {
|
||||
expect(
|
||||
importMjml("<mjml><mj-body><mj-raw>x</mj-raw></mj-body></mjml>", {
|
||||
|
||||
Reference in new issue
Block a user