41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import { expect, test } from "bun:test";
|
|
import { createSectionPreset, emailPresets } from "../src/presets.ts";
|
|
import { renderEmailPreview } from "../src/browser.ts";
|
|
import type { BlockDocument } from "@wrnexus/blocks";
|
|
|
|
test("every designed preset renders natively without remote placeholder assets", async () => {
|
|
for (const preset of emailPresets) {
|
|
let id = 0;
|
|
const section = createSectionPreset(preset.id, () => `preset-${++id}`);
|
|
const document: BlockDocument = {
|
|
schemaVersion: 1,
|
|
kind: "email",
|
|
meta: { subject: "Preset QA" },
|
|
theme: { tokens: {} },
|
|
root: {
|
|
id: "root",
|
|
type: "layout.email-document",
|
|
version: 1,
|
|
props: { width: "600" },
|
|
styles: {},
|
|
slots: { content: [section] },
|
|
},
|
|
};
|
|
const before = JSON.stringify(document);
|
|
const result = await renderEmailPreview(document, {
|
|
variables: {
|
|
recipientName: "Alex",
|
|
organizationAddress: "Company address",
|
|
unsubscribeUrl: "https://example.com/unsubscribe",
|
|
},
|
|
});
|
|
expect(result.ok).toBe(true);
|
|
if (result.ok) {
|
|
expect(result.value.html).not.toContain("placehold.co");
|
|
expect(result.value.html).toContain(String(section.props.background));
|
|
expect(result.value.text.length).toBeGreaterThan(80);
|
|
}
|
|
expect(JSON.stringify(document)).toBe(before);
|
|
}
|
|
});
|